MCP servers using npx fail to connect in VS Code 1.112
Status Fixed / completed
Maintainer reply None cached
Workaround ✓ Mentioned in thread ↓
Activity 6 comments · opened Mar 18, 2026 · closed Mar 22, 2026
Description
After updating to VS Code 1.112, all npx-based MCP servers fail to connect with error -32000: Connection closed. Python/uv-based MCP servers continue to work fine.
Environment
- VS Code: 1.112 (March 18, 2026)
- OS: Windows 11
- npx: 10.9.2 (on PATH, works from integrated terminal)
Reproduction
- Configure npx-based MCP servers (e.g.
npx -y @modelcontextprotocol/server-github) - Update to VS Code 1.112
- All npx-based servers show
MCP error -32000: Connection closed - Reconnect, reload window, and full restart all fail to fix it
Diagnosis
- Failing: All npx-based MCP servers (server-github, playwright, context7, etc.)
- Working: All Python/uv-based MCP servers
- Running the same npx commands from the integrated terminal works perfectly - servers start and respond to JSON-RPC initialize requests
- This worked on VS Code 1.111 with identical configuration
Likely cause
VS Code 1.112 introduced MCP server sandboxing and enable/disable features. While sandboxing is documented as macOS/Linux only, the surrounding refactoring may have changed how the extension spawns stdio subprocesses on Windows - possibly not inheriting the full PATH or shell environment that npx needs.
Workaround
None found so far.
6 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
This is not a duplicate of the linked issues. Here's why:
/d:): My error is'npx' is not recognized, not a path rewriting issue.New evidence
~/.claude.jsonconfig connects all npx servers fine in the Claude Desktop app. Only broken in VS Code extension.Claude VSCode.log):``
`[ERROR] "MCP server "playwright" Server stderr: 'npx' is not recognized as an internal or external command"
[DEBUG] MCP server "playwright": Connection failed after 142ms: MCP error -32000: Connection closed
npx.cmdThe config specifies
but the process spawns barenpx(without.cmdextension). On Windows,child_process.spawn()withoutshell: truecannot resolve.cmd` files."command": "npx.cmd"→ spawnsnpx→ fails"command": "C:/Program Files/nodejs/node.exe"→ spawnsnode→ failscommandfield before spawning.uvx.exeis a real.exebinary, and Python'sScriptsdirectory is on the Windows system PATH. Even if stripped touvx, it resolves.Environment
C:\Program Files\nodejsis on PATH in Git Bash but may not be inherited by extension hostRoot cause found - traced through extension source
Dug into the minified
extension.jsinanthropic.claude-code-2.1.79-win32-x64. The bug is inresolveShellPath()and how it interacts with MCP server spawning on Windows with Git Bash as default terminal.The chain
1.
resolveShellPath()runsbash -lic "printenv PATH"using Git Bash (vscode.env.shell):Returns Unix-format PATH:
/c/Program Files/nodejs:/usr/bin:/mingw64/bin:...2.
$V()(env builder) replacesprocess.env.PATHwith the Unix PATH:Called as:
$V(resolveShellPath(this.output))3. MCP servers get spawned via
cross-spawnwithshell: falseand this Unix PATH:4.
cross-spawntries to resolvenpxagainst the PATH, but the PATH entries are/c/Program Files/nodejs(Unix) instead ofC:\Program Files\nodejs(Windows). Resolution fails.cmd.exeerror:'npx' is not recognized.Why Python servers work
uvx.exe/uv.exeare specified with absolute Windows paths in the config (C:/Users/.../Scripts/uvx.exe), so they bypass PATH resolution entirely.The introducing change
v2.1.78 changelog: "Fixed Bash tool not finding Homebrew and other PATH-dependent binaries when VS Code is launched from Dock/Spotlight"
This fix added/changed
resolveShellPathto resolve PATH from the login shell. Works correctly on macOS (zsh returns Unix paths, macOS expects Unix paths). Breaks on Windows when Git Bash is the default terminal (returns Unix paths, but Windows expects Windows paths).Suggested fix
In
resolveShellPath, whenprocess.platform === 'win32'and the resolved PATH contains Unix-style entries (forward slashes,/c/prefixes), convert them to Windows format before returning. Or skip shell PATH resolution entirely on Windows when the shell is Git Bash/MSYS2.Workaround
Set
claudeCode.environmentVariablesin VS Code settings to override PATH back to Windows format:This runs after the Unix PATH replacement in the extension code and restores correct Windows PATH for MCP server spawning.
Environment
Workaround confirmed working. All npx-based MCP servers now connect successfully after applying the PATH override. Tested with servers including @anthropic/server-github, @playwright/mcp, and mcp-dashboards.
Fix
Add to your VS Code
settings.json:To get your Windows PATH, run
echo %PATH%in cmd.exe and paste the result as the value.This overrides the Unix-format PATH that
resolveShellPath()injects, restoring correct Windows PATH for MCP server spawning.The developers recognised this regression and shipped a fix in v2.1.81:
Confirmed working after update. Closing.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.