Skip to content

Commit 8ad6ad0

Browse files
committed
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
1 parent 42cb6b2 commit 8ad6ad0

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

packages/client/src/client/streamableHttp.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,11 @@ export class StreamableHTTPClientTransport implements Transport {
282282

283283
await response.text?.().catch(() => {});
284284

285-
// 405 indicates that the server does not offer an SSE stream at GET endpoint
286-
// This is an expected case that should not trigger an error
287-
if (response.status === 405) {
285+
// 404: Server has no GET handler for this endpoint (POST-only)
286+
// 405: Server explicitly does not allow GET
287+
// 406: Server rejects Accept header for GET
288+
// All indicate the server does not offer an SSE stream at the GET endpoint
289+
if (response.status === 404 || response.status === 405 || response.status === 406) {
288290
return;
289291
}
290292

0 commit comments

Comments
 (0)