fix: handle 404 and 406 gracefully in SSE stream initialization#1969
Open
nanookclaw wants to merge 1 commit intomodelcontextprotocol:mainfrom
Open
fix: handle 404 and 406 gracefully in SSE stream initialization#1969nanookclaw wants to merge 1 commit intomodelcontextprotocol:mainfrom
nanookclaw wants to merge 1 commit intomodelcontextprotocol:mainfrom
Conversation
Widen the response status check in StreamableHTTPClientTransport._startOrAuthSse() from 405-only to include 404 and 406. Servers that only support POST-based communication (no GET SSE stream) commonly return 404 (no handler) or 406 (Accept header rejected) instead of the spec-defined 405. All three statuses indicate the server does not offer an SSE stream at the GET endpoint. Fixes modelcontextprotocol#1635
|
@modelcontextprotocol/client
@modelcontextprotocol/server
@modelcontextprotocol/express
@modelcontextprotocol/fastify
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
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
StreamableHTTPClientTransport._startOrAuthSse()only handles HTTP 405 as a graceful exit from the GET SSE stream attempt. Many MCP servers return 404 (no GET handler) or 406 (Accept header rejected) instead, causing the client to throw and preventing POST-based communication that would otherwise work.Fix
Widen the status check in
_startOrAuthSse()to treat 404, 405, and 406 identically — all three indicate the server does not offer an SSE stream at the GET endpoint.Change:
packages/client/src/client/streamableHttp.tsline 285:response.status === 405→response.status === 404 || response.status === 405 || response.status === 406Impact
Affects Gemini CLI (#5268, #2787), MCP Inspector (#1150), LibreChat, and any client consuming this SDK against servers that only support POST.
Closes #1635