claude-code - 💡(How to fix) Fix [FEATURE] Allow hooks to trigger MCP server reconnection

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

Workflows that restart MCP servers mid-session — such as switching between environments, rotating credentials, or changing server configuration — currently require the user to remember and execute /mcp → Reconnect after every switch. This is error-prone (users forget and get confusing tool errors) and adds friction to what should be a single-action workflow.

Fix Action

Fix / Workaround

  • Document the manual step clearly: This is the current workaround. The hook outputs a message telling the user to run /mcp. Works but adds friction.
  • Auto-reconnect on connection failure: Claude Code could detect a broken MCP connection on the next tool call and automatically reconnect. This would help but is reactive rather than proactive, and the first tool call after a restart would still fail.

Code Example

{
  "systemMessage": "MCP server restarted with new config.",
  "hookSpecificOutput": {
    "hookEventName": "SessionStart",
    "reconnectMcpServers": ["snowflake"]
  }
}
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing requests and this feature hasn't been requested yet
  • This is a single feature request (not multiple features)

Problem Statement

SessionStart hooks can start/restart MCP servers and output system messages, but they cannot programmatically trigger MCP reconnection. After a hook restarts an MCP server (e.g., as part of an environment switch workflow), the user must manually run /mcp → Reconnect before tools become available again.

This creates a multi-step manual workflow where it could be seamless:

  1. A skill restarts an MCP server with new configuration
  2. The user runs /clear (triggering the SessionStart hook)
  3. The hook detects the restarted server
  4. The user must manually run /mcp → Reconnect ← this step should be automatable

Proposed Solution

Allow the SessionStart hook's JSON response to include a directive that triggers MCP reconnection for specified servers. For example:

{
  "systemMessage": "MCP server restarted with new config.",
  "hookSpecificOutput": {
    "hookEventName": "SessionStart",
    "reconnectMcpServers": ["snowflake"]
  }
}

Claude Code would process this by automatically re-initializing the MCP session for the named servers, the same way /mcp → Reconnect does today.

Alternative Solutions

  • Document the manual step clearly: This is the current workaround. The hook outputs a message telling the user to run /mcp. Works but adds friction.
  • Auto-reconnect on connection failure: Claude Code could detect a broken MCP connection on the next tool call and automatically reconnect. This would help but is reactive rather than proactive, and the first tool call after a restart would still fail.

Priority

Low - Nice to have

Feature Category

MCP server integration

Use Case Example

Workflows that restart MCP servers mid-session — such as switching between environments, rotating credentials, or changing server configuration — currently require the user to remember and execute /mcp → Reconnect after every switch. This is error-prone (users forget and get confusing tool errors) and adds friction to what should be a single-action workflow.

Additional Context

No response

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING