spring-projects / spring-projects/spring-ai
streamable-http MCP client treats GET /mcp as SSE and fails when server returns JSON (Invalid SSE response)
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.9k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 6
Description
When using Spring AI MCP client with streamable-http, the client performs a GET request to the MCP base endpoint (/mcp) during initialization.
The current implementation always parses the GET /mcp response as SSE.
If the server returns a normal HTTP JSON response (which is valid for streamable-http servers), initialization fails with:
io.modelcontextprotocol.spec.McpTransportException: Invalid SSE response
This makes Spring AI MCP client incompatible with some valid MCP servers (e.g. ModelScope MCP servers), even though they work correctly with other MCP clients (VS Code Cline, Node-based clients).
Steps to Reproduce
spring:
ai:
mcp:
client:
streamable-http:
connections:
firecrawl-mcp-server:
url: https://mcp.api-inference.modelscope.net/
endpoint: <id>/mcp
Start the application and observe client initialization failure.
Actual Behavior
Spring AI sends:
GET https://.../<id>/mcp
Server responds with HTTP 200 JSON, e.g.:
{"info":"return 200 for GET /mcp."}
Client attempts to parse this as SSE and throws:
Invalid SSE response
Stack trace points to:
io.modelcontextprotocol.spec.McpTransportException: Invalid SSE response. Status code: 200 Line: {"info":"return 200 for GET /mcp."}
at io.modelcontextprotocol.client.transport.ResponseSubscribers$SseLineSubscriber.hookOnNext(ResponseSubscribers.java:185) ~[mcp-core-0.14.0.jar:0.14.0]
at io.modelcontextprotocol.client.transport.ResponseSubscribers$SseLineSubscriber.hookOnNext(ResponseSubscribers.java:72) ~[mcp-core-0.14.0.jar:0.14.0]
at reactor.core.publisher.BaseSubscriber.onNext(BaseSubscriber.java:160) ~[reactor-core-3.7.11.jar:3.7.11]
Expected Behavior
For streamable-http transport:
GET /mcpshould not be required to return SSE- Non-SSE HTTP responses (e.g. JSON) should be allowed
- Stream validation should occur during actual streaming requests, not during the initial GET probe
Environment
- Spring AI 1.1.0-M4
- mcp-core: 0.14.0
- Transport: streamable-http
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the streamable-http client initialization and its GET /mcp probe; trace how the response is handed to SSE parsing, including the ResponseSubscribers.SseLineSubscriber stack-trace entry point. The change is done when a valid non-SSE JSON response is accepted during the initial GET while actual streaming requests still validate their stream responses.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100