[BUG] VS Code extension spawns duplicate MCP servers (still present in v2.1.71)

Resolved 💬 2 comments Opened Mar 8, 2026 by jayeshm33-bit Closed Apr 5, 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?

The VS Code extension spawns duplicate instances of every MCP server defined in .mcp.json. The Extension Host reads .mcp.json and starts MCP servers, then the Claude CLI binary it spawns also reads .mcp.json and starts its own copies. Result: 2× every MCP server, every time VS Code connects.

This was reported in #15969 but autoclosed without a fix.

Process tree proof (from ps output):

| MCP process | Parent PID | Parent process |
|---|---|---|
| story_rag_mcp.py (PID 3740) | 3604 | Claude CLI binary (claude --output-format stream-json ...) |
| story_rag_mcp.py (PID 3911) | 3145 | VS Code Extension Host |

Both parent processes independently read the same .mcp.json and each spawn their own set of servers. This doubles memory usage and causes CPU thrashing on startup, especially with heavier MCP servers (Python processes loading ML models, connecting to vector DBs, etc.).

What Should Happen?

Only one instance of each MCP server should be started. The extension and CLI should coordinate so that MCP servers are spawned once, not by both layers independently.

Error Messages/Logs

$ ps aux --sort=-%cpu | head -6
USER       PID %CPU %MEM  ...  COMMAND
jayesh    3911 43.6  2.8  ...  ./.venv/bin/python ./tools/story_rag_mcp.py
jayesh    3740 40.3  2.7  ...  ./.venv/bin/python ./tools/story_rag_mcp.py
jayesh    4265 16.9  0.4  ...  ./.venv/bin/python ./tools/knowledge_graph_mcp.py
jayesh    2073 15.1  0.4  ...  ./.venv/bin/python ./tools/knowledge_graph_mcp.py

$ ps -o ppid,pid,cmd -p 3740,3911
   PPID     PID CMD
   3604    3740 ./.venv/bin/python ./tools/story_rag_mcp.py   # parent = Claude CLI
   3145    3911 ./.venv/bin/python ./tools/story_rag_mcp.py   # parent = Extension Host

Steps to Reproduce

  1. Define MCP servers in .mcp.json at project root
  2. Open the project in VS Code with the Claude Code extension
  3. Start a Claude Code session
  4. Check running processes — each MCP server has two instances with different parent PIDs

Claude Model

Opus

Is this a regression?

No — same behavior was reported in #15969 (v2.0.76), still present in v2.1.71.

Last Working Version

_No response_

Claude Code Version

2.1.71

Platform

Anthropic API

Operating System

WSL2 (Linux 6.6.87.2-microsoft-standard-WSL2)

Terminal/Shell

VS Code integrated terminal (bash)

Additional Information

  • Previous report: #15969 (autoclosed without fix)
  • .mcp.json config has 3 servers (sequential-thinking, story-rag, knowledge-graph)
  • All 3 get duplicated — 6 total processes instead of 3
  • sequential-thinking (npm-based) ends up with 3 instances
  • Workaround: manually pkill duplicates after startup, but they return on every VS Code reconnect

View original on GitHub ↗

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