Skip to content

MCP servers should auto-reconnect when disconnected mid-session #36308

Description

@quantamixsol

Problem

MCP servers configured in .mcp.json can disconnect during a session due to:

  • Idle timeout — the child process exits after no activity
  • Crash on bad config — e.g. a backend failing on every call causes the process to exit
  • OS process management — VS Code / the OS may kill background processes during memory pressure
  • Unhandled exceptions — a single bad tool call can crash the entire MCP server process

Currently there's no way to reconnect without restarting the entire Claude Code session. This means losing all conversation context.

Observed behavior

  • MCP tools appear in the tool list at session start, then silently stop working mid-session
  • Tool calls return connection errors with no recovery path
  • The user has no visibility into MCP server health status
  • Restarting the session is the only workaround, losing all conversation context

Expected behavior

MCP servers should be resilient to transient disconnections and recoverable without session restart.

Proposed solution

  1. Auto-reconnect on next tool call attempt — if an MCP server is disconnected when a tool call is made, automatically restart the process and retry the call
  2. /mcp restart command — allow manual reconnection of MCP servers without restarting the session
  3. Keep-alive pings — periodic health checks to detect disconnection early, before the user hits a failed tool call
  4. Surface MCP connection status in the UI — show which MCP servers are connected/disconnected (e.g. in /mcp output or a status indicator)

Environment

  • Claude Code in VS Code extension
  • Windows 11
  • MCP server: custom Python server (graq mcp serve) running as stdio child process

Impact

This is particularly disruptive for long sessions where MCP tools are integral to the workflow (e.g. knowledge graph reasoning, code analysis). Losing MCP connectivity mid-session forces a full restart, which means losing conversation context and re-establishing all prior work.


🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions