fix(mcp): align SDK and wire streamable server manually
All checks were successful
Build and publish Docker image / Build and push CPU image (push) Successful in 2m10s
Build and publish Docker image / Build and push GPU image (push) Successful in 3m2s

- align all io.modelcontextprotocol.sdk artifacts to 0.18.1 via
  dependencyManagement so Spring AI transitives no longer pull mcp 0.10.0
- exclude Spring AI's legacy MCP server/webmvc auto-config, which is binary-
  incompatible with the 0.18.1 streamable transport APIs
- build McpSyncServer directly against WebMvcStreamableServerTransportProvider
  and adapt Spring AI ToolCallbacks to MCP SyncToolSpecifications manually
- keep /mcp as the sole Streamable HTTP endpoint for both initialize/tool calls
  and optional SSE event streams
- update MCP transport documentation to match the new runtime

Validated locally with:
- POST /mcp initialize -> HTTP 200 + Mcp-Session-Id
- POST /mcp tools/list -> returns resolve-library-id + get-library-docs
This commit is contained in:
moze
2026-05-06 03:05:22 +02:00
parent 343a4ff3c3
commit e54e1dd33b
6 changed files with 128 additions and 20 deletions

View File

@@ -21,11 +21,14 @@ spring:
async:
request-timeout: 0 # MCP GET streams must not time out
# Spring AI MCP server — Streamable HTTP transport (MCP spec 2025-03-26).
# McpWebMvcServerAutoConfiguration (SSE transport) is excluded below;
# WebMvcStreamableServerTransportProvider is wired manually in McpConfig.
# Spring AI 1.0.0's MCP auto-config only knows the legacy SSE/stdIO transport interfaces,
# so both MCP auto-config classes are excluded below and the Streamable HTTP transport plus
# McpSyncServer are wired manually in McpConfig.
# Clients connect with type: http at POST /mcp.
autoconfigure:
exclude: org.springframework.ai.mcp.server.autoconfigure.McpWebMvcServerAutoConfiguration
exclude:
- org.springframework.ai.mcp.server.autoconfigure.McpWebMvcServerAutoConfiguration
- org.springframework.ai.mcp.server.autoconfigure.McpServerAutoConfiguration
ai:
mcp:
server: