Bug description MCP has endpoints of "/sse" and "mcp/message". After /sse is called, MCP server is waiting second call of "mcp/message" from client. However when you scaled up APIs then there will be load balancer(which means each request might go to different instance of APIs). Instance 1 is waiting second call but instance 2 is receiving second call which will fail connection. Is there way to share state across the multiple instances for connections?

Environment Spring AI 1.0.0

Expected behavior MCP connection should support on shared state so that it will support multiple instances of MCP server after scaled up.

Comment From: YunKuiLu

You can look forward to MCP with Streamable-HTTP transport mode. The MCP Java SDK version 0.11.0 now supports Streamable-HTTP transport, and Spring AI will catch up soon.

If you still want to use the SSE transport mode, you may need to modify the gateway, using something like HASH load balancing to route requests with the same session-id to the same server instance.

Comment From: junan-trustarc

You can look forward to MCP with Streamable-HTTP transport mode. The MCP Java SDK version 0.11.0 now supports Streamable-HTTP transport, and Spring AI will catch up soon.

If you still want to use the SSE transport mode, you may need to modify the gateway, using something like HASH load balancing to route requests with the same session-id to the same server instance.

Thanks for reply, do you know when spring ai will support Streamable http approximately? is there any in-progress PR or? We are trying to avoid sticky session so..

Comment From: YunKuiLu

Since the MCP Java SDK 0.11.0 was just released 4 hours ago, the Spring AI maintainers probably haven't started working on it yet. Also, since Spring AI just released version 1.0.1, it might not release the next stable version very soon.

Before that, you also can try to use the MCP Java SDK 0.11.0 and refer to the McpServerAutoConfiguration and McpXXXServerAutoConfiguration classes in spring-ai-autoconfigure-mcp-server to quickly build a Streamable-HTTP mcp server.

Comment From: Damore

@YunKuiLu I believe, even with the Streamable Http, the server can return a text/event-stream, which will be a SSE, where the server may have an initialization phase and may assign a session ID at this time, by including it in an Mcp-Session-Id header on the HTTP. This means, the problem with session distribution still exists.

Session Management