[Feature Request] Auto re-initialize MCP session on 'Server not initialized' error

Resolved 💬 2 comments Opened Feb 1, 2026 by fiddur Closed Feb 2, 2026

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:

  1. Client reconnects with the old session ID ✓
  2. Server restores the session (same ID preserved) ✓
  3. But the new server instance requires re-initialization
  4. Client sends a tool call → Server returns {"error":{"code":-32000,"message":"Bad Request: Server not initialized"}}
  5. User must manually run /mcp or /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:

  1. Send a new initialize request to the server
  2. Complete the initialization handshake
  3. 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 reconnect command (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.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗