[BUG] MCP server processes not cleaned up on exit (process accumulation)

Resolved 💬 3 comments Opened Feb 10, 2026 by madrus Closed Mar 30, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

NOTE: This bug report has been generated by asking Claude Code if I should report this bug.

Bug Description

Claude Code does not properly terminate MCP server child processes
when exiting or restarting, leading to orphaned processes that
accumulate over time.

## Impact

  • Multiple orphaned MCP server processes (I had 25+ instances)
  • Memory leaks (~40-70MB per process)
  • MCP servers showing as "failed" due to resource conflicts
  • System slowdown

## Environment

  • Claude Code Version: 2.1.38
  • OS: macOS (Darwin 25.3.0)
  • MCP Server affected: @zilliz/claude-context-mcp (but likely

affects all MCP servers)

## Workaround
Manually kill orphaned processes: pkill -f "claude-context-mcp"

This is a process lifecycle management bug that the Claude Code
team should fix to prevent resource leaks.

What Should Happen?

## Expected Behavior
All MCP server child processes should be terminated when:

  • Claude Code exits
  • A conversation/session ends
  • An MCP server is restarted

Error Messages/Logs

No erros in the log but failure to initialize the MCP server:

❯ /mcp                                                              
────────────────────────────────────────────────────────────────────
 Manage MCP servers                                                 
 6 servers                                                          

   Project    (/Users/madrus/dev/biz/toernooien/tournado-test/.mcp. 
   MCPs      json (file does not exist))                            
 ❯ claude-context · ✘ failed                                        
   context7 · ✔ connected                                           
   filesystem · ✔ connected
   sequential-thinking · ✔ connected
   serena · ✔ connected
   tavily · ✔ connected

 ※ Error logs shown inline with --debug
 https://code.claude.com/docs/en/mcp for help

Steps to Reproduce

## Steps to Reproduce

  1. Configure an MCP server (e.g., claude-context)
  2. Start Claude Code multiple times over several days
  3. Check running processes: ps aux | grep claude-context-mcp
  4. Observe multiple orphaned node processes

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.38

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Warp

Additional Information

_No response_

View original on GitHub ↗

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