stdio MCP servers should auto-reconnect like HTTP/SSE transports
Problem
When a stdio-based MCP server (e.g. Playwright MCP) disconnects, Claude Code does not attempt automatic reconnection. Users must manually run /mcp to reconnect. This happens frequently — roughly every 10-20 minutes on macOS — making stdio MCP servers unreliable for longer sessions.
HTTP/SSE/WebSocket transports have exponential backoff reconnection (5 attempts, 1s-16s), but stdio is explicitly excluded from this logic.
Root Cause
In the minified cli.js (v2.1.92), line 6078:
if(y!=="stdio"&&y!=="sdk")
This condition skips automatic reconnection for stdio transport. Reconnecting a stdio server is just re-spawning the child process — functionally identical to what /mcp does manually.
Proposed Fix
Change:
if(y!=="stdio"&&y!=="sdk")
To:
if(y!=="sdk")
This is a one-line change that gives stdio servers the same auto-reconnect behavior that HTTP/SSE/WebSocket servers already have.
Environment
- Claude Code 2.1.92 (Bun standalone binary, macOS arm64)
- MCP server:
@playwright/mcp@0.0.70(stdio transport) - macOS 15.4 (Darwin 25.4.0)
Related
- #43177
- #37482 (stdin pipe loss on macOS)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗