Add mcp-server module: order-lookup service exposed via @McpTool/@McpResource/@McpPrompt over Streamable HTTP

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FtpJvZfg4nvLvtzgJTDWpB
This commit is contained in:
Claude
2026-09-23 11:56:37 +00:00
parent c1fc41e0de
commit 9919da58a7
21 changed files with 704 additions and 0 deletions
@@ -0,0 +1,35 @@
# The 404 that shows up with no spring.ai.mcp.server.protocol set, and why
Captured manually against a standalone run of this module with application.yml's
`spring.ai.mcp.server.protocol: streamable` line removed -- everything else identical.
Reproduced with: `mvn -o spring-boot:run --server.port=18099 --debug`, then:
$ curl -X POST http://localhost:18099/mcp -H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}'
{"timestamp":"2026-09-23T11:44:01.196Z","status":404,"error":"Not Found","path":"/mcp"}
The real reason, from Boot's own --debug condition-evaluation report (trimmed to the one line
that matters):
McpServerStreamableHttpWebMvcAutoConfiguration:
Did not match:
- AllNestedConditions 1 matched 1 did not; NestedCondition on
McpServerAutoConfiguration.EnabledStreamableServerCondition.StreamableEnabledCondition
@ConditionalOnProperty (spring.ai.mcp.server.protocol=STREAMABLE) did not find
property 'protocol'; NestedCondition on
McpServerAutoConfiguration.EnabledStreamableServerCondition.McpServerEnabledCondition
@ConditionalOnProperty (spring.ai.mcp.server.enabled=true) matched
The jar's spring-configuration-metadata.json lists "streamable" as spring.ai.mcp.server.protocol's
default value -- but that default is only ever applied when something actually binds the
@ConfigurationProperties object (McpServerProperties). The @ConditionalOnProperty guarding
McpServerStreamableHttpWebMvcAutoConfiguration runs before any binding happens, checking the
Spring Environment directly for a literal "spring.ai.mcp.server.protocol" entry. No entry, no
match, no RouterFunction registered for /mcp -- the endpoint simply does not exist, and every
request to it 404s exactly like a request to a path nobody ever mapped, which is exactly what it
is. Setting spring.ai.mcp.server.protocol: streamable explicitly in application.yml fixes it, and
that same run then returns a normal 200 with a real MCP initialize response, e.g.:
{"jsonrpc":"2.0","id":1,"result":{"protocolVersion":"2025-06-18","capabilities":{"completions":{},"logging":{},"prompts":{"listChanged":true},"resources":{"subscribe":false,"listChanged":true},"tools":{"listChanged":true}},"serverInfo":{"name":"order-lookup-server","version":"1.0.0"}}}