[FEATURE] Share MCP server processes across concurrent Claude Code sessions
Problem
When running multiple Claude Code sessions concurrently (common workflow: development + code review + investigation), every MCP server is spawned independently per session. This causes massive memory consumption and frequently triggers OOM kills on macOS.
Measured Data (macOS, 24 GB RAM, 4 concurrent sessions)
| MCP Server | Processes per session | × 4 sessions | Memory per set |
|------------|----------------------|---------------|----------------|
| nx-mcp | 2 (npm + node) | 8 | ~400 MB |
| nx mcp (local) | 2 (npm + node) | 8 | ~380 MB |
| angular-cli | 3 (npm + ng + node) | 12 | ~580 MB |
| backlog | 2 (npm + node) | 8 | ~360 MB |
| serena | 2 (uv + python) | 6 | ~105 MB |
| Total | | ~42 processes | ~1.9 GB |
Add Claude CLI processes (~1.7 GB) and Nx daemons spawned by nx-mcp (~0.8 GB), and Claude-related processes alone consume ~4.5 GB out of 24 GB.
This regularly results in zsh: killed claude (macOS OOM killer).
Expected Behavior
MCP servers that are configured at the project or user level should be shared as a single process (or process group) across all concurrent Claude Code sessions in the same workspace, rather than spawning duplicate instances.
For example, 4 sessions with 6 MCP servers should spawn 6 MCP processes total, not 42.
Proposed Solutions (in order of preference)
- Shared MCP daemon: A single MCP server process per workspace that multiplexes requests from multiple Claude Code sessions
- Lazy initialization: Only start MCP servers when their tools are actually invoked (related: #7336), combined with aggressive shutdown when idle
- Session-level MCP profiles: Allow users to configure which MCP servers are enabled per session without manual
/mcptoggling each time
Current Workarounds
- Manually toggling MCP servers on/off per session via
/mcp(tedious, error-prone) - Limiting concurrent sessions (defeats the purpose of parallel workflows)
- Periodically running
npx nx daemon --stopto clean up spawned daemons
Environment
- macOS (Darwin 25.3.0, Apple Silicon)
- RAM: 24 GB
- Claude Code: 2.1.59
- Node.js: v24.13.0
- MCP servers: nx-mcp, angular-cli, backlog, serena, context7
Related Issues
- #20412 — MCP servers auto-injected causing OOM crashes
- #4953 — Process grows to 120+ GB and gets OOM killed
- #18011 — V8 heap exhaustion with multiple sessions
- #15211 — MCP child processes not cleaned up on exit
- #3036 — Multiple MCP servers consume context window rapidly
- #7336 — Lazy loading for MCP servers (95% reduction possible)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗