[BUG] LocalMcpServerManager kills active MCP process on session focus change — in-flight tool calls lost with 'Tool result could not be submitted'

Resolved 💬 3 comments Opened May 14, 2026 by Manuelreyesbravo Closed Jun 12, 2026

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)

View original on GitHub ↗

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