This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git
The following commit(s) were added to refs/heads/main by this push:
new e32f2faec Fix #3362: new ai-tool-source Kamelet offers a flow as a
tool for AI agents and MCP clients (#3364)
e32f2faec is described below
commit e32f2faec93aa323e442adc487e11c760501eb78
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon Nov 23 15:14:35 2026 +0100
Fix #3362: new ai-tool-source Kamelet offers a flow as a tool for AI agents
and MCP clients (#3364)
* Fix #3362: new ai-tool-source Kamelet offers a flow as a tool for AI
agents and MCP clients
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y4dDmBDsSWV117kccuNf9
* Fix #3362: the description names only the openai component as another
caller of the tool
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y4dDmBDsSWV117kccuNf9
* chore: regenerate the catalog files after merging main
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y4dDmBDsSWV117kccuNf9
* chore: regenerate the catalog files after merging main
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y4dDmBDsSWV117kccuNf9
* Fix #3362: ai-tool-source refuses undeclared arguments, and
camel.server.mcp-enabled alone serves MCP (CAMEL-27405, CAMEL-27404)
- argSchema: Camel adds additionalProperties false when the schema does not
set it, so a call with an undeclared argument is refused (described).
- camel.server.mcp-enabled works from --prop and -D too and turns the HTTP
server on; the description no longer asks for camel.server.enabled.
- The MCP test drops camel.server.enabled, expects additionalProperties
false
in the listed schema, and checks that extra and CamelHttpUri are refused.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y4dDmBDsSWV117kccuNf9
---------
Co-authored-by: Claude Opus 5.5 <[email protected]>
---
.../camel-kamelets-catalog-sbom.json | 24 ++-
docs/modules/ROOT/nav.adoc | 1 +
kamelets/ai-tool-source.kamelet.yaml | 129 ++++++++++++
.../main/resources/META-INF/kamelets-index.json | 10 +
.../resources/kamelets/ai-tool-source.kamelet.yaml | 129 ++++++++++++
.../src/test/java/AiToolIT.java | 50 +++++
.../src/test/resources/aitool/ai-tool-route.yaml | 61 ++++++
.../aitool/ai-tool-source-mcp.citrus.it.yaml | 222 +++++++++++++++++++++
8 files changed, 625 insertions(+), 1 deletion(-)
diff --git a/camel-kamelets-sbom/camel-kamelets-catalog-sbom.json
b/camel-kamelets-sbom/camel-kamelets-catalog-sbom.json
index b76288e8a..d58769aa6 100644
--- a/camel-kamelets-sbom/camel-kamelets-catalog-sbom.json
+++ b/camel-kamelets-sbom/camel-kamelets-catalog-sbom.json
@@ -12,6 +12,11 @@
}
},
"components" : [ {
+ "bom-ref" : "kamelet:ai-tool-source",
+ "type" : "library",
+ "name" : "ai-tool-source",
+ "version" : "4.24.0-SNAPSHOT"
+ }, {
"bom-ref" : "kamelet:avro-deserialize-action",
"type" : "library",
"name" : "avro-deserialize-action",
@@ -1221,6 +1226,17 @@
"name" : "artemis-jakarta-client-all",
"version" : "2.57.0",
"purl" : "pkg:maven/org.apache.activemq/[email protected]"
+ }, {
+ "bom-ref" : "pkg:maven/org.apache.camel/[email protected]",
+ "type" : "library",
+ "group" : "org.apache.camel",
+ "name" : "camel-ai-tool",
+ "version" : "4.24.0-SNAPSHOT",
+ "purl" : "pkg:maven/org.apache.camel/[email protected]",
+ "properties" : [ {
+ "name" : "camel.apache.org/versioned-by",
+ "value" : "runtime"
+ } ]
}, {
"bom-ref" : "pkg:maven/org.apache.camel/[email protected]",
"type" : "library",
@@ -2495,7 +2511,10 @@
} ],
"dependencies" : [ {
"ref" : "camel-kamelets-catalog",
- "dependsOn" : [ "kamelet:avro-deserialize-action",
"kamelet:avro-serialize-action", "kamelet:aws-bedrock-agent-runtime-sink",
"kamelet:aws-bedrock-agent-sink", "kamelet:aws-bedrock-text-sink",
"kamelet:aws-cloudtrail-source", "kamelet:aws-cloudwatch-sink",
"kamelet:aws-comprehend-sink", "kamelet:aws-ddb-sink",
"kamelet:aws-ddb-streams-source", "kamelet:aws-ec2-sink",
"kamelet:aws-eventbridge-sink", "kamelet:aws-eventbridge-source",
"kamelet:aws-kinesis-firehose-sink", "kamelet:aws-ki [...]
+ "dependsOn" : [ "kamelet:ai-tool-source",
"kamelet:avro-deserialize-action", "kamelet:avro-serialize-action",
"kamelet:aws-bedrock-agent-runtime-sink", "kamelet:aws-bedrock-agent-sink",
"kamelet:aws-bedrock-text-sink", "kamelet:aws-cloudtrail-source",
"kamelet:aws-cloudwatch-sink", "kamelet:aws-comprehend-sink",
"kamelet:aws-ddb-sink", "kamelet:aws-ddb-streams-source",
"kamelet:aws-ec2-sink", "kamelet:aws-eventbridge-sink",
"kamelet:aws-eventbridge-source", "kamelet:aws-kinesis-fireh [...]
+ }, {
+ "ref" : "kamelet:ai-tool-source",
+ "dependsOn" : [
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]" ]
}, {
"ref" : "kamelet:avro-deserialize-action",
"dependsOn" : [
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]" ]
@@ -3216,6 +3235,9 @@
}, {
"ref" : "pkg:maven/org.apache.activemq/[email protected]",
"dependsOn" : [ ]
+ }, {
+ "ref" : "pkg:maven/org.apache.camel/[email protected]",
+ "dependsOn" : [ ]
}, {
"ref" : "pkg:maven/org.apache.camel/[email protected]",
"dependsOn" : [ ]
diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc
index 257764551..7b7b376b2 100644
--- a/docs/modules/ROOT/nav.adoc
+++ b/docs/modules/ROOT/nav.adoc
@@ -1,4 +1,5 @@
// THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT
+* xref:ai-tool-source.adoc[]
* xref:avro-deserialize-action.adoc[]
* xref:avro-serialize-action.adoc[]
* xref:aws-bedrock-agent-runtime-sink.adoc[]
diff --git a/kamelets/ai-tool-source.kamelet.yaml
b/kamelets/ai-tool-source.kamelet.yaml
new file mode 100644
index 000000000..eaff55e79
--- /dev/null
+++ b/kamelets/ai-tool-source.kamelet.yaml
@@ -0,0 +1,129 @@
+# ---------------------------------------------------------------------------
+# 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.
+# ---------------------------------------------------------------------------
+apiVersion: camel.apache.org/v1
+kind: Kamelet
+metadata:
+ name: ai-tool-source
+ annotations:
+ camel.apache.org/kamelet.support.level: "Preview"
+ camel.apache.org/catalog.version: "4.24.0-SNAPSHOT"
+ camel.apache.org/kamelet.icon:
"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2NCA2NCI+PGNpcmNsZSBjeD0iMzIiIGN5PSIzMiIgcj0iMzAiIGZpbGw9IiMxZjZmZWIiLz48cGF0aCBkPSJNNDEuNSAxNC41YTEwIDEwIDAgMCAwLTEyLjMgMTIuNkwxNS42IDQwLjdhNCA0IDAgMCAwIDUuNyA1LjdsMTMuNi0xMy42YTEwIDEwIDAgMCAwIDEyLjYtMTIuM2wtNiA2LTUuMi0xLjQtMS40LTUuMnoiIGZpbGw9IiNmZmYiLz48Y2lyY2xlIGN4PSIxOC41IiBjeT0iNDMuNSIgcj0iMS42IiBmaWxsPSIjMWY2ZmViIi8+PC9zdmc+Cg=="
+ camel.apache.org/provider: "Apache Software Foundation"
+ camel.apache.org/kamelet.group: "AI Tool"
+ camel.apache.org/kamelet.namespace: "AI"
+ labels:
+ camel.apache.org/kamelet.type: "source"
+ camel.apache.org/kamelet.verified: "true"
+spec:
+ definition:
+ title: "AI Tool Source"
+ description: |-
+ Offers the steps that follow it as a tool that an AI agent can call,
such as an MCP client like Claude Desktop or Cursor, with the arguments of each
call as JSON.
+
+ Use it to let an AI assistant look up or change data through a flow you
control, such as returning the status of an order. In a route (YAML), the steps
after `from: kamelet:ai-tool-source` run for each call; they can also hand the
call on with `to: kamelet:<name>`. To offer the tool over MCP, set
`camel.server.mcp-enabled=true` and `camel.server.mcp-tags` to its tag, in
`application.properties` or with `--prop` or `-D`: Camel JBang then adds
`camel-mcp-server` by itself, other appl [...]
+
+ Output: the body is the arguments of the call, as JSON text, such as
`{"orderId":"42"}`, with only the arguments that `argSchema` declares (`{}` for
a tool without arguments). Each of them is also a header of its own name, such
as `orderId`. The body at the end of the flow, as text, is the result the
caller gets back; the headers are not sent back. A flow that does not change
the body gives the caller its own arguments back.
+
+ Good to know: an MCP client is an untrusted sender. Anyone who can reach
the MCP endpoint can call every tool it offers, with any arguments, so check
them before you use them. The MCP server offers only the tools whose tag is in
`camel.server.mcp-tags`, never one with another tag. It listens on all network
interfaces by default (`camel.server.host`) and has no login: protect it with
OAuth (`camel.server.mcp-oauth-profile`) or network rules. A call from a web
page of another host is [...]
+ required:
+ - toolName
+ - description
+ - tags
+ type: object
+ properties:
+ toolName:
+ title: Tool Name
+ description: The name of the tool, which the AI model sees and calls
it by. Letters, digits, `_` and `-` only, at most 64 characters, such as
`get_order_status`. It must be unique among the tools the application offers.
+ type: string
+ pattern: "^[A-Za-z0-9_-]{1,64}$"
+ example: get_order_status
+ description:
+ title: Description
+ description: What the tool does and when to use it, written for the AI
model, which reads it to decide whether to call the tool, such as `Returns the
status of an order by its id`.
+ type: string
+ example: Returns the status of an order by its id
+ tags:
+ title: Tags
+ description: One or more tags, separated by commas, that put the tool
in groups, such as `orders`. An MCP server offers only the tools whose tag is
in its `camel.server.mcp-tags` setting.
+ type: string
+ pattern: "^\\s*[^,\\s]+(\\s*,\\s*[^,\\s]+)*\\s*$"
+ example: orders
+ argSchema:
+ title: Arguments Schema
+ description: 'The JSON Schema of the arguments of the tool, an
`object` with its `properties` and the `required` ones, such as
`{"type":"object","properties":{"orderId":{"type":"string","description":"The
order id"}},"required":["orderId"]}`. It can also be read from a file, with
`file:` or `classpath:` in front of its location. When it does not set
`additionalProperties`, Camel adds `additionalProperties: false`, so a call
with an argument it does not declare is refused; with an [...]
+ type: string
+ example:
'{"type":"object","properties":{"orderId":{"type":"string","description":"The
order id"}},"required":["orderId"]}'
+ title:
+ title: Title
+ description: A name of the tool for people, which an MCP client may
show instead of the tool name, such as `Order status`.
+ type: string
+ example: Order status
+ readOnlyHint:
+ title: Read Only Hint
+ description: Tells an MCP client that the tool only reads data and
changes nothing. A hint only, which Camel does not check.
+ type: boolean
+ destructiveHint:
+ title: Destructive Hint
+ description: Tells an MCP client that the tool may delete or overwrite
data. A hint only, which Camel does not check.
+ type: boolean
+ idempotentHint:
+ title: Idempotent Hint
+ description: Tells an MCP client that calling the tool again with the
same arguments changes nothing more. A hint only, which Camel does not check.
+ type: boolean
+ openWorldHint:
+ title: Open World Hint
+ description: Tells an MCP client that the tool works with systems
outside the application, such as the internet. A hint only, which Camel does
not check.
+ type: boolean
+ allowedRoles:
+ title: Allowed Roles
+ description: The roles, separated by commas, of which the caller needs
one to call the tool, such as `finance`. The roles come from the login of the
caller (MCP over HTTP with OAuth); a caller without a login is refused.
+ type: string
+ example: finance
+ allRolesRequired:
+ title: All Roles Required
+ description: Whether the caller needs all the roles of `allowedRoles`
instead of one of them.
+ type: boolean
+ default: false
+ dataTypes:
+ # No headers listed and no 'default:' on purpose: over MCP the flow gets
no header of its own,
+ # only one header per declared argument, named as the argument, and a
default would run a
+ # transformer on every call. See #3117.
+ out:
+ headers: {}
+ dependencies:
+ # camel-mcp-server is not a dependency on purpose: the tool can also be
called by the openai component,
+ # and Camel JBang adds camel-mcp-server when camel.server.mcp-enabled is
set.
+ - "camel:ai-tool"
+ - "camel:kamelet"
+ template:
+ from:
+ uri: "ai-tool:{{toolName}}"
+ parameters:
+ description: "{{description}}"
+ tags: "{{tags}}"
+ argSchema: "RAW({{?argSchema}})"
+ title: "{{?title}}"
+ readOnlyHint: "{{?readOnlyHint}}"
+ destructiveHint: "{{?destructiveHint}}"
+ idempotentHint: "{{?idempotentHint}}"
+ openWorldHint: "{{?openWorldHint}}"
+ allowedRoles: "{{?allowedRoles}}"
+ allRolesRequired: "{{allRolesRequired}}"
+ argumentsAsBody: true
+ steps:
+ - to:
+ uri: kamelet:sink
diff --git
a/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
b/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
index d2d22c5a0..cf154d752 100644
--- a/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
+++ b/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
@@ -1,5 +1,15 @@
{
"kamelets" : [ {
+ "name" : "ai-tool-source",
+ "type" : "source",
+ "supportLevel" : "Preview",
+ "title" : "AI Tool Source",
+ "summary" : "Offers the steps that follow it as a tool that an AI agent
can call, such as an MCP client like Claude Desktop or Cursor, with the
arguments of each call as JSON.",
+ "description" : "Offers the steps that follow it as a tool that an AI
agent can call, such as an MCP client like Claude Desktop or Cursor, with the
arguments of each call as JSON.\n\nUse it to let an AI assistant look up or
change data through a flow you control, such as returning the status of an
order. In a route (YAML), the steps after `from: kamelet:ai-tool-source` run
for each call; they can also hand the call on with `to: kamelet:<name>`. To
offer the tool over MCP, set `camel. [...]
+ "group" : "AI Tool",
+ "namespace" : "AI",
+ "provider" : "Apache Software Foundation"
+ }, {
"name" : "avro-deserialize-action",
"type" : "action",
"supportLevel" : "Stable",
diff --git
a/library/camel-kamelets/src/main/resources/kamelets/ai-tool-source.kamelet.yaml
b/library/camel-kamelets/src/main/resources/kamelets/ai-tool-source.kamelet.yaml
new file mode 100644
index 000000000..eaff55e79
--- /dev/null
+++
b/library/camel-kamelets/src/main/resources/kamelets/ai-tool-source.kamelet.yaml
@@ -0,0 +1,129 @@
+# ---------------------------------------------------------------------------
+# 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.
+# ---------------------------------------------------------------------------
+apiVersion: camel.apache.org/v1
+kind: Kamelet
+metadata:
+ name: ai-tool-source
+ annotations:
+ camel.apache.org/kamelet.support.level: "Preview"
+ camel.apache.org/catalog.version: "4.24.0-SNAPSHOT"
+ camel.apache.org/kamelet.icon:
"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2NCA2NCI+PGNpcmNsZSBjeD0iMzIiIGN5PSIzMiIgcj0iMzAiIGZpbGw9IiMxZjZmZWIiLz48cGF0aCBkPSJNNDEuNSAxNC41YTEwIDEwIDAgMCAwLTEyLjMgMTIuNkwxNS42IDQwLjdhNCA0IDAgMCAwIDUuNyA1LjdsMTMuNi0xMy42YTEwIDEwIDAgMCAwIDEyLjYtMTIuM2wtNiA2LTUuMi0xLjQtMS40LTUuMnoiIGZpbGw9IiNmZmYiLz48Y2lyY2xlIGN4PSIxOC41IiBjeT0iNDMuNSIgcj0iMS42IiBmaWxsPSIjMWY2ZmViIi8+PC9zdmc+Cg=="
+ camel.apache.org/provider: "Apache Software Foundation"
+ camel.apache.org/kamelet.group: "AI Tool"
+ camel.apache.org/kamelet.namespace: "AI"
+ labels:
+ camel.apache.org/kamelet.type: "source"
+ camel.apache.org/kamelet.verified: "true"
+spec:
+ definition:
+ title: "AI Tool Source"
+ description: |-
+ Offers the steps that follow it as a tool that an AI agent can call,
such as an MCP client like Claude Desktop or Cursor, with the arguments of each
call as JSON.
+
+ Use it to let an AI assistant look up or change data through a flow you
control, such as returning the status of an order. In a route (YAML), the steps
after `from: kamelet:ai-tool-source` run for each call; they can also hand the
call on with `to: kamelet:<name>`. To offer the tool over MCP, set
`camel.server.mcp-enabled=true` and `camel.server.mcp-tags` to its tag, in
`application.properties` or with `--prop` or `-D`: Camel JBang then adds
`camel-mcp-server` by itself, other appl [...]
+
+ Output: the body is the arguments of the call, as JSON text, such as
`{"orderId":"42"}`, with only the arguments that `argSchema` declares (`{}` for
a tool without arguments). Each of them is also a header of its own name, such
as `orderId`. The body at the end of the flow, as text, is the result the
caller gets back; the headers are not sent back. A flow that does not change
the body gives the caller its own arguments back.
+
+ Good to know: an MCP client is an untrusted sender. Anyone who can reach
the MCP endpoint can call every tool it offers, with any arguments, so check
them before you use them. The MCP server offers only the tools whose tag is in
`camel.server.mcp-tags`, never one with another tag. It listens on all network
interfaces by default (`camel.server.host`) and has no login: protect it with
OAuth (`camel.server.mcp-oauth-profile`) or network rules. A call from a web
page of another host is [...]
+ required:
+ - toolName
+ - description
+ - tags
+ type: object
+ properties:
+ toolName:
+ title: Tool Name
+ description: The name of the tool, which the AI model sees and calls
it by. Letters, digits, `_` and `-` only, at most 64 characters, such as
`get_order_status`. It must be unique among the tools the application offers.
+ type: string
+ pattern: "^[A-Za-z0-9_-]{1,64}$"
+ example: get_order_status
+ description:
+ title: Description
+ description: What the tool does and when to use it, written for the AI
model, which reads it to decide whether to call the tool, such as `Returns the
status of an order by its id`.
+ type: string
+ example: Returns the status of an order by its id
+ tags:
+ title: Tags
+ description: One or more tags, separated by commas, that put the tool
in groups, such as `orders`. An MCP server offers only the tools whose tag is
in its `camel.server.mcp-tags` setting.
+ type: string
+ pattern: "^\\s*[^,\\s]+(\\s*,\\s*[^,\\s]+)*\\s*$"
+ example: orders
+ argSchema:
+ title: Arguments Schema
+ description: 'The JSON Schema of the arguments of the tool, an
`object` with its `properties` and the `required` ones, such as
`{"type":"object","properties":{"orderId":{"type":"string","description":"The
order id"}},"required":["orderId"]}`. It can also be read from a file, with
`file:` or `classpath:` in front of its location. When it does not set
`additionalProperties`, Camel adds `additionalProperties: false`, so a call
with an argument it does not declare is refused; with an [...]
+ type: string
+ example:
'{"type":"object","properties":{"orderId":{"type":"string","description":"The
order id"}},"required":["orderId"]}'
+ title:
+ title: Title
+ description: A name of the tool for people, which an MCP client may
show instead of the tool name, such as `Order status`.
+ type: string
+ example: Order status
+ readOnlyHint:
+ title: Read Only Hint
+ description: Tells an MCP client that the tool only reads data and
changes nothing. A hint only, which Camel does not check.
+ type: boolean
+ destructiveHint:
+ title: Destructive Hint
+ description: Tells an MCP client that the tool may delete or overwrite
data. A hint only, which Camel does not check.
+ type: boolean
+ idempotentHint:
+ title: Idempotent Hint
+ description: Tells an MCP client that calling the tool again with the
same arguments changes nothing more. A hint only, which Camel does not check.
+ type: boolean
+ openWorldHint:
+ title: Open World Hint
+ description: Tells an MCP client that the tool works with systems
outside the application, such as the internet. A hint only, which Camel does
not check.
+ type: boolean
+ allowedRoles:
+ title: Allowed Roles
+ description: The roles, separated by commas, of which the caller needs
one to call the tool, such as `finance`. The roles come from the login of the
caller (MCP over HTTP with OAuth); a caller without a login is refused.
+ type: string
+ example: finance
+ allRolesRequired:
+ title: All Roles Required
+ description: Whether the caller needs all the roles of `allowedRoles`
instead of one of them.
+ type: boolean
+ default: false
+ dataTypes:
+ # No headers listed and no 'default:' on purpose: over MCP the flow gets
no header of its own,
+ # only one header per declared argument, named as the argument, and a
default would run a
+ # transformer on every call. See #3117.
+ out:
+ headers: {}
+ dependencies:
+ # camel-mcp-server is not a dependency on purpose: the tool can also be
called by the openai component,
+ # and Camel JBang adds camel-mcp-server when camel.server.mcp-enabled is
set.
+ - "camel:ai-tool"
+ - "camel:kamelet"
+ template:
+ from:
+ uri: "ai-tool:{{toolName}}"
+ parameters:
+ description: "{{description}}"
+ tags: "{{tags}}"
+ argSchema: "RAW({{?argSchema}})"
+ title: "{{?title}}"
+ readOnlyHint: "{{?readOnlyHint}}"
+ destructiveHint: "{{?destructiveHint}}"
+ idempotentHint: "{{?idempotentHint}}"
+ openWorldHint: "{{?openWorldHint}}"
+ allowedRoles: "{{?allowedRoles}}"
+ allRolesRequired: "{{allRolesRequired}}"
+ argumentsAsBody: true
+ steps:
+ - to:
+ uri: kamelet:sink
diff --git a/tests/camel-kamelets-itest/src/test/java/AiToolIT.java
b/tests/camel-kamelets-itest/src/test/java/AiToolIT.java
new file mode 100644
index 000000000..7426532fb
--- /dev/null
+++ b/tests/camel-kamelets-itest/src/test/java/AiToolIT.java
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+
+import java.util.stream.Stream;
+
+import org.citrusframework.api.common.TestLoader;
+import org.citrusframework.container.SequenceBeforeTest;
+import org.citrusframework.junit.jupiter.CitrusSupport;
+import org.citrusframework.junit.jupiter.CitrusTestFactory;
+import org.citrusframework.junit.jupiter.CitrusTestFactorySupport;
+import org.citrusframework.spi.BindToRegistry;
+import org.junit.jupiter.api.DynamicTest;
+
+import static
org.citrusframework.actions.CreateVariablesAction.Builder.createVariables;
+
+/**
+ * The ai-tool-source Kamelet, offered over MCP by camel-mcp-server on the
HTTP port of the integration.
+ */
+@CitrusSupport
+public class AiToolIT {
+
+ private final int mcpPort = ServerPorts.next();
+
+ @BindToRegistry
+ public SequenceBeforeTest beforeAiTool() {
+ return new SequenceBeforeTest.Builder().onTests("ai-tool-*").actions(
+ createVariables()
+ .variable("ai.tool.port", String.valueOf(mcpPort))
+ ).build();
+ }
+
+ @CitrusTestFactory
+ public Stream<DynamicTest> aiTool() {
+ return
CitrusTestFactorySupport.factory(TestLoader.YAML).packageScan("aitool");
+ }
+}
diff --git
a/tests/camel-kamelets-itest/src/test/resources/aitool/ai-tool-route.yaml
b/tests/camel-kamelets-itest/src/test/resources/aitool/ai-tool-route.yaml
new file mode 100644
index 000000000..14d69a3fe
--- /dev/null
+++ b/tests/camel-kamelets-itest/src/test/resources/aitool/ai-tool-route.yaml
@@ -0,0 +1,61 @@
+# ---------------------------------------------------------------------------
+# 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.
+# ---------------------------------------------------------------------------
+# Three tools: two with the tag orders, which the MCP server offers, and one
with the tag admin, which it does not
+- route:
+ id: "order-status"
+ from:
+ uri: "kamelet:ai-tool-source"
+ parameters:
+ toolName: "get_order_status"
+ description: "Returns the status of an order by its id"
+ tags: "orders"
+ title: "Order status"
+ readOnlyHint: true
+ argSchema:
'{"type":"object","properties":{"orderId":{"type":"string","description":"The
order id (digits)"},"note":{"type":"string"}},"required":["orderId"]}'
+ steps:
+ - log: "Order tool got ${body} with orderId=${header.orderId}
note=${header.note} extra=${header.extra} CamelHttpUri=${header.CamelHttpUri}"
+ # a header of the flow does not go back to the caller, only the body
+ - setHeader:
+ name: "Internal"
+ constant: "not-for-the-caller"
+ - setBody:
+ simple: '{"orderId":"${header.orderId}","status":"shipped"}'
+- route:
+ id: "pay-invoice"
+ from:
+ uri: "kamelet:ai-tool-source"
+ parameters:
+ toolName: "pay_invoice"
+ description: "Pays an invoice"
+ tags: "orders"
+ allowedRoles: "finance"
+ steps:
+ - log: "Pay tool called"
+ - setBody:
+ constant: "paid"
+- route:
+ id: "delete-order"
+ from:
+ uri: "kamelet:ai-tool-source"
+ parameters:
+ toolName: "delete_order"
+ description: "Deletes an order"
+ tags: "admin"
+ destructiveHint: true
+ steps:
+ - setBody:
+ constant: "deleted"
diff --git
a/tests/camel-kamelets-itest/src/test/resources/aitool/ai-tool-source-mcp.citrus.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/aitool/ai-tool-source-mcp.citrus.it.yaml
new file mode 100644
index 000000000..1573aa536
--- /dev/null
+++
b/tests/camel-kamelets-itest/src/test/resources/aitool/ai-tool-source-mcp.citrus.it.yaml
@@ -0,0 +1,222 @@
+# ---------------------------------------------------------------------------
+# 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.
+# ---------------------------------------------------------------------------
+
+name: ai-tool-source-mcp-test
+description: 'ai-tool-source offers its flow as a tool over MCP: the tools of
the tag orders are listed with their schema and hints, a call gets the declared
arguments as JSON and the reply of the flow back, a call with an undeclared
argument is refused, a tool with allowedRoles refuses a caller without login,
and a tool of another tag is neither listed nor callable'
+variables:
+ - name: "mcp.accept"
+ value: "application/json, text/event-stream"
+actions:
+ - camel:
+ cli:
+ run:
+ integration:
+ file: "aitool/ai-tool-route.yaml"
+ systemProperties:
+ properties:
+ - name: "camel.server.port"
+ value: "${ai.tool.port}"
+ - name: "camel.server.mcp-enabled"
+ value: "true"
+ - name: "camel.server.mcp-tags"
+ value: "orders"
+
+ # MCP streamable HTTP: initialize opens a session, given in the
Mcp-Session-Id header
+ - http:
+ client: "http://localhost:${ai.tool.port}"
+ sendRequest:
+ POST:
+ path: "/mcp"
+ contentType: "application/json"
+ headers:
+ - name: "Accept"
+ value: "${mcp.accept}"
+ body:
+ data:
'{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"citrus","version":"1"}}}'
+ - http:
+ client: "http://localhost:${ai.tool.port}"
+ receiveResponse:
+ response:
+ status: 200
+ type: "plaintext"
+ body:
+ data: '@contains(''"tools":{"listChanged":true}'')@'
+ extract:
+ header:
+ - name: "Mcp-Session-Id"
+ variable: "mcp.session"
+ - http:
+ client: "http://localhost:${ai.tool.port}"
+ sendRequest:
+ POST:
+ path: "/mcp"
+ contentType: "application/json"
+ headers:
+ - name: "Accept"
+ value: "${mcp.accept}"
+ - name: "Mcp-Session-Id"
+ value: "${mcp.session}"
+ body:
+ data: '{"jsonrpc":"2.0","method":"notifications/initialized"}'
+ - http:
+ client: "http://localhost:${ai.tool.port}"
+ receiveResponse:
+ response:
+ status: 202
+
+ # tools/list: the two tools of the tag orders, with their schema and hints,
and not the tool of the tag admin
+ - http:
+ client: "http://localhost:${ai.tool.port}"
+ sendRequest:
+ POST:
+ path: "/mcp"
+ contentType: "application/json"
+ headers:
+ - name: "Accept"
+ value: "${mcp.accept}"
+ - name: "Mcp-Session-Id"
+ value: "${mcp.session}"
+ body:
+ data: '{"jsonrpc":"2.0","id":2,"method":"tools/list"}'
+ - http:
+ client: "http://localhost:${ai.tool.port}"
+ receiveResponse:
+ response:
+ status: 200
+ type: "plaintext"
+ body:
+ data:
'@matches(''(?s)(?!.*delete_order).*\Q{"name":"get_order_status","title":"Order
status","description":"Returns the status of an order by its
id","inputSchema":{"additionalProperties":false,"type":"object","properties":{"orderId":{"type":"string","description":"The
order id
(digits)"},"note":{"type":"string"}},"required":["orderId"]},"annotations":{"readOnlyHint":true}}\E.*\Q{"name":"pay_invoice","description":"Pays
an invoice","inputSchema":{"additionalProperties":false [...]
+
+ # tools/call: the flow gets the arguments as JSON, and its body is the result
+ - http:
+ client: "http://localhost:${ai.tool.port}"
+ sendRequest:
+ POST:
+ path: "/mcp"
+ contentType: "application/json"
+ headers:
+ - name: "Accept"
+ value: "${mcp.accept}"
+ - name: "Mcp-Session-Id"
+ value: "${mcp.session}"
+ body:
+ data:
'{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"get_order_status","arguments":{"orderId":"42","note":"urgent"}}}'
+ - http:
+ client: "http://localhost:${ai.tool.port}"
+ receiveResponse:
+ response:
+ status: 200
+ type: "plaintext"
+ body:
+ data:
'@contains(''{"jsonrpc":"2.0","id":3,"result":{"content":[{"type":"text","text":"{\"orderId\":\"42\",\"status\":\"shipped\"}"}],"isError":false}}'')@'
+ - camel:
+ cli:
+ verify:
+ integration: "ai-tool-route"
+ logMessage: 'Order tool got {"orderId":"42","note":"urgent"} with
orderId=42 note=urgent extra= CamelHttpUri='
+
+ # A call with an argument that argSchema does not declare is refused before
the flow runs, a Camel header among them
+ - http:
+ client: "http://localhost:${ai.tool.port}"
+ sendRequest:
+ POST:
+ path: "/mcp"
+ contentType: "application/json"
+ headers:
+ - name: "Accept"
+ value: "${mcp.accept}"
+ - name: "Mcp-Session-Id"
+ value: "${mcp.session}"
+ body:
+ data:
'{"jsonrpc":"2.0","id":4,"method":"tools/call","params":{"name":"get_order_status","arguments":{"orderId":"42","extra":"x","CamelHttpUri":"http://example.com"}}}'
+ - http:
+ client: "http://localhost:${ai.tool.port}"
+ receiveResponse:
+ response:
+ status: 200
+ type: "plaintext"
+ body:
+ data:
'@matches(''(?s).*\Q"id":4,"result":{"content":[{"type":"text","text":"Tool
(get_order_status) input validation
failed\E.*extra.*CamelHttpUri.*\Q"isError":true}}\E.*'')@'
+
+ # A call that misses a required argument is refused before the flow runs
+ - http:
+ client: "http://localhost:${ai.tool.port}"
+ sendRequest:
+ POST:
+ path: "/mcp"
+ contentType: "application/json"
+ headers:
+ - name: "Accept"
+ value: "${mcp.accept}"
+ - name: "Mcp-Session-Id"
+ value: "${mcp.session}"
+ body:
+ data:
'{"jsonrpc":"2.0","id":5,"method":"tools/call","params":{"name":"get_order_status","arguments":{"note":"no
id"}}}'
+ - http:
+ client: "http://localhost:${ai.tool.port}"
+ receiveResponse:
+ response:
+ status: 200
+ type: "plaintext"
+ body:
+ data:
'@matches(''(?s).*\Q"id":5,"result":{"content":[{"type":"text","text":"Tool
(get_order_status) input validation
failed\E.*orderId.*\Q"isError":true}}\E.*'')@'
+
+ # allowedRoles: a caller without login is refused
+ - http:
+ client: "http://localhost:${ai.tool.port}"
+ sendRequest:
+ POST:
+ path: "/mcp"
+ contentType: "application/json"
+ headers:
+ - name: "Accept"
+ value: "${mcp.accept}"
+ - name: "Mcp-Session-Id"
+ value: "${mcp.session}"
+ body:
+ data:
'{"jsonrpc":"2.0","id":6,"method":"tools/call","params":{"name":"pay_invoice","arguments":{}}}'
+ - http:
+ client: "http://localhost:${ai.tool.port}"
+ receiveResponse:
+ response:
+ status: 200
+ type: "plaintext"
+ body:
+ data:
'@matches(''(?s).*\Q"id":6,"result":{"content":[{"type":"text","text":"Access
denied: not authorized to call tool\E.*pay_invoice.*\Q"isError":true}}\E.*'')@'
+
+ # The tool of the tag admin is not offered
+ - http:
+ client: "http://localhost:${ai.tool.port}"
+ sendRequest:
+ POST:
+ path: "/mcp"
+ contentType: "application/json"
+ headers:
+ - name: "Accept"
+ value: "${mcp.accept}"
+ - name: "Mcp-Session-Id"
+ value: "${mcp.session}"
+ body:
+ data:
'{"jsonrpc":"2.0","id":7,"method":"tools/call","params":{"name":"delete_order","arguments":{}}}'
+ - http:
+ client: "http://localhost:${ai.tool.port}"
+ receiveResponse:
+ response:
+ status: 200
+ type: "plaintext"
+ body:
+ data:
'@contains(''{"jsonrpc":"2.0","id":7,"error":{"code":-32602,"message":"Unknown
tool: invalid_tool_name","data":"Tool not found: delete_order"}}'')@'