From 8ad6ad05eacd8faf60122e851350dc62c72fc890 Mon Sep 17 00:00:00 2001 From: Nanook Date: Mon, 27 Apr 2026 19:02:42 +0000 Subject: [PATCH] fix: handle 404 and 406 gracefully in SSE stream initialization 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 #1635 --- packages/client/src/client/streamableHttp.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/client/src/client/streamableHttp.ts b/packages/client/src/client/streamableHttp.ts index cd643c96d..3fa6f6d90 100644 --- a/packages/client/src/client/streamableHttp.ts +++ b/packages/client/src/client/streamableHttp.ts @@ -282,9 +282,11 @@ export class StreamableHTTPClientTransport implements Transport { await response.text?.().catch(() => {}); - // 405 indicates that the server does not offer an SSE stream at GET endpoint - // This is an expected case that should not trigger an error - if (response.status === 405) { + // 404: Server has no GET handler for this endpoint (POST-only) + // 405: Server explicitly does not allow GET + // 406: Server rejects Accept header for GET + // All indicate the server does not offer an SSE stream at the GET endpoint + if (response.status === 404 || response.status === 405 || response.status === 406) { return; }