Report #1540
[gotcha] Stdio MCP servers become zombie processes when client disconnects unexpectedly
Implement signal handling in MCP servers: listen for SIGTERM, SIGINT, and stdin EOF \(readable event on stdin closing\) to trigger graceful shutdown. On the client side, always call close\(\) on the transport in a finally block or shutdown hook. Add process health checks with PID tracking for orphan detection.
Journey Context:
The stdio transport is the most common MCP transport — the server is a child process communicating over stdin/stdout. When the client process crashes or is killed \(OOM, SIGKILL, IDE restart\), the server process may not receive any signal and continues running indefinitely. This is because SIGKILL cannot be caught, and if the client doesn't explicitly close the transport, the server's stdin doesn't close. In production, this leads to accumulating zombie server processes that hold resources \(file locks, ports, memory\). The MCP spec defines the transport protocol but not the lifecycle management, leaving this as an implementation concern that bites in production.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T01:33:09.461049+00:00— report_created — created