You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "davsclaus (via GitHub)" <gi...@apache.org> on 2026/09/18 20:48:37 UTC
[PR] CAMEL-24828: the examples tools of camel-jbang-mcp list the examples by group [camel]
davsclaus opened a new pull request, #26605:
URL: https://github.com/apache/camel/pull/26605
Stacked on #26604 (base is its branch, so only this change shows in the diff; GitHub retargets to main when #26604 merges).
The MCP tools `camel_catalog_examples` / `camel_catalog_example_file` in camel-jbang-mcp, and `list_examples` / `get_example_file` in the camel-jbang-core AI tool registry, lagged behind the reorganized examples catalog (CAMEL-24824):
- in camel-jbang-mcp the three arguments were not declared optional, so a call without all of them failed with `Missing required argument: filter` (then `level`, then `limit`)
- the descriptions still spoke of a difficulty level (beginner, intermediate, advanced) while the catalog now has the 11 group levels, so an agent filtered with values that match nothing
- the new metadata (order, teaches, infraServices) was not returned and there was no way to get the groups with their title and intro
- the core registry capped the result at 20 with no limit argument, so an unfiltered listing dropped half of the 40 examples
Now both tools:
- take optional `filter`, `level` (a group) and `limit` (default 50)
- return `groups` (level, title, intro, count) and the `examples` in reading order, each with `order`, `teaches` (components, eips, languages, dataformats), `infraServices`, `bundled` and `files`, plus `count` and `total`
- describe the groups instead of difficulty levels
`ExampleHelper.getTeaches` is the new map accessor; `getTeachesSummary` now builds on it. Tests: `ExampleToolsTest` (new, 3) and two cases in `ToolRegistryTest`.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01Bp3538HRBPMQkb5ta9xRaj
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-24828: the examples tools of camel-jbang-mcp list the examples by group [camel]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #26605:
URL: https://github.com/apache/camel/pull/26605#issuecomment-5736007681
:star2: Thank you for your contribution to the Apache Camel project! :star2:
:robot: CI automation will test this PR automatically.
:camel: Apache Camel Committers, please review the following items:
* First-time contributors **require MANUAL approval** for the GitHub Actions to run
* You can use the command `/component-test (camel-)component-name1 (camel-)component-name2..` to request a test from the test bot although they are normally detected and executed by CI.
* You can label PRs using `skip-tests` and `test-dependents` to fine-tune the checks executed by this PR.
* Build and test logs are available in the summary page. **Only** [Apache Camel committers](https://camel.apache.org/community/team/#committers) have access to the summary.
:warning: Be careful when sharing logs. Review their contents before sharing them publicly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-24828: the examples tools of camel-jbang-mcp list the examples by group [camel]
Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus closed pull request #26605: CAMEL-24828: the examples tools of camel-jbang-mcp list the examples by group
URL: https://github.com/apache/camel/pull/26605
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-24828: the examples tools of camel-jbang-mcp list the examples by group [camel]
Posted by "gnodet-bot (via GitHub)" <gi...@apache.org>.
gnodet-bot commented on code in PR #26605:
URL: https://github.com/apache/camel/pull/26605#discussion_r4050693356
##########
dsl/camel-jbang/camel-jbang-mcp/src/test/java/org/apache/camel/dsl/jbang/core/commands/mcp/ExampleToolsTest.java:
##########
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.mcp;
+
+import java.util.List;
+
+import org.apache.camel.dsl.jbang.core.common.ExampleHelper;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+class ExampleToolsTest {
+
+ @Test
+ void listsTheWholeLadderInReadingOrderWithoutArguments() {
+ ExampleTools.ExampleListResult all = new ExampleTools().camel_catalog_examples(null, null, null);
+
+ assertThat(all.count()).isEqualTo(all.total());
+ assertThat(all.groups()).isNotEmpty();
+ List<String> levels = all.groups().stream().map(ExampleTools.GroupInfo::level).toList();
+ assertThat(levels).isSubsetOf(ExampleHelper.getGroupOrder());
+ assertThat(levels).isSortedAccordingTo((a, b) -> Integer.compare(
+ ExampleHelper.getGroupOrder().indexOf(a), ExampleHelper.getGroupOrder().indexOf(b)));
+ assertThat(levels.get(0)).isEqualTo("quick-start");
+ ExampleTools.GroupInfo first = all.groups().get(0);
+ assertThat(first.title()).isEqualTo(ExampleHelper.getGroupTitle("quick-start"));
+ assertThat(first.intro()).isNotBlank();
+
+ // the examples follow the groups in order
+ List<String> exampleLevels = all.examples().stream().map(ExampleTools.ExampleInfo::level).distinct().toList();
+ assertThat(exampleLevels).isEqualTo(levels);
+ assertThat(all.examples().stream().map(ExampleTools.ExampleInfo::name)).contains("quick-start/timer-log");
+ }
+
+ @Test
+ void filtersOneGroupAndReturnsWhatTheExamplesTeach() {
+ ExampleTools.ExampleListResult run = new ExampleTools().camel_catalog_examples(null, "run", null);
+
+ assertThat(run.groups()).hasSize(1);
+ assertThat(run.groups().get(0).level()).isEqualTo("run");
+ assertThat(run.groups().get(0).count()).isEqualTo(run.total());
+ assertThat(run.examples()).allMatch(e -> "run".equals(e.level()));
+ assertThat(run.examples()).isSortedAccordingTo((a, b) -> Integer.compare(a.order(), b.order()));
Review Comment:
⚠️ **NPE risk in sort comparator:** `Integer.compare(a.order(), b.order())` auto-unboxes both `Integer` arguments. `ExampleInfo.order()` is declared as `Integer` and `toExampleInfo` maps `getOrder() == Integer.MAX_VALUE → null`, so any example in the `run` group that carries no `order` metadata will produce a `null` here and throw a `NullPointerException` at test time.
The test happens to pass today because every current `run` example has an explicit `order` field. Adding a new example without one silently breaks the test suite.
Use a null-safe comparator:
```suggestion
assertThat(run.examples()).isSortedAccordingTo(
Comparator.comparingInt(e -> e.order() != null ? e.order() : Integer.MAX_VALUE));
```
##########
dsl/camel-jbang/camel-jbang-mcp/src/test/java/org/apache/camel/dsl/jbang/core/commands/mcp/ExampleToolsTest.java:
##########
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.mcp;
+
+import java.util.List;
+
+import org.apache.camel.dsl.jbang.core.common.ExampleHelper;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+class ExampleToolsTest {
+
+ @Test
+ void listsTheWholeLadderInReadingOrderWithoutArguments() {
+ ExampleTools.ExampleListResult all = new ExampleTools().camel_catalog_examples(null, null, null);
+
+ assertThat(all.count()).isEqualTo(all.total());
Review Comment:
⚠️ **Fragile implicit assumption:** `all.count() == all.total()` holds only while the total number of examples stays below the default limit of 50. The PR body itself mentions ~40 examples today, so this passes now — but when the catalog grows past 50 entries with no other code change, this assertion will fail and the breakage will be confusing (the code will be correct, only the test assumption will be wrong).
Make the intent explicit:
```suggestion
assertThat(all.count()).isEqualTo(all.total()); // true while total examples < default limit (50)
```
Or, better, pass an explicit limit larger than the catalog and assert equality against that:
```java
ExampleTools.ExampleListResult all = new ExampleTools().camel_catalog_examples(null, null, 1000);
assertThat(all.count()).isEqualTo(all.total());
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org