You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
StdioClientTransport.close() does not kill the process tree, leaving orphan processes #2023
When StdioClientTransport.close() is called, only the direct child process is signaled. If the MCP server was started via a wrapper command (e.g. npx, uvx, python -m), the wrapper's child processes (the actual server) become orphans and continue running indefinitely.
Root cause
The close() method uses processToClose.kill('SIGTERM') / processToClose.kill('SIGKILL'), which calls Node's ChildProcess.kill(). This only signals the direct child PID — not its descendants.
This affects all platforms:
macOS/Linux: No process group kill (process.kill(-pid, signal)) is used, so children of the direct process are not signaled.
Windows: ChildProcess.kill() does not kill the process tree at all. Only taskkill /T /F /PID <pid> can do that.
Reproduction
Start an MCP server via a wrapper (e.g. npx @some/mcp-server)
Call transport.close()
Observe that npx is killed but the underlying node process remains running
Possible solutions
Option A: Kill the process tree in close() — use pgrep -P (Unix) or taskkill /T /F (Windows) to enumerate and signal all descendants before/instead of ChildProcess.kill().
Option B: Spawn with detached: true and use process.kill(-pid, signal) to kill the process group. However, this has trade-offs: if the parent crashes, detached children become permanent orphans with no automatic cleanup.
Option C: Expose a hook or option so consumers can provide their own process cleanup logic.
Activity
fix: kill process tree on StdioClientTransport.close()
fix(server): exit when MCP parent process disappears (#217)
JoannaaKL commentedon Jun 23, 2026
Hey folks, I am happy to provide a fix for this issue, would it be welcome?
fix(client): kill process tree on StdioClientTransport.close() (model…
fix(client): kill process tree on StdioClientTransport.close() (model…