Repository navigation
Commit 77273a0
committed
fix(client/streamableHttp): handle 404 by clearing session ID per MCP spec
Per MCP spec §Session Management (2025-03-26), when a client receives HTTP 404
in response to a request containing an Mcp-Session-Id, it MUST clear the session
ID. Previously, both send() (POST) and _startOrAuthSse() (GET) would throw
StreamableHTTPError without clearing _sessionId, permanently breaking the client
with stale session IDs.
This change:
- Adds SdkErrorCode.ClientHttpNotFound
- On 404, clears this._sessionId before throwing, so subsequent calls do not
keep failing with the same stale session ID
- Leaves full re-initialization to the caller (as InitializeRequest involves
capability negotiation owned by the Client layer)
Fixes modelcontextprotocol#1708.1 parent 984a27e commit 77273a0
2 files changed
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
578 | 578 | | |
579 | 579 | | |
580 | 580 | | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
581 | 592 | | |
582 | 593 | | |
583 | 594 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
0 commit comments