Skip to content

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

Description

@TomsTech

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).

Activity

  1. github-actions commented on Dec 24, 2025

    @github-actions

    Found 3 possible duplicate issues:

    1. [BUG] MCP servers not properly terminated when Claude Code exits, causing orphaned processes #1935
    2. [BUG] claude mcp list causes orphaned mcp server processes #11778
    3. [BUG] background tasks are not properly killed and cleared up natively on Windows (powershell) #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

  2. added
    duplicateThis issue or pull request already exists
    and removed
    bugSomething isn't working
    has reproHas detailed reproduction steps
    platform:windowsIssue specifically occurs on Windows
    on Dec 27, 2025
  3. github-actions commented on Dec 27, 2025

    @github-actions

    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

  4. github-actions commented on Jan 4, 2026

    @github-actions

    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.

  5. locked as resolved and limited conversation to collaborators on Jan 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions