claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

Windows: MCP server child processes not cleaned up on exit/crash

Open TomsTech opened this issue 4 weeks ago • 1 comments

Description

On Windows, MCP server processes spawned by Claude Code are not properly terminated when Claude Code exits or crashes. This leads to accumulation of orphaned Python/Node processes over time.

Environment

  • OS: Windows 11
  • Claude Code version: 2.0.76
  • MCP servers: Various (uvx-based Python servers, npx-based Node servers)

Steps to Reproduce

  1. Start Claude Code with MCP servers configured (e.g., sqlite, fetch, puppeteer)
  2. Use the session normally
  3. Exit Claude Code (or let it crash/timeout)
  4. Check running processes - MCP server processes remain running

Observed Behavior

After several Claude Code sessions, I found:

  • 85+ orphaned Python processes from uv/cache (uvx MCP servers)
  • 27+ orphaned PowerShell processes
  • Multiple duplicate instances of the same MCP server

These processes accumulate over days and cause:

  • High memory usage
  • Repeated popup windows (authentication dialogs, login prompts)
  • System slowdown

Expected Behavior

When Claude Code exits (gracefully or via crash), all spawned MCP server child processes should be terminated.

Suggested Fix

On Windows, use Job Objects to group child processes with the parent. When the parent process terminates (for any reason), Windows will automatically terminate all processes in the job.

Current Workaround

Added a Stop hook to clean up processes on graceful exit - but this only works for graceful exits, not crashes.

Additional Context

This appears to be Windows-specific. Unix systems handle child process cleanup differently (process groups, SIGHUP propagation).

TomsTech avatar Dec 24 '25 01:12 TomsTech

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/1935
  2. https://github.com/anthropics/claude-code/issues/11778
  3. https://github.com/anthropics/claude-code/issues/8865

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

github-actions[bot] avatar Dec 24 '25 01:12 github-actions[bot]

This issue has been automatically closed as a duplicate of #1935.

If this is incorrect, please re-open this issue or create a new one.

🤖 Generated with Claude Code

github-actions[bot] avatar Dec 27 '25 09:12 github-actions[bot]