[Feature Request] Auto re-initialize MCP session on 'Server not initialized' error
Problem
When an MCP server restarts (e.g., during deployment), the MCP session ID can be preserved in a database, but the server's initialization state cannot be persisted. This means:
- Client reconnects with the old session ID ✓
- Server restores the session (same ID preserved) ✓
- But the new server instance requires re-initialization
- Client sends a tool call → Server returns
{"error":{"code":-32000,"message":"Bad Request: Server not initialized"}} - User must manually run
/mcpor/mcp reconnect <server>to re-initialize
Suggested Solution
When Claude Code's MCP client receives a -32000 error with message containing "not initialized", it should automatically:
- Send a new
initializerequest to the server - Complete the initialization handshake
- Retry the original request
This would make MCP connections resilient to server restarts without requiring user intervention.
Current Workaround
Users must manually run /mcp or /mcp reconnect <server_name> after every server restart.
Why This Can't Be Fixed Server-Side
The MCP protocol's initialization state (capabilities negotiation, client info exchange) is handled internally by the SDK and cannot be serialized/restored. The server can only preserve the session ID, not the initialization state.
Related Issues
- #605 - Added
/mcp reconnectcommand (manual solution) - #5670, #9268 - Duplicates requesting auto-reconnect
This feature request is specifically about automatic re-initialization when the server indicates it needs it, not just providing a manual command.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗