Skip to content

fix(mcp): handle Streamable HTTP MCP responses with SSE framing#779

Open
Mohl wants to merge 1 commit intoRightNow-AI:mainfrom
Mohl:fix/streamable-http-mcp
Open

fix(mcp): handle Streamable HTTP MCP responses with SSE framing#779
Mohl wants to merge 1 commit intoRightNow-AI:mainfrom
Mohl:fix/streamable-http-mcp

Conversation

@Mohl
Copy link

@Mohl Mohl commented Mar 21, 2026

Problem

MCP servers using Streamable HTTP transport (e.g., Hindsight) wrap JSON-RPC responses in SSE framing:

event: message
data: {"jsonrpc":"2.0","id":1,"result":{...}}

The SSE transport handler expected raw JSON bodies, causing Invalid MCP SSE JSON-RPC response: expected value at line 1 column 1 errors when connecting to these servers.

Fix

Extract the JSON payload from data: lines before deserializing. Falls back to raw body parsing for servers that return plain JSON, so existing SSE servers are unaffected.

Testing

  • Tested against Hindsight MCP server (v0.4.19) — 26 tools discovered and operational
  • Existing plain-JSON SSE servers continue to work (no behavioral change for non-SSE-framed responses)

Context

Streamable HTTP is the newer MCP transport defined in the MCP spec (2025-03-26). This change adds forward-compatible support without requiring a new transport type.

MCP servers using Streamable HTTP (e.g., Hindsight) wrap JSON-RPC
responses in SSE framing (event: message\ndata: {...}\n\n). The SSE
transport handler expected raw JSON, causing 'Invalid MCP SSE JSON-RPC
response' errors when connecting to these servers.

Extract the JSON payload from SSE data: lines before deserializing.
Falls back to raw body parsing for servers that return plain JSON.

Fixes connection to MCP servers implementing the Streamable HTTP
transport (MCP spec 2025-03-26).
@Mohl
Copy link
Author

Mohl commented Mar 21, 2026

Note: This change was necessary to get openfang to work with hindsight mcp server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant