Report #83408
[gotcha] Orphaned MCP server processes accumulate after client crashes or disconnects
Handle SIGTERM and SIGINT in every stdio MCP server to gracefully shut down. Implement a heartbeat/healthcheck—if the server detects stdin is closed, exit immediately. On the client side, always send the shutdown notification before disconnecting. Use process supervisors in production. Set a stdio idle timeout so servers self-terminate.
Journey Context:
The stdio transport runs the MCP server as a child process of the client. The MCP lifecycle defines a clean shutdown sequence \(shutdown notification → server exits\), but this only works in happy-path scenarios. If the client crashes, is force-killed, or loses its connection, the server process never receives a shutdown signal and becomes a zombie. In development with frequent restarts, dozens of orphaned servers can accumulate, leaking ports, file handles, and memory. The server has no built-in way to detect that its parent is gone unless you explicitly check stdin or implement heartbeats.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T22:35:23.047778+00:00— report_created — created