Write/Edit tool hangs 2–4 min (ep_poll, no network/CPU) when a stdio MCP server is connected
Summary: Write/Edit tool calls intermittently hang for 2–4 minutes when an MCP (stdio) server is connected. The file is written to disk instantly, but the tool result returns [Tool result missing due to internal error] and the turn stalls until the user interrupts. A no-MCP session does not hang.
Version: Claude Code 2.1.177 (also seen on 2.1.170). Linux (Bazzite / Fedora atomic), Node-based CLI, running inside tmux.
Symptom:
- A
WriteorEdittool call hangs 2–4 min. The target file lands on disk immediately (verified via mtime). - The tool result comes back as
[Tool result missing due to internal error]. - The status line shows
Recalling/writing memory…/ a long-running spinner during the stall. - Force-stopping the turn recovers; the next turn proceeds. Intermittent.
Process state captured during a live ~200s hang (sampled every 15s on the claude PID):
stat=Ssl cpu=4.4% wchan=ep_poll :443 sockets=NONE hot-thread=ep_poll
i.e. the process is parked idle in the Node event loop (ep_poll) for the entire hang — no API/network socket open, ~0 CPU, not in uninterruptible IO, not a futex deadlock. It is awaiting something internal that never arrives, then the tool result fails internally.
Ruled out by that capture: slow API/network (no socket), CPU/compute (flat ~4%), disk/fsync (stat=Ssl, vmstat IO-wait 0%), context-size/cache-miss (would show API socket + CPU), local futex deadlock, low memory/disk (23 GiB free, disk 28%).
Suspected cause: the only child of the claude process is an MCP server (stdio). ep_poll is consistent with the event loop blocked on a pipe fd, i.e. the harness awaiting an MCP-server response/ack on tool completion. The mcp logs show the harness attempting channel notifications (Channel notifications skipped: server did not declare claude/channel capability).
Control test: a session launched with --strict-mcp-config --mcp-config '{}' (no MCP servers; confirmed no MCP child) ran 15 sequential Write tool calls with zero hangs, completing in <60s. The MCP-connected session hangs on single writes. (Bug is intermittent, so this is directional, not absolute.)
Workaround: writing files via a Bash heredoc (cat > file) does not hang; only the Write/Edit tools do — consistent with the stall being in the tool-completion → MCP path, not file IO.
Repro (approx): in a session with a stdio MCP server connected, issue repeated Write/Edit tool calls; intermittently one hangs ~2–4 min with the process idle in ep_poll and the tool result returning an internal error.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗