Croway opened a new pull request, #25306:
URL: https://github.com/apache/camel/pull/25306

   # CAMEL-24310: camel-mcp-server — bridge, McpServerEngine SPI and Vert.x 
engine
   
   Sub-tasks of 
[CAMEL-24308](https://issues.apache.org/jira/browse/CAMEL-24308): implements 
[CAMEL-24310](https://issues.apache.org/jira/browse/CAMEL-24310) and 
[CAMEL-24312](https://issues.apache.org/jira/browse/CAMEL-24312), plus the 
conformance-kit half of 
[CAMEL-24313](https://issues.apache.org/jira/browse/CAMEL-24313).
   
   > **Stacked on #25301** (CAMEL-24309 registry listener SPI) — the first 
commit here is that PR; review only the `CAMEL-24310` commit. Will rebase once 
#25301 merges.
   
   ## What this adds
   
   Two new modules under `components/camel-ai` exposing `ai-tool` routes 
(CAMEL-23382) as MCP tools over streamable HTTP. No route is needed for the 
server itself.
   
   ### `camel-mcp-server-api` — runtime-agnostic bridge + SPI
   - `McpServerEngine` SPI (`initialize`/`toolAdded`/`toolRemoved`), resolution 
mirroring `PlatformHttpEngine`: registry bean → FactoryFinder 
(`mcp-server-engine`) → fail with a clear message.
   - `McpServerBridge` (CamelContext service): selects registry tools by tag — 
**never** the untagged default pool (external MCP clients are untrusted 
senders); refuses flat-namespace name collisions with an ERROR log; subscribes 
to the `AiToolRegistry` listener **before** snapshotting (no race window); 
executes via `AiToolExecutor` on a managed pool with a bounded per-call 
timeout; maps `AiToolResult` to pre-sanitized results — raw route exception 
messages never reach the engine or the client. A timed-out call does not return 
its pooled exchange (the route may still be using it).
   - Enforcer rule bans the MCP SDK, Reactor, Vert.x and platform-http from 
compile/runtime scope — a leak would drag Reactor onto the Quarkus/Spring Boot 
classpath.
   - Ships the **engine conformance kit** as a test-jar: the same 
SDK-client-driven scenarios (tools/list tag filtering, calls, sanitization, 
timeout, list changes) will run against the Quarkus and Spring Boot engines in 
their repos, so behavior cannot drift.
   
   ### `camel-mcp-server` — Vert.x engine for Camel Main / JBang
   - Official MCP Java SDK (`mcp-core` 2.0.0, already used by camel-openai as 
client) with a custom `McpStreamableServerTransportProvider` — the SDK ships 
only servlet and stdio server transports. Ported from the SDK's 
`HttpServletStreamableServerTransportProvider` to the Vert.x model: request 
handling offloaded to the worker pool (unordered), all response writes on the 
connection's event-loop context, long-lived GET SSE channel without occupying a 
worker thread.
   - Protocol: POST answering `application/json` or `text/event-stream`, GET 
SSE with `Last-Event-ID` replay, `Mcp-Session-Id` sessions, DELETE termination; 
session semantics fully delegated to the SDK's `McpStreamableServerSession`. 
`tools/list_changed` emitted automatically on `addTool`/`removeTool`.
   - Registered on the platform HTTP router (`VertxPlatformHttpRouter`), so the 
endpoint serves on the main server port and sits behind its auth/CORS handlers.
   
   ### Module naming vs the sub-task sketch
   CAMEL-24310 sketched the engine as a *runtime dependency* of the bridge 
module — that is a Maven dependency cycle (the engine compiles against the 
SPI). Following the `camel-langchain4j-agent-api` precedent: plain Camel users 
add **`camel-mcp-server`** (the parent issue's UX promise holds), native-engine 
runtimes depend on **`camel-mcp-server-api`**. Noted on the JIRA.
   
   ## Out of scope (next PR)
   `camel.server.mcp-*` properties + camel-main autowiring (CAMEL-24311) and 
the final docs polish (CAMEL-24314). An initial `mcp-server.adoc` component 
page (usage, options, protocol, security section) is included here.
   
   ## Testing
   - `McpServerBridgeTest` (8 tests, mock engine): tag selection, default-pool 
exclusion, collision refusal, multi-tag remove-once, lifecycle add/remove, 
success/argument-error/sanitized-error/timeout mapping.
   - `McpServerBridgeResolutionTest`: clear startup failure when no engine is 
on the classpath.
   - `VertxMcpServerConformanceTest` (6 tests): the conformance kit against the 
real engine over a Vert.x platform HTTP server, driven by the official MCP SDK 
client (`McpClient.sync` + `HttpClientStreamableHttpTransport`) — initialize, 
tools/list filtering, tools/call success, missing required argument, sanitized 
execution error, timeout, tools list reflecting route stop/start.
   
   All 15 tests green; `formatter:format` + `impsort:sort` applied; generated 
catalog/spi files committed.
   
   ---
   _This PR was written by Claude Code on behalf of Federico Mariani (@Croway)._
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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]

Reply via email to