[BUG] Claude Code kills ALL Python processes system-wide at turn boundaries (Windows)
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.jsonwith stdio-configured Python MCP servers
Reproduction Steps
- Configure a Python MCP server in
.mcp.jsonusing stdio transport:
{
"cylentra-task-manager": {
"command": "C:\path\to\venv\Scripts\python.exe",
"args": ["-m", "my_mcp_server"]
}
}
- 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()"
- In Claude Code, send any message and wait for the response to complete.
- 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
disconnectMcpServermemoization 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.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗