davsclaus opened a new pull request, #3364:
URL: https://github.com/apache/camel-kamelets/pull/3364
A new source Kamelet, `ai-tool-source` (Preview), on the Camel `ai-tool`
component. It offers the steps after it as a tool that an AI agent can call.
With `camel-mcp-server`, any MCP client can call the tool. The `openai` and
`langchain4j-agent` components can call it through their `tags` option.
In a route (YAML): `from: kamelet:ai-tool-source` with steps, or followed by
`to: kamelet:<sink>`.
## Options
- `toolName` (required, pattern `^[A-Za-z0-9_-]{1,64}$`): the name the model
calls the tool by.
- `description` (required): what the tool does, written for the model.
- `tags` (required): the MCP server only offers tools whose tag is in
`camel.server.mcp-tags`. Requiring it means nothing is exposed by accident.
- `argSchema`: the JSON Schema of the arguments, inline or
`file:`/`classpath:`. Without it the tool takes no arguments.
- `title`, `readOnlyHint`, `destructiveHint`, `idempotentHint`,
`openWorldHint`: MCP hints.
- `allowedRoles`, `allRolesRequired`: the roles of a caller logged in with
OAuth.
`argumentsAsBody` is fixed to `true` in the template.
## Output
- The body is the arguments as JSON text, holding only the declared
arguments (`{}` for a tool without arguments).
- Each declared argument is also a header with its own name.
- The body at the end of the flow, as text, is the tool result. No header
goes back to the caller.
- If the flow leaves the body unchanged, the caller gets its own arguments
back.
## Design
- `camel:mcp-server` is not a dependency of the Kamelet. Serving over MCP is
the operator's choice, and the tool can also be called in-process by `openai`
or `langchain4j-agent`.
- Camel JBang adds `camel-mcp-server` by itself when
`camel.server.mcp-enabled=true` is in `application.properties` (verified).
- The description says how to serve it: `camel.server.enabled`,
`camel.server.mcp-enabled`, `camel.server.mcp-tags`, and
`http://<host>:<port>/mcp`.
- Security: MCP clients are untrusted senders, and the tag selection is the
boundary.
- Only declared arguments reach the flow, so an undeclared `CamelHttpUri`
argument is dropped (tested).
- Route errors come back only as `Tool execution failed`, and a timeout as
`Tool execution timed out`.
- Only the body goes back, never the headers (tested with a header set in
the flow).
- The description notes that the server binds to all interfaces with no
login, and points to OAuth and the Origin check.
- `spec.dataTypes.out` has empty headers and no `default`. Over MCP, the
flow gets no header of its own besides the arguments.
## Tests
`AiToolIT` (new, package `aitool`) runs one integration with the Kamelet and
`camel-mcp-server` over MCP streamable HTTP. It holds three tools: two tagged
`orders`, which are offered, and one tagged `admin`, which is not. The test
does the following:
- `initialize`, taking the `Mcp-Session-Id` header, then
`notifications/initialized` (202).
- `tools/list` lists `get_order_status` with its schema, title and
`readOnlyHint`, plus `pay_invoice`, and not `delete_order`.
- `tools/call` gives the flow `{"note":"urgent","orderId":"42"}` plus
`orderId` and `note` headers, with the undeclared `extra` and `CamelHttpUri`
dropped. The reply of the flow is the result.
- A call missing a required argument is refused before the flow runs.
- `allowedRoles` without OAuth refuses the call.
- Calling the `admin` tool gives "Tool not found".
Local results: `./mvnw -o clean install -DskipITs` passes. `AiToolIT`: 1
test, 1 passed (about 10 s). A mutation check
(`camel.server.mcp-tags=orders,admin`) makes the `tools/list` check fail as it
should.
Fixes #3362.
## Upgrade note
- New Kamelet `ai-tool-source` (Preview): offers a flow as a tool for AI
agents. Set `camel.server.mcp-enabled=true` and `camel.server.mcp-tags` to
serve it to MCP clients with `camel-mcp-server`.
_Claude Code on behalf of Claus Ibsen_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_016Y4dDmBDsSWV117kccuNf9
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]