Report #95923
[gotcha] MCP server process becomes orphaned when the client crashes without sending shutdown notification
When using stdio transport, always wire SIGTERM/SIGINT handlers on the client to send a shutdown notification before exiting. As a fallback, set a reasonable OS-level timeout \(e.g., spawn with a detached flag and kill after N seconds of stdin closure\). On the server side, detect stdin EOF and exit gracefully.
Journey Context:
The MCP lifecycle includes a shutdown sequence: client sends a shutdown notification, server responds, then both close. But if the client crashes, is killed with SIGKILL, or loses its network connection, no shutdown is sent. With stdio transport, the server process inherits the client's stdin pipe—when the client dies, stdin closes \(EOF\). Well-written servers detect this and exit. But many don't: they might be waiting on a timer, a subprocess, or an event loop that doesn't monitor stdin. The server process becomes an orphan, holding ports, file locks, or other resources. On restart, the client spawns a new server, and now you have two. This compounds: every client crash leaks a server process. The fix is defense-in-depth: client-side cleanup on exit, server-side stdin monitoring, and process management \(PID files, health checks\) for long-running servers.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T19:35:21.900460+00:00— report_created — created