StreamableHTTPClientTransport should handle 404 and 406 gracefully for GET SSE stream
Maintainer antworten meist innerhalb von 1 Tag
@nanookclaw arbeitet bereits daran.
Seit 27.4.2026.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 76/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Ruhig
- Tech-Stack
- typescript
- Bereich
- api, networking
Rechercherichtung
Beginne in packages/client/src/client/streamableHttp.ts, genauer in StreamableHTTPClientTransport._startOrAuthSse(), und verfolge, wie der GET-Antwortstatus während der Initialisierung behandelt wird. Überprüfe das Verhalten mit einem POST-only MCP-Server oder, falls verfügbar, einem gezielten Client-Test. Als erledigt gilt die Aufgabe, wenn 404 und 406 wie 405 die auf POST basierende Kommunikation ohne einen fatalen Fehler fortsetzen lassen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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)
- Vorherrschende Sprache
- TypeScript
- Sterne
- 13.7k
- Forks
- 2.3k
- Ø Merge
- 1 T. 6 Std.
- Gemergte PRs (30 T.)
- 53
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus modelcontextprotocol/typescript-sdk
-
The `maxToolInputElements` refusal lacks the `Input validation error:` prefix that the schema refusal carriesEvtl. vergeben @barry166 hat das vor 2 Tagen übernommen. Offenv1 v2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
modelcontextprotocol/typescript-sdk#3111 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
server: registeredResource.update and registeredResourceTemplate.update desync title and metadata.title when updating metadata aloneEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offenv1 v2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
modelcontextprotocol/typescript-sdk#3103 · 5 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
[v1.x] Protocol.request keeps its abort listener after the request resolved, so a later abort sends notifications/cancelled for an answered request (1.30.0)Evtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offenv1
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
modelcontextprotocol/typescript-sdk#3090 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
[v2] e2e `protocol:timeout:max-total` is flaky over SSE: fake timers advance before the request reaches the serverEvtl. vergeben @Singmin hat das vor 11 Tagen übernommen. Offenv1 v2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
modelcontextprotocol/typescript-sdk#3045 ·
Maintainer antworten meist innerhalb von 1 Tag
-
[v1.x] Backport #2654: `notifications/cancelled` with `requestId: 0` is ignored, so the first server→client request cannot be cancelled (still in 1.32.1)Evtl. vergeben @CloudCorpRecords hat das vor 12 Tagen übernommen. Offenv1
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 77/100
modelcontextprotocol/typescript-sdk#3043 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in modelcontextprotocol/typescript-sdk
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
CopilotKit/openmuse#215 ·
Maintainer antworten meist innerhalb von 3 Tagen
-
b:minor bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
software-mansion/argent#1698 ·
Maintainer antworten meist innerhalb von 1 Tag
-
e2e-failure ready-to-code
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
redhat-developer/rhdh-plugin-export-overlays#4624 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag