MCP stdio Leaks: Why Your Agent's Tool Servers Hang at Shutdown, Die on a Bad Filename and Leave Ghost Tools

A stdio MCP server that never exits is not a mystery: the Python SDK’s writer task can be blocked in a pipe write that only the reader can unblock, so cancelling it waits forever. In MCP Python SDK 2.2.0 on Linux, this probe reproduced that hang and three related lifecycle defects — an unencodable string that kills the connection with no JSON-RPC error, a rejected ClientSessionGroup registration that leaves a second server child alive and unreachable, and a disconnected session whose old tool name survives in group.tools. All four have a host-side workaround you can enforce today, and the probe below counts exactly what your host leaks. ...

October 30, 2026 · 8 min · baeseokjae