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
Commit 63df3d8
Browse filesBrowse the repository at this point in the historyBrowse files
StdioClientTransport.close() called ChildProcess.kill(), which only signals
the direct child. Wrapper commands (npx/uvx/python -m/shells) fork the real
MCP server as a grandchild, so the server was left orphaned; on Windows kill()
does not terminate the tree at all.
Spawn the child detached on POSIX so it leads its own process group, and add
killProcessTree() so the existing SIGTERM -> 2s grace -> SIGKILL escalation
signals the whole tree: process.kill(-pid) for the group (falling back to a
pgrep -P descendant walk), and taskkill /T /F on Windows.
Escalation now also checks signalCode, so a server that exits on SIGTERM does
not trigger a redundant SIGKILL (and descendant walk) on the common path.
Closesmodelcontextprotocol#2023
Fix `StdioClientTransport.close()` leaving MCP server processes alive when the command is a wrapper (npx/uvx/python -m, shell scripts) that forks the real server as a grandchild — `ChildProcess.kill()` only signalled the direct child.
6
+
7
+
The child is now spawned in its own process group on POSIX, and the existing SIGTERM→2s grace→SIGKILL escalation in `close()` now signals the whole tree: `process.kill(-pid)` on POSIX (with a best-effort `pgrep -P` descendant-walk fallback), and `taskkill /T` (soft) escalating to `taskkill /T /F` on Windows. A server that exits on SIGTERM no longer triggers a redundant SIGKILL.
8
+
9
+
Note: spawning detached means the child no longer shares the parent's controlling terminal, so terminal SIGINT (Ctrl+C) is not auto-forwarded to it; the transport tears the tree down in `close()`.
0 commit comments