Auto-reconnect MCP streamable-HTTP servers on `Session not found`
Summary
When an MCP server using streamable HTTP transport evicts a session
(idle timeout, restart, deploy), the client keeps using its stale
session ID and every tool call fails with:
Streamable HTTP error: Error POSTing to endpoint:
{"error":{"message":"Session not found","code":-32600},...}
/mcp reports the server as "Connected" because that status reflects
the last successful handshake, not live session validity. Users must
manually reconnect via /mcp to recover.
Proposed behavior
On receiving JSON-RPC error code -32600 with message "Session not found"
(or equivalent session-eviction signal), Claude Code should transparently
re-establish the session and retry the failed call once, rather than
surfacing the error to the user.
Repro
- Connect to any streamable-HTTP MCP server (e.g. Fastmail).
- Leave the session idle long enough for the server to evict it
(or wait for a server-side restart).
- Invoke any tool from that server.
- Observe
Session not founderror;/mcpstill shows "Connected". - Manually
/mcp→ reconnect → tool works again.
Environment
Claude Code (CLI), darwin.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗