StreamableHTTPClientTransport should handle 404 and 406 gracefully for GET SSE stream
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- typescript
- Domain
- api, networking
Research direction
Start in packages/client/src/client/streamableHttp.ts, specifically StreamableHTTPClientTransport._startOrAuthSse(), and trace how the GET response status is handled during initialization. Verify the behavior with a POST-only MCP server or a focused client test if available. Done means 404 and 406, like 405, allow POST-based communication to continue without a fatal error.
Written by the indexing model from the issue text.
Description
Problem
The StreamableHTTPClientTransport._startOrAuthSse() method sends a GET request to open an SSE stream during initialization. Per the MCP spec, the server MAY respond with 405 Method Not Allowed if it doesn't support SSE streams, and the client correctly handles this.
However, many MCP servers return 404 Not Found or 406 Not Acceptable instead of 405 for this GET request:
- 404: Server doesn't have a GET handler for the MCP endpoint (only POST)
- 406: Server rejects
Accept: text/event-streamheader (e.g., requires bothapplication/jsonandtext/event-stream)
Both cases mean the same thing: the server does not offer an SSE stream at the GET endpoint. But the client treats them as fatal errors, preventing the connection even though POST-based communication would work fine.
Current Behavior
// packages/client/src/client/streamableHttp.ts, _startOrAuthSse()
if (response.status === 405) {
return; // Only 405 is handled gracefully
}
throw new SdkError(...); // 404 and 406 throw, killing the connection
This causes errors like:
StreamableHTTPError: Streamable HTTP error: Failed to open SSE stream: Not Found
Affected Clients
This impacts any client consuming the SDK, including:
- Gemini CLI (
google-gemini/gemini-cli) — #5268, #2787 - MCP Inspector — #1150
- LibreChat and other MCP consumers
Proposed Fix
Treat 404 and 406 the same as 405 — all indicate the server does not offer an SSE stream at the GET endpoint:
// 404: Server has no GET handler (only POST)
// 405: Server explicitly doesn't allow GET
// 406: Server rejects the Accept header for GET
if (response.status === 404 || response.status === 405 || response.status === 406) {
return;
}
The client will then proceed with POST-based communication, which works correctly for these servers.
Reproduction
- Set up an MCP server that only supports POST (no GET SSE stream)
- Connect using
StreamableHTTPClientTransport - The GET request returns 404 → client throws and disconnects
- POST would have worked fine
Environment
@modelcontextprotocol/sdk: latest- Discovered while debugging Gemini CLI v0.32.1 connecting to a remote HTTP MCP server (ArmorCode)
- Dominant language
- TypeScript
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 3d 11h
- Merged PRs (30d)
- 32
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing 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.
More from modelcontextprotocol/typescript-sdk
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
modelcontextprotocol/typescript-sdk#2920 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
modelcontextprotocol/typescript-sdk#2919 · 1 comment ·
Maintainers usually reply within 1 day
-
v1 v2
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
modelcontextprotocol/typescript-sdk#2916 · 1 comment ·
Maintainers usually reply within 1 day
-
v1 v2
Difficulty 1/5 Under an hour Newbie friendliness 90/100
modelcontextprotocol/typescript-sdk#2867 · 1 comment ·
Maintainers usually reply within 1 day
-
v1 v2
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
modelcontextprotocol/typescript-sdk#2854 · 1 comment ·
Maintainers usually reply within 1 day
All issues in modelcontextprotocol/typescript-sdk
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Doist/todoist-cli#576 ·
Maintainers usually reply within 1 day
-
feature
Difficulty 1/5 Under an hour Newbie friendliness 72/100
vercel-labs/skills#2370 ·
Maintainers usually reply within 1 day
-
🐛 Bug supabase/cli
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
CopilotKit/aimock#491 ·
Maintainers usually reply within 1 day