Orphaned MCP server processes persist after session exit
Resolved 💬 3 comments Opened Feb 22, 2026 by andrew-transcend Closed Feb 26, 2026
Description
MCP server child processes are not cleaned up when a Claude Code session ends (crash, Ctrl+C, network disconnect, or normal exit). Each session spawns multiple MCP server processes, and over time these accumulate as zombies.
Reproduction
- Start a Claude Code session (with plugins that use MCP servers — e.g., chrome-devtools-mcp, context7, slack)
- Exit the session (any method — clean exit, Ctrl+C, crash)
- Run
ps aux | grep -E '(chrome-devtools-mcp|context7-mcp|mcp-server-slack)' | grep -v grep - Observe that MCP processes from the ended session are still running
After several sessions, dozens of orphan processes accumulate:
# Example: 6 orphaned sessions worth of MCP processes still running
s004 10:00AM context7, chrome-devtools x2, slack
s003 5:24AM context7, chrome-devtools x2
s002 5:03AM context7, chrome-devtools x2
s001 Thu 4AM context7, chrome-devtools x2, slack
s000 Thu 6AM context7, chrome-devtools x2, slack
Each session spawns ~8-10 processes due to the process tree: npm exec → node mcp-server → watchdog (for chrome-devtools-mcp).
Expected behavior
MCP server processes should be terminated when their parent Claude Code session ends, regardless of how the session exits.
Suggested approaches
- Use process groups (
setpgid) so all child processes can be killed together - Register cleanup handlers for SIGTERM, SIGINT, SIGHUP, and uncaught exceptions
- Implement an orphan reaper on session start that detects and cleans up stale MCP processes from previous sessions
Environment
- macOS Darwin (Apple Silicon)
- Claude Code (standalone installer)
- Plugins: chrome-devtools-mcp, context7, mcp-server-slack, granola
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗