Skip to content

The agent that grows with you

fix(mcp): correct inverted liveness check in _stdio_children_dead

deadczarvc2663117f7263
diff --git a/tools/mcp_tool.py b/tools/mcp_tool.py
index 658024e78b8..8bc9b4ac21d 100644
--- a/tools/mcp_tool.py
+++ b/tools/mcp_tool.py
@@ -6165,6 +6165,20 @@ def _make_tool_handler(server_name: str, tool_name: str, tool_timeout: float):
and isinstance(_stdio_dead_result := _stdio_dead(), bool)
and _stdio_dead_result
):
+ # Dead stdio children with a stale session object: the
+ # transport failed WITHOUT clearing session, so the
+ # line-6077 reconnect path never fires. Signal the
+ # server task to rebuild the transport (respawn the
+ # subprocess) in the background and return a clean
+ # reconnecting error; the next call lands on the fresh
+ # session. The breaker resets once it initializes.
+ _bump_server_error(server_name)
+ if _signal_reconnect(server):
+ return tool_error(
+ f"MCP server '{server_name}' stdio subprocess is "
+ f"dead and reconnect was requested. Do NOT retry "
+ f"immediately — give it a few seconds to respawn."
+ )
raise TimeoutError(
f"MCP stdio subprocess for '{server_name}' has "
f"exited; failing the call fast instead of "