MCP servers using npx fail to connect in VS Code 1.112

Status Fixed / completed
Maintainer reply None cached
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

  1. Configure npx-based MCP servers (e.g. npx -y @modelcontextprotocol/server-github)
  2. Update to VS Code 1.112
  3. All npx-based servers show MCP error -32000: Connection closed
  4. 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.

View original on GitHub ↗

6 Comments

github-actions[bot] · 7 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/25044
  2. https://github.com/anthropics/claude-code/issues/5098
  3. https://github.com/anthropics/claude-code/issues/13457

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

KyuRish · 7 months ago

This is not a duplicate of the linked issues. Here's why:

  • #25044 (no TTY): My servers were working fine until the VS Code 1.112 update. TTY hasn't changed.
  • #5098 (Git Bash path rewriting /d:): My error is 'npx' is not recognized, not a path rewriting issue.
  • #13457 (subprocess PATH inheritance): Closer, but that issue was closed as fixed. This is a new regression.

New evidence

  1. Same MCP config works in Claude Desktop - identical ~/.claude.json config connects all npx servers fine in the Claude Desktop app. Only broken in VS Code extension.
  1. VS Code extension log confirms the cause (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
`
The config specifies
npx.cmd but the process spawns bare npx (without .cmd extension). On Windows, child_process.spawn() without shell: true cannot resolve .cmd` files.

  1. Tried workarounds that confirm the stripping behavior:
  • Config: "command": "npx.cmd" → spawns npx → fails
  • Config: "command": "C:/Program Files/nodejs/node.exe" → spawns node → fails
  • The extension appears to strip both the directory path and file extension from the command field before spawning.
  1. Python servers work because uvx.exe is a real .exe binary, and Python's Scripts directory is on the Windows system PATH. Even if stripped to uvx, it resolves.
  1. Timing: Broke immediately after VS Code 1.112 update. 1.112 introduced MCP server sandboxing and enable/disable features - the refactoring likely changed subprocess spawning behavior.

Environment

  • VS Code 1.112 (March 18, 2026)
  • Claude Code extension v2.1.78
  • Windows 11 (10.0.26200)
  • Node v22.16.0, npx 10.9.2
  • C:\Program Files\nodejs is on PATH in Git Bash but may not be inherited by extension host
KyuRish · 6 months ago

Root cause found - traced through extension source

Dug into the minified extension.js in anthropic.claude-code-2.1.79-win32-x64. The bug is in resolveShellPath() and how it interacts with MCP server spawning on Windows with Git Bash as default terminal.

The chain

1. resolveShellPath() runs bash -lic "printenv PATH" using Git Bash (vscode.env.shell):

resolveShellPath(z) {
  let V = r.env.shell;  // "C:\Program Files\Git\bin\bash.exe"
  let {stdout: K} = spawnSync(V, ["-lic", `printf '${U}'; command printenv PATH; printf '${U}'`]);
  if (v && v.includes(":")) return v;  // passes because Git Bash uses : separators
}

Returns Unix-format PATH: /c/Program Files/nodejs:/usr/bin:/mingw64/bin:...

2. $V() (env builder) replaces process.env.PATH with the Unix PATH:

function $V(z) {
  let j = {...process.env};
  if (z) j.PATH = z;  // Unix PATH replaces Windows PATH
  return j;
}

Called as: $V(resolveShellPath(this.output))

3. MCP servers get spawned via cross-spawn with shell: false and this Unix PATH:

this._process = crossSpawn(command, args, {
  env: {...wb6(), ...this._serverParams.env},  // wb6() copies PATH from process.env
  shell: false
});

4. cross-spawn tries to resolve npx against the PATH, but the PATH entries are /c/Program Files/nodejs (Unix) instead of C:\Program Files\nodejs (Windows). Resolution fails. cmd.exe error: 'npx' is not recognized.

Why Python servers work

uvx.exe / uv.exe are 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 resolveShellPath to 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, when process.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.environmentVariables in VS Code settings to override PATH back to Windows format:

"claudeCode.environmentVariables": [
  {"name": "PATH", "value": "C:\Program Files\nodejs;C:\Windows\system32;..."}
]

This runs after the Unix PATH replacement in the extension code and restores correct Windows PATH for MCP server spawning.

Environment

  • VS Code 1.112, Claude Code 2.1.79, Windows 11
  • Default terminal: Git Bash
  • Node v22.16.0
KyuRish · 6 months ago

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:

"claudeCode.environmentVariables": [
    {"name": "PATH", "value": "<your Windows PATH>"}
]

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.

KyuRish · 6 months ago

The developers recognised this regression and shipped a fix in v2.1.81:

[VSCode] Fixed Windows PATH inheritance for Bash tool when using Git Bash (regression in v2.1.78)

Confirmed working after update. Closing.

github-actions[bot] · 6 months ago

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.