claude-code - 💡(How to fix) Fix [BUG] LocalMcpServerManager kills active MCP process on session focus change — in-flight tool calls lost with 'Tool result could not be submitted' [2 comments, 2 participants]

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…
GitHub stats
anthropics/claude-code#58898Fetched 2026-05-14 03:36:38
View on GitHub
Comments
2
Participants
2
Timeline
3
Reactions
0
Timeline (top)
commented ×2labeled ×1

When multiple Claude Desktop sessions are open and the user switches focus between them, LocalMcpServerManager closes and restarts the shared MCP server process. If a tool call is in flight at that moment, the result pipe is broken — the tool call is permanently lost and the UI shows three cascading errors with no recovery path.


Error Message

2026-05-13 21:22:24 [warn] [LocalMcpServerManager] mimir disconnected

  • The 3 error messages give no indication that the cause is an MCP process restart
  • At minimum: return the broken tool result as an error to the session instead of dropping it silently
  • #57134 — preview_screenshot silent hang (same pattern: error known internally, never surfaced to session)

Root Cause

Root cause — confirmed from ~/.config/Claude/logs/main.log

Code Example

Your previous message wasn't sent. You can try again.
We couldn't connect to Claude. Please check your network connection and try again.
Tool result could not be submitted. The request may have expired or the connection was interrupted. Refresh the page to continue.

---

2026-05-13 21:22:13 [info] [CCD] LocalSessions.setFocusedSession: sessionId=local_e9ea4dac-...
2026-05-13 21:22:24 [info] [LocalMcpServerManager] Closing mimir
2026-05-13 21:22:24 [warn] [LocalMcpServerManager] mimir disconnected
2026-05-13 21:22:24 [info] [LocalMcpServerManager] Connecting to mimir
2026-05-13 21:22:24 [info] [LocalMcpServerManager] Connected to mimir (118 tools)
RAW_BUFFERClick to expand / collapse

Summary

When multiple Claude Desktop sessions are open and the user switches focus between them, LocalMcpServerManager closes and restarts the shared MCP server process. If a tool call is in flight at that moment, the result pipe is broken — the tool call is permanently lost and the UI shows three cascading errors with no recovery path.


Errors shown to user (in sequence)

Your previous message wasn't sent. You can try again.
We couldn't connect to Claude. Please check your network connection and try again.
Tool result could not be submitted. The request may have expired or the connection was interrupted. Refresh the page to continue.

No retry, no automatic recovery. The session must be restarted from scratch.


Root cause — confirmed from ~/.config/Claude/logs/main.log

Every time session focus changes, LocalMcpServerManager tears down the existing MCP process and spawns a new one:

2026-05-13 21:22:13 [info] [CCD] LocalSessions.setFocusedSession: sessionId=local_e9ea4dac-...
2026-05-13 21:22:24 [info] [LocalMcpServerManager] Closing mimir
2026-05-13 21:22:24 [warn] [LocalMcpServerManager] mimir disconnected
2026-05-13 21:22:24 [info] [LocalMcpServerManager] Connecting to mimir
2026-05-13 21:22:24 [info] [LocalMcpServerManager] Connected to mimir (118 tools)

This happened 4 times in 14 minutes during a normal multi-session workflow:

  • 21:08:51 — Close → disconnect → reconnect
  • 21:11:29 — Close → disconnect → reconnect
  • 21:13:08 — Close → disconnect → reconnect
  • 21:22:24 — Close → disconnect → reconnect

When a tool call is active during the close, the anyio memory stream throws ClosedResourceError (visible in MCP server stderr), the pipe is broken, and Claude Desktop surfaces the 3 errors above.


Contributing factor — single-instance design

LocalMcpServerManager maintains one MCP process shared across all sessions. Every focus switch triggers a full teardown+respawn cycle. With 2+ sessions active, focus switches are frequent and the kill window is wide.


Impact

  • Any multi-session workflow where the user switches windows during a tool call hits this
  • The session cannot recover — context is lost, user must restart
  • The 3 error messages give no indication that the cause is an MCP process restart

Proposed fix

  • Don't teardown the MCP process on focus change — keep it alive as long as any session needs it
  • Or: drain in-flight tool calls before closing (graceful shutdown with a short timeout)
  • At minimum: return the broken tool result as an error to the session instead of dropping it silently

Environment

  • Claude Desktop (Linux, Fedora 43)
  • Claude Code 2.1.64
  • 3–5 concurrent sessions

Related

  • #57134 — preview_screenshot silent hang (same pattern: error known internally, never surfaced to session)
  • #53922 — concurrent session rate-limiting (parallel session context)

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

claude-code - 💡(How to fix) Fix [BUG] LocalMcpServerManager kills active MCP process on session focus change — in-flight tool calls lost with 'Tool result could not be submitted' [2 comments, 2 participants]