MCP: Auto-reconnect to remote servers after connection drop
Problem
When a remote MCP server restarts (e.g., Kubernetes pod restart during deployment), the HTTP/SSE connection drops and Claude Code shows "Authentication required. Reconnect this MCP server in Settings." The user must manually reconnect every time.
This is particularly painful in GitOps workflows where CI/CD pipelines frequently redeploy services — each deployment requires a manual reconnect even though nothing about the authentication has changed.
Current Behavior
- MCP server pod restarts (deployment, scaling, crash recovery)
- HTTP/SSE connection drops
- Claude Code marks the server as disconnected
- User must manually go to Settings and click "Reconnect"
- Reconnection succeeds immediately (credentials and sessions are still valid)
Expected Behavior
Claude Code should automatically retry the connection with exponential backoff when a remote MCP server becomes unreachable. The MCP Streamable HTTP transport already supports session resumption via the Mcp-Session-Id header, so the server-side infrastructure exists for seamless reconnection.
Proposed Solution
- Detect connection drops on HTTP/SSE transport
- Retry with backoff (e.g., 1s, 2s, 4s, 8s... up to 60s)
- Reuse the existing
Mcp-Session-Idfor session resumption if the server supports it - After N failed retries, fall back to current behavior (prompt user to reconnect)
- Optional: configurable retry policy in MCP server settings (
autoReconnect: true,maxRetries: 10, etc.)
Environment
- Claude Code CLI
- Remote MCP server over Streamable HTTP transport with distributed sessions (PostgreSQL-backed)
- Kubernetes single-replica deployment
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗