Croway opened a new pull request, #30801:
URL: https://github.com/apache/camel/pull/30801
## Summary
Follow-up to the MCP parity review for CAMEL-26360, done while reviewing the
Quarkus engine (apache/camel-quarkus#9509) and the Spring Boot engine. This PR
has three fixes to the Camel Main reference engine and the shared bridge. All
the code involved is unreleased (4.24.0).
1. **Resource and prompt routes receive the caller identity.** On an
authenticated request, `ai-tool` routes got `CamelMcpSecurityPrincipal`,
`CamelAiToolSecurityPrincipalName`/`Roles` and the `CamelMcpOAuth*` properties.
`ai-resource` routes (fixed and `uriTemplate`) and `ai-prompt` routes got
nothing, so a resource such as `crm://customers/{id}` could not check who is
asking.
- `McpResourceReadHandler`, `McpResourceTemplateReadHandler` and
`McpPromptHandler` get default overloads taking `McpToolCallContext` (`@since
4.24`). They delegate to the existing methods, so the Spring Boot and Quarkus
engines keep working until they pass a context.
- `McpServerBridge` sets the identity on resource, template and prompt
exchanges with the same code as for tools.
- The Vert.x engine passes the transport context on the session,
stateless and 2026-07-28 paths. stdio has no caller.
2. **A tool whose schema is not valid JSON Schema 2020-12 is refused the
same way in every protocol era.**
- Before:
- in `dual` the tool was hidden, with only a generic `AiToolRegistry`
WARN;
- in `modern` it was served;
- when the route started before the bridge, the CamelContext failed to
start.
- Now the Vert.x engine checks the input and output schemas with the
SDK's validator before adding the tool anywhere, and throws
`McpServerRefusedException`. stdio checks the input schema. Upgrade-guide entry
added.
3. **Percent-encoded dot segments no longer match a `uriTemplate`
variable.** The check refused `.` and `..` but accepted `%2e%2e`, `.%2e` or
`..%2F..%2Fetc%2Fpasswd`, and the route received the value raw.
`AiResourceUriTemplate.match()` now refuses a value that, once percent-decoded,
is or contains a dot segment between `/` or `\`. Values that match are still
passed raw.
## Tests
- `McpServerBridgeCallerIdentityTest` and `McpServerMainCallerIdentityTest`.
A basic-auth caller is visible on resources, templates and prompts over the
legacy session, legacy stateless and 2026-07-28 protocols. An anonymous request
sets nothing.
- `VertxMcpServerInvalidToolSchemaTest` covers legacy, dual, dual +
stateless and modern, with the route started before and after the server. Also
`StdioMcpServerEngineTest`.
- New `AiResourceUriTemplateTest` cases, and a resource conformance test
checking that the route is not called.
- `camel-ai-tool` 212, `camel-ai-prompt` 15, `camel-ai-resource` 58,
`camel-mcp-server-api` 139, `camel-mcp-server` 188 tests, 0 failures.
## Not in this PR
- A URI that the SDK matcher accepts but Camel's template matcher refuses,
including the encoded dot segments above, still returns `-32603` instead of
resource-not-found. That is already the case on `main`, and fixing it needs a
not-found result in the handler SPI.
- The Spring Boot starter and the Quarkus extension still call the resource
and prompt methods without a context. They can pass the caller context in a
follow-up.
- Expect a small conflict with #30764 in `McpServerBridge` and the docs.
_Claude Code on behalf of Federico Mariani_
--
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]