Orphaned MCP server processes not cleaned up when sessions end

Resolved 💬 6 comments Opened Feb 2, 2026 by johannesdb Closed Mar 10, 2026

Description

When Claude Code sessions end (either by closing VSCode, switching workspaces, or the extension crashing), MCP server child processes are not terminated. This leads to accumulation of orphaned processes that consume significant CPU and RAM over time.

Observed behavior

After a day of normal Claude Code usage:

  • 96 orphaned conport-mcp Python processes consuming ~74% CPU combined
  • 49 orphaned claude native binary processes

Each MCP server process uses ~1-2% CPU continuously even when idle.

Expected behavior

When a Claude Code session ends, all spawned child processes (MCP servers) should be terminated.

Environment

  • OS: macOS (Darwin 25.2.0, arm64)
  • Claude Code version: 2.1.29 (VSCode extension)
  • MCP server: ConPort (Python-based)

Suggested fixes

  1. Process groups: Spawn MCP servers in the same process group so they can be terminated together with the parent
  2. Signal handling: Ensure proper SIGTERM propagation to child processes on shutdown
  3. Watchdog: MCP servers could periodically check if their parent process is still alive
  4. Cleanup on startup: Detect and offer to kill orphaned processes from previous sessions

Workaround

Manual cleanup:

pkill -f "conport-mcp"

Reproduction

  1. Start Claude Code in VSCode
  2. Use features that spawn MCP servers (e.g., ConPort)
  3. Close VSCode window or switch workspace
  4. Check for orphaned processes: ps aux | grep -E "(conport-mcp|claude.*native-binary)"

View original on GitHub ↗

This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗