fix(mcp): handle Streamable HTTP MCP responses with SSE framing#779
Open
Mohl wants to merge 1 commit intoRightNow-AI:mainfrom
Open
fix(mcp): handle Streamable HTTP MCP responses with SSE framing#779Mohl wants to merge 1 commit intoRightNow-AI:mainfrom
Mohl wants to merge 1 commit intoRightNow-AI:mainfrom
Conversation
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).
Author
|
Note: This change was necessary to get openfang to work with hindsight mcp server. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
MCP servers using Streamable HTTP transport (e.g., Hindsight) wrap JSON-RPC responses in SSE framing:
The SSE transport handler expected raw JSON bodies, causing
Invalid MCP SSE JSON-RPC response: expected value at line 1 column 1errors 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
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.