Add 'claude mcp reconnect' CLI command
Problem
When developing locally with HTTP-based MCP servers, the server restarts frequently (e.g., pnpm dev after code changes). When the server process dies and restarts, the MCP SDK's SSE connection drops and the server is marked as "failed" in Claude Code. The only way to recover is /mcp → Reconnect manually.
This happens dozens of times per day during active development.
Requested Feature
A CLI command to programmatically reconnect an MCP server:
claude mcp reconnect <server-name>
This would enable a post-build hook in settings.json that auto-reconnects after server restarts:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "claude mcp reconnect my-local-server"
}
]
}
]
}
}
Workarounds Tried
- Manual
/mcp→ Reconnect (works but tedious) - Wrapper scripts with reminders (doesn't actually reconnect)
- The SDK could also auto-reconnect with backoff (like native
EventSource), but that's a bigger change
Context
HTTP-based MCP servers behind a proxy (staging/prod) don't have this issue — the proxy routes to healthy backends transparently. It's specifically local dev where the SDK connects directly to the server process.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗