[BUG] VS Code Extension: STDIO MCP server is not terminated
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?
VS Code Extension: Stdio MCP Server not terminated with new session
Version info
- Claude Version: 2.1.220
- I am using Claude Code VS Code Extension: Version 2.1.220
Problem Description
We configured an MCP server to run via stdio (Session A). When a new session (Session B) is started, a new MCP server instance is launched, which is the expected behavior. However, the MCP server process from the previous session is not terminated when the new session is opened.
This causes an issue because our MCP server establishes a connection to a backend that only supports a single active connection. Since the original MCP server process remains running and keeps the backend connection open, the MCP server started for Session B cannot connect to the backend.
Current workaround: Manually terminate the existing MCP server process using Task Manager before opening a new session.
What Should Happen?
When a new VS Code session is started, the previous session should gracefully terminate its connections to all MCP servers running over stdio. This ensures that any resources or backend connections held by the previous session are released before the new session starts.
Error Messages/Logs
Steps to Reproduce
- Configure an existing MCP server to run via stdio (see attached server implementation server.py).
- Start the VS Code extension and connect to the MCP server via stdio.
- Open a new session and connect to the MCP server via stdio again.
- Open the MCP server log file. You will see that the server has been started twice, but the first instance was never terminated.
- Close VS Code. At this point, both MCP server processes are terminated.
Claude Model
_No response_
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.1.220
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
Other
Additional Information
_No response_