Skip to content

fix: handle 404 and 406 gracefully in SSE stream initialization#1969

Open
nanookclaw wants to merge 1 commit intomodelcontextprotocol:mainfrom
nanookclaw:fix/handle-404-406-sse-stream
Open

fix: handle 404 and 406 gracefully in SSE stream initialization#1969
nanookclaw wants to merge 1 commit intomodelcontextprotocol:mainfrom
nanookclaw:fix/handle-404-406-sse-stream

Conversation

@nanookclaw
Copy link
Copy Markdown

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.ts line 285: response.status === 405response.status === 404 || response.status === 405 || response.status === 406

Impact

Affects Gemini CLI (#5268, #2787), MCP Inspector (#1150), LibreChat, and any client consuming this SDK against servers that only support POST.

Closes #1635

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
@nanookclaw nanookclaw requested a review from a team as a code owner April 27, 2026 19:03
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 27, 2026

⚠️ No Changeset found

Latest commit: 8ad6ad0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 27, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/@modelcontextprotocol/client@1969

@modelcontextprotocol/server

npm i https://pkg.pr.new/@modelcontextprotocol/server@1969

@modelcontextprotocol/express

npm i https://pkg.pr.new/@modelcontextprotocol/express@1969

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/@modelcontextprotocol/fastify@1969

@modelcontextprotocol/hono

npm i https://pkg.pr.new/@modelcontextprotocol/hono@1969

@modelcontextprotocol/node

npm i https://pkg.pr.new/@modelcontextprotocol/node@1969

commit: 8ad6ad0

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.

StreamableHTTPClientTransport should handle 404 and 406 gracefully for GET SSE stream

1 participant