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
claude -p leaves orphaned MCP child processes after exit #42881
When claude -p (non-interactive/programmatic mode) finishes execution, the CLI node.exe process exits but all MCP server child processes remain alive as orphans. They are never cleaned up.
Reproduction
# Count node.exe processes before
powershell -Command "(Get-Process node -EA Silent).Count"# Run a simple prompt with MCP config
claude -p "respond with OK" --mcp-config mcp-config.json --strict-mcp-config
# Count after — orphaned MCP processes remain
powershell -Command "(Get-Process node -EA Silent).Count"
The delta shows MCP servers (node.exe, python.exe) that were spawned by the CLI but never terminated.
Impact
In automated setups using Task Scheduler / cron with claude -p, each execution leaves 2-5 orphaned MCP processes (~80 MB each). With 4-6 scheduled runs per day, this accumulates to 10-30 zombie processes and ~1-2 GB of wasted RAM daily.
Environment
Windows 11 Pro
Claude Code 2.1.91
MCPs configured via --mcp-config with --strict-mcp-config
Expected behavior
When claude -p exits, it should terminate all MCP child processes it spawned (e.g., via process tree kill or Job Object on Windows, process group kill on Linux/macOS).
Current workaround
A scheduled PowerShell script (mcp-health-check.ps1) runs every 30 minutes: finds all active Claude CLI processes, walks their descendant trees, identifies MCP-pattern processes not descended from any living CLI, and kills them.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.
Activity
github-actions commentedon Apr 3, 2026
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
github-actions commentedon Apr 6, 2026
This issue has been automatically closed as a duplicate of #40927.
If this is incorrect, please re-open this issue or create a new one.
🤖 Generated with Claude Code
github-actions commentedon Apr 14, 2026
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.