[BUG] Claude Code kills ALL Python processes system-wide at turn boundaries (Windows)

Resolved 💬 2 comments Opened Mar 10, 2026 by philyoast Closed Apr 7, 2026

Bug Description

Claude Code v2.1.71 on Windows kills all Python processes system-wide at every model turn boundary — including processes started from completely separate terminals that have no relationship to Claude Code.

Environment

  • Claude Code v2.1.71
  • Windows 11 Pro 10.0.26200
  • Python 3.13 (multiple paths tested)
  • .mcp.json with stdio-configured Python MCP servers

Reproduction Steps

  1. Configure a Python MCP server in .mcp.json using stdio transport:
{
  "cylentra-task-manager": {
    "command": "C:\path\to\venv\Scripts\python.exe",
    "args": ["-m", "my_mcp_server"]
  }
}
  1. In a completely separate PowerShell terminal (not spawned by Claude Code), start any Python HTTP server:
python -c "from http.server import HTTPServer, BaseHTTPRequestHandler; HTTPServer((\"127.0.0.1\", 8502), BaseHTTPRequestHandler).serve_forever()"
  1. In Claude Code, send any message and wait for the response to complete.
  1. Result: The Python process started in step 2 is killed with no error logged. The PowerShell terminal returns to the prompt.

Systematic Testing Performed

We systematically tested to identify the kill mechanism:

| Test | Executable | Result |
|------|-----------|--------|
| Venv python.exe (same as .mcp.json) | C:\venv\Scripts\python.exe | Killed at turn boundary |
| System python.exe (different path) | C:\AppData\Local\Python\python.exe | Killed at turn boundary |
| Venv pythonw.exe (different name) | C:\venv\Scripts\pythonw.exe | Killed at turn boundary |
| Node.js HTTP server | node | Survived turn boundary |

Key finding: The kill targets ALL Python processes regardless of:

  • Executable path (venv vs system Python)
  • Executable name (python.exe vs pythonw.exe)
  • Who spawned them (Claude Code child vs independent terminal)
  • Port (not in .mcp.json at all)

Node.js processes are NOT killed — a simple node -e "require(\"http\").createServer(...).listen(8502)" survived multiple turn boundaries with the same PID.

Impact

  • Cannot run persistent Python HTTP MCP servers locally — they get killed every turn
  • Affects ALL Python processes on the system — not just MCP-related ones
  • Data loss risk — any Python process doing work (data processing, model training, etc.) will be terminated without warning
  • Blocks the MCP Streamable HTTP transport pattern for Python servers on Windows

Expected Behavior

Claude Code should only manage the lifecycle of MCP server processes it spawned via .mcp.json stdio entries. It should NOT kill unrelated Python processes running on the system.

Workaround

Revert to stdio transport for Python MCP servers. The kill bug does not affect stdio-managed servers (Claude Code manages their lifecycle correctly). Node.js processes are also unaffected.

Related Issues

  • #1935 — MCP servers not properly terminated (opposite problem, same lifecycle area)
  • #22612 — Root cause analysis of disconnectMcpServer memoization bug; Windows orphan process data
  • #18405 — Orphaned processes from subagents crashing computer (Windows)
  • #31646 — Reverse-engineered kill sequence (SIGINT → 100ms → SIGTERM → 400ms → SIGKILL)

Additional Context

This appears to be a broad process cleanup mechanism that targets all python processes by name rather than tracking specific PIDs that Claude Code spawned. The fact that Node.js processes survive while all Python variants (python.exe, pythonw.exe, from any path) are killed suggests process-name-based targeting.

View original on GitHub ↗

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