Skip to content

[Feature Request] Auto-reconnect SSE MCP servers after server-side restart #30224

@DanielPBak

Description

@DanielPBak

Problem

When an SSE-based MCP server restarts (e.g., due to a deployment or process restart), all active Claude Code sessions that were connected to it become stale. The tools remain listed but every call fails silently or errors out.

The only workaround is to manually go into /mcp and reconnect in each active Claude Code session. With multiple terminals open, this is disruptive and error-prone.

Expected behavior

Claude Code should detect when an SSE MCP server connection has been invalidated (connection drop, server restart, session expiry) and automatically attempt to re-initialize the connection. This aligns with the MCP spec's session management requirements:

When a client receives HTTP 404 in response to a request containing an Mcp-Session-Id, it MUST start a new session by sending a new InitializeRequest without a session ID attached.

Source: https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#session-management

Use case

We run an internal SSE MCP server (jarvis) that provides read-only gRPC access to production data. When the server restarts, every active Claude Code instance loses its connection. Engineers typically have 2-4 Claude Code sessions open, so each restart requires manually reconnecting in each one.

Possible approaches

  1. Auto-reconnect on tool call failure: When an MCP tool call fails with a connection/session error, automatically attempt to re-initialize the server connection before surfacing the error to the user.
  2. Heartbeat/keepalive: Periodically check SSE server health and reconnect proactively.
  3. Hook event: Expose an McpServerDisconnected hook event so users can build custom recovery logic.

Related issues

Environment

  • Platform: darwin
  • Claude Code version: latest
  • MCP transport: SSE

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:mcpduplicateThis issue or pull request already existsenhancementNew feature or requestplatform:macosIssue specifically occurs on macOSstaleIssue is inactive

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions