Skip to content

Commit dba5a0f

Browse files
authored
CAMEL-23270: Camel-Jbang-MCP: Add MCP tool annotations (readOnlyHint, destructiveHint, openWorldHint) to all tools (#22341)
Add @Tool.Annotations(readOnlyHint=true, destructiveHint=false, openWorldHint=false) to all 27 tool methods across 12 tool classes. All tools in this module are read-only (query catalogs, validate input, generate scaffolds) so this explicitly declares that to MCP clients, enabling auto-approval and better tool selection decisions. Quarkus MCP Server SDK 1.11.0 already supports these annotations. Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
1 parent eb79fd7 commit dba5a0f

File tree

12 files changed

+54
-27
lines changed

12 files changed

+54
-27
lines changed

dsl/camel-jbang/camel-jbang-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/CatalogTools.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ public class CatalogTools {
4444
/**
4545
* Tool to list available Camel components.
4646
*/
47-
@Tool(description = "List available Camel components from the catalog. " +
47+
@Tool(annotations = @Tool.Annotations(readOnlyHint = true, destructiveHint = false, openWorldHint = false),
48+
description = "List available Camel components from the catalog. " +
4849
"Returns component name, description, and labels. " +
4950
"Use filter to search by name, label to filter by category.")
5051
public ComponentListResult camel_catalog_components(
@@ -92,7 +93,8 @@ public ComponentListResult camel_catalog_components(
9293
/**
9394
* Tool to get detailed documentation for a specific component.
9495
*/
95-
@Tool(description = "Get detailed documentation for a Camel component including all options, " +
96+
@Tool(annotations = @Tool.Annotations(readOnlyHint = true, destructiveHint = false, openWorldHint = false),
97+
description = "Get detailed documentation for a Camel component including all options, " +
9698
"endpoint parameters, and usage examples.")
9799
public ComponentDetailResult camel_catalog_component_doc(
98100
@ToolArg(description = "Component name (e.g., kafka, http, file, timer)") String component,
@@ -154,7 +156,8 @@ public ComponentDetailResult camel_catalog_component_doc(
154156
/**
155157
* Tool to list data formats.
156158
*/
157-
@Tool(description = "List available Camel data formats for marshalling/unmarshalling " +
159+
@Tool(annotations = @Tool.Annotations(readOnlyHint = true, destructiveHint = false, openWorldHint = false),
160+
description = "List available Camel data formats for marshalling/unmarshalling " +
158161
"(e.g., json, xml, csv, avro, protobuf).")
159162
public DataFormatListResult camel_catalog_dataformats(
160163
@ToolArg(description = "Filter by name") String filter,
@@ -187,7 +190,8 @@ public DataFormatListResult camel_catalog_dataformats(
187190
/**
188191
* Tool to list expression languages.
189192
*/
190-
@Tool(description = "List available Camel expression languages " +
193+
@Tool(annotations = @Tool.Annotations(readOnlyHint = true, destructiveHint = false, openWorldHint = false),
194+
description = "List available Camel expression languages " +
191195
"(e.g., simple, jsonpath, xpath, groovy, jq).")
192196
public LanguageListResult camel_catalog_languages(
193197
@ToolArg(description = "Filter by name") String filter,
@@ -216,7 +220,8 @@ public LanguageListResult camel_catalog_languages(
216220
/**
217221
* Tool to get detailed documentation for a specific data format.
218222
*/
219-
@Tool(description = "Get detailed documentation for a Camel data format including all options, "
223+
@Tool(annotations = @Tool.Annotations(readOnlyHint = true, destructiveHint = false, openWorldHint = false),
224+
description = "Get detailed documentation for a Camel data format including all options, "
220225
+ "Maven coordinates, and configuration parameters.")
221226
public DataFormatDetailResult camel_catalog_dataformat_doc(
222227
@ToolArg(description = "Data format name (e.g., json-jackson, avro, csv, protobuf, jaxb)") String dataformat,
@@ -250,7 +255,8 @@ public DataFormatDetailResult camel_catalog_dataformat_doc(
250255
/**
251256
* Tool to get detailed documentation for a specific expression language.
252257
*/
253-
@Tool(description = "Get detailed documentation for a Camel expression language including all options, "
258+
@Tool(annotations = @Tool.Annotations(readOnlyHint = true, destructiveHint = false, openWorldHint = false),
259+
description = "Get detailed documentation for a Camel expression language including all options, "
254260
+ "Maven coordinates, and configuration parameters.")
255261
public LanguageDetailResult camel_catalog_language_doc(
256262
@ToolArg(description = "Language name (e.g., simple, jsonpath, xpath, jq, groovy)") String language,
@@ -283,7 +289,8 @@ public LanguageDetailResult camel_catalog_language_doc(
283289
/**
284290
* Tool to list EIPs (Enterprise Integration Patterns).
285291
*/
286-
@Tool(description = "List Camel Enterprise Integration Patterns (EIPs) like split, aggregate, " +
292+
@Tool(annotations = @Tool.Annotations(readOnlyHint = true, destructiveHint = false, openWorldHint = false),
293+
description = "List Camel Enterprise Integration Patterns (EIPs) like split, aggregate, " +
287294
"filter, choice, multicast, circuit-breaker, etc.")
288295
public EipListResult camel_catalog_eips(
289296
@ToolArg(description = "Filter by name") String filter,
@@ -314,7 +321,8 @@ public EipListResult camel_catalog_eips(
314321
/**
315322
* Tool to get detailed documentation for a specific EIP.
316323
*/
317-
@Tool(description = "Get detailed documentation for a Camel EIP (Enterprise Integration Pattern).")
324+
@Tool(annotations = @Tool.Annotations(readOnlyHint = true, destructiveHint = false, openWorldHint = false),
325+
description = "Get detailed documentation for a Camel EIP (Enterprise Integration Pattern).")
318326
public EipDetailResult camel_catalog_eip_doc(
319327
@ToolArg(description = "EIP name (e.g., split, aggregate, choice, filter)") String eip,
320328
@ToolArg(description = "Runtime type: main, spring-boot, or quarkus (default: main)") String runtime,

dsl/camel-jbang/camel-jbang-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/DependencyCheckTools.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ public class DependencyCheckTools {
4747
/**
4848
* Tool to check Camel dependency hygiene for a project.
4949
*/
50-
@Tool(description = "Check Camel project dependency hygiene. Given a pom.xml (and optionally route definitions), "
50+
@Tool(annotations = @Tool.Annotations(readOnlyHint = true, destructiveHint = false, openWorldHint = false),
51+
description = "Check Camel project dependency hygiene. Given a pom.xml (and optionally route definitions), "
5152
+ "detects outdated Camel dependencies compared to the latest catalog version, "
5253
+ "missing Maven dependencies for components used in routes, "
5354
+ "and version conflicts between the Camel BOM and explicit dependency overrides. "

dsl/camel-jbang/camel-jbang-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/DiagnoseTools.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ public class DiagnoseTools {
7272
/**
7373
* Tool to diagnose Camel errors from stack traces or error messages.
7474
*/
75-
@Tool(description = "Diagnose a Camel error from a stack trace or error message. "
75+
@Tool(annotations = @Tool.Annotations(readOnlyHint = true, destructiveHint = false, openWorldHint = false),
76+
description = "Diagnose a Camel error from a stack trace or error message. "
7677
+ "Returns the identified component/EIP involved, common causes for the error, "
7778
+ "links to relevant Camel documentation, and suggested fixes. "
7879
+ "Covers the most common Camel exceptions including NoSuchEndpointException, "

dsl/camel-jbang/camel-jbang-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/ExplainTools.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ public class ExplainTools {
4646
/**
4747
* Tool to get enriched context for a Camel route.
4848
*/
49-
@Tool(description = "Get enriched context for a Camel route including documentation for all components and EIPs used. "
49+
@Tool(annotations = @Tool.Annotations(readOnlyHint = true, destructiveHint = false, openWorldHint = false),
50+
description = "Get enriched context for a Camel route including documentation for all components and EIPs used. "
5051
+
5152
"Returns structured data with component descriptions, EIP explanations, and route structure. " +
5253
"Use this context to understand and explain the route.")

dsl/camel-jbang/camel-jbang-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/HardenTools.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ public class HardenTools {
4848
/**
4949
* Tool to get security hardening context for a Camel route.
5050
*/
51-
@Tool(description = "Get security hardening analysis context for a Camel route. " +
51+
@Tool(annotations = @Tool.Annotations(readOnlyHint = true, destructiveHint = false, openWorldHint = false),
52+
description = "Get security hardening analysis context for a Camel route. " +
5253
"Returns security-sensitive components, potential vulnerabilities, " +
5354
"and security best practices. Use this context to provide security " +
5455
"hardening recommendations for the route.")

dsl/camel-jbang/camel-jbang-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/KameletTools.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ public class KameletTools {
4040
/**
4141
* Tool to list available Kamelets.
4242
*/
43-
@Tool(description = "List available Camel Kamelets from the Kamelet Catalog. " +
43+
@Tool(annotations = @Tool.Annotations(readOnlyHint = true, destructiveHint = false, openWorldHint = false),
44+
description = "List available Camel Kamelets from the Kamelet Catalog. " +
4445
"Returns kamelet name, type (source, sink, action), support level, and description. " +
4546
"Use filter to search by name or description, type to filter by category.")
4647
public KameletListResult camel_catalog_kamelets(
@@ -97,7 +98,8 @@ public KameletListResult camel_catalog_kamelets(
9798
/**
9899
* Tool to get detailed documentation for a specific Kamelet.
99100
*/
100-
@Tool(description = "Get detailed documentation for a specific Camel Kamelet including all properties/options, "
101+
@Tool(annotations = @Tool.Annotations(readOnlyHint = true, destructiveHint = false, openWorldHint = false),
102+
description = "Get detailed documentation for a specific Camel Kamelet including all properties/options, "
101103
+ "dependencies, and usage information.")
102104
public KameletDetailResult camel_catalog_kamelet_doc(
103105
@ToolArg(description = "Kamelet name (e.g., aws-s3-source, kafka-sink, log-action)") String kamelet,

dsl/camel-jbang/camel-jbang-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/MigrationTools.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ public class MigrationTools {
4747
/**
4848
* Step 1: Analyze a project's pom.xml to detect runtime, Camel version, Java version, and components.
4949
*/
50-
@Tool(description = "Analyze a Camel project's pom.xml to detect the runtime type (main, spring-boot, quarkus, "
50+
@Tool(annotations = @Tool.Annotations(readOnlyHint = true, destructiveHint = false, openWorldHint = false),
51+
description = "Analyze a Camel project's pom.xml to detect the runtime type (main, spring-boot, quarkus, "
5152
+ "wildfly, karaf), Camel version, Java version, and Camel component dependencies. "
5253
+ "This is the first step in a migration workflow.")
5354
public ProjectAnalysisResult camel_migration_analyze(
@@ -96,7 +97,8 @@ public ProjectAnalysisResult camel_migration_analyze(
9697
/**
9798
* Step 2: Check compatibility and provide relevant migration guide references.
9899
*/
99-
@Tool(description = "Check migration compatibility for Camel components by providing relevant migration guide "
100+
@Tool(annotations = @Tool.Annotations(readOnlyHint = true, destructiveHint = false, openWorldHint = false),
101+
description = "Check migration compatibility for Camel components by providing relevant migration guide "
100102
+ "URLs and Java version requirements. The LLM should consult the migration guides for "
101103
+ "detailed component rename mappings and API changes.")
102104
public CompatibilityResult camel_migration_compatibility(
@@ -194,7 +196,8 @@ public CompatibilityResult camel_migration_compatibility(
194196
/**
195197
* Step 3: Get Maven commands to run OpenRewrite migration recipes.
196198
*/
197-
@Tool(description = "Get Maven commands to run Camel OpenRewrite migration recipes for upgrading between versions. "
199+
@Tool(annotations = @Tool.Annotations(readOnlyHint = true, destructiveHint = false, openWorldHint = false),
200+
description = "Get Maven commands to run Camel OpenRewrite migration recipes for upgrading between versions. "
198201
+ "Returns the exact Maven commands to execute on the project. "
199202
+ "PREREQUISITE: The project MUST compile successfully ('mvn clean compile' must pass) "
200203
+ "BEFORE running the OpenRewrite recipes. If the project does not compile, fix the build "
@@ -278,7 +281,8 @@ public MigrationRecipesResult camel_migration_recipes(
278281
/**
279282
* Search migration guides for a specific term.
280283
*/
281-
@Tool(description = "Search Camel migration and upgrade guides for a specific term or component name. "
284+
@Tool(annotations = @Tool.Annotations(readOnlyHint = true, destructiveHint = false, openWorldHint = false),
285+
description = "Search Camel migration and upgrade guides for a specific term or component name. "
282286
+ "Returns matching snippets from the official guides with version info and URLs. "
283287
+ "Supports fuzzy matching for typo tolerance. "
284288
+ "Use this instead of web search when looking up migration-related changes, "

dsl/camel-jbang/camel-jbang-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/MigrationWildflyKarafTools.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ public class MigrationWildflyKarafTools {
4242
/**
4343
* WildFly/Karaf migration guidance with archetype-based project creation.
4444
*/
45-
@Tool(description = "Get migration guidance for Camel projects running on WildFly, Karaf, or WAR-based "
45+
@Tool(annotations = @Tool.Annotations(readOnlyHint = true, destructiveHint = false, openWorldHint = false),
46+
description = "Get migration guidance for Camel projects running on WildFly, Karaf, or WAR-based "
4647
+ "application servers. Returns the Maven archetype command to create a new target project, "
4748
+ "migration steps, and relevant migration guide URLs. "
4849
+ "IMPORTANT: When migrating to a different runtime (e.g., WildFly to Quarkus, Karaf to Spring Boot), "

dsl/camel-jbang/camel-jbang-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/OpenApiTools.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ public class OpenApiTools {
4848

4949
private static final Set<String> VALID_MISSING_OPERATION_MODES = Set.of("fail", "ignore", "mock");
5050

51-
@Tool(description = "Validate an OpenAPI specification for use with Camel's contract-first REST support. "
51+
@Tool(annotations = @Tool.Annotations(readOnlyHint = true, destructiveHint = false, openWorldHint = false),
52+
description = "Validate an OpenAPI specification for use with Camel's contract-first REST support. "
5253
+ "Checks for compatibility issues like missing operationIds, unsupported security schemes, "
5354
+ "and OpenAPI 3.1 features that Camel does not fully support.")
5455
public ValidateResult camel_openapi_validate(
@@ -127,7 +128,8 @@ public ValidateResult camel_openapi_validate(
127128
return new ValidateResult(valid, errors, warnings, info, operationCount);
128129
}
129130

130-
@Tool(description = "Generate Camel YAML scaffold for contract-first OpenAPI integration. "
131+
@Tool(annotations = @Tool.Annotations(readOnlyHint = true, destructiveHint = false, openWorldHint = false),
132+
description = "Generate Camel YAML scaffold for contract-first OpenAPI integration. "
131133
+ "Produces a rest:openApi configuration block and route stubs for each operation "
132134
+ "defined in the spec. This is the recommended approach since Camel 4.6.")
133135
public ScaffoldResult camel_openapi_scaffold(
@@ -191,7 +193,8 @@ public ScaffoldResult camel_openapi_scaffold(
191193
return new ScaffoldResult(yaml.toString(), stubs.size(), filename, mode, apiTitle);
192194
}
193195

194-
@Tool(description = "Get guidance on configuring Camel's contract-first REST missingOperation modes "
196+
@Tool(annotations = @Tool.Annotations(readOnlyHint = true, destructiveHint = false, openWorldHint = false),
197+
description = "Get guidance on configuring Camel's contract-first REST missingOperation modes "
195198
+ "(fail, ignore, mock). For 'mock' mode, provides directory structure, mock file paths, "
196199
+ "and example content derived from the OpenAPI spec.")
197200
public MockGuidanceResult camel_openapi_mock_guidance(

dsl/camel-jbang/camel-jbang-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/TestScaffoldTools.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ public class TestScaffoldTools {
7272
/**
7373
* Tool to generate a JUnit 5 test skeleton for a Camel route.
7474
*/
75-
@Tool(description = "Generate a JUnit 5 test skeleton for a Camel route. "
75+
@Tool(annotations = @Tool.Annotations(readOnlyHint = true, destructiveHint = false, openWorldHint = false),
76+
description = "Generate a JUnit 5 test skeleton for a Camel route. "
7677
+ "Given a YAML or XML route definition, produces a test class with "
7778
+ "CamelTestSupport or @CamelSpringBootTest boilerplate, "
7879
+ "mock endpoints for producer endpoints, MockEndpoint assertions, "

0 commit comments

Comments
 (0)