spring-projects / spring-projects/spring-ai

streamable-http MCP client treats GET /mcp as SSE and fails when server returns JSON (Invalid SSE response)

Open
#5,239 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage
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 /mcp should 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.