Skip to content

CAMEL-27145: camel-mcp-server-starter - serve the Camel routes on the Spring AI stateless MCP server - #2112

Merged
Croway merged 1 commit into
apache:mainfrom
Croway:CAMEL-27145-mcp-stateless
Nov 18, 2026
Merged

Croway merged 1 commit into
apache:mainfrom
Croway:CAMEL-27145-mcp-stateless

Conversation

@Croway

@Croway Croway commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

CAMEL-27145: the MCP server starter now serves the Camel ai-tool, ai-resource and ai-prompt routes when Spring AI runs its stateless MCP server.

Problem

With spring.ai.mcp.server.protocol=STATELESS, Spring AI auto-configures an McpStatelessSyncServer instead of an McpSyncServer. CamelMcpServerAutoConfiguration was @ConditionalOnBean(McpSyncServer.class), so the starter silently registered nothing.

Change

  • SpringAiMcpServerEngine publishes into either Spring AI server through a small internal adapter. Handlers receive the MCP transport context, so the caller identity reaches the route as before.
  • CamelMcpServerAutoConfiguration activates on either server bean (AnyNestedCondition), and runs after Spring AI's stateless auto-configuration too.
  • CamelMcpServerStatelessTransportAutoConfiguration: the counterpart of CamelMcpServerTransportAutoConfiguration for STATELESS. It installs Camel's Origin validation and caller-context extraction on Spring AI's WebMvcStatelessServerTransport; an application-provided transport takes precedence.
  • The "transport not active" warning now accepts STREAMABLE or STATELESS.
  • Docs: "Serving without sessions" in the starter usage page (regenerated docs page included).

Without a session, every request is served on its own: restarts and several instances without session affinity no longer end the client's session. Such clients receive no notifications (they see changed lists at their next list request), and a GET on the endpoint is answered with 405 by Spring AI.

MCP protocol version 2026-07-28 needs Spring AI 2.1.0 (spring.ai.mcp.server.protocol=MODERN): CAMEL-27174.

Tests

SpringBootMcpServerStatelessTest: the MCP SDK client lists and calls tools, the Spring Security caller reaches the route, initialize returns no Mcp-Session-Id, GET is answered 405, and Origin is validated. The starter's 55 tests are green locally.

Related: apache/camel#30343 (Camel Main / JBang side of CAMEL-27145).

Claude Code on behalf of Croway

… Spring AI stateless MCP server

With spring.ai.mcp.server.protocol=STATELESS, Spring AI auto-configures an
McpStatelessSyncServer instead of an McpSyncServer, and the starter registered
nothing. The engine now publishes into either server, and Camel's Origin
validation and caller-context extraction are installed on the stateless WebMVC
transport too. Each request is served without a session, so restarts and several
instances without session affinity no longer end the client's session.
@Croway
Croway requested review from gzurowski and oscerd November 18, 2026 13:25
@Croway
Croway merged commit 2029739 into apache:main Nov 18, 2026
4 checks passed
@Croway
Croway deleted the CAMEL-27145-mcp-stateless branch November 18, 2026 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant