MCP on Windows: "spawn npx ENOENT" — wrap with cmd /c
MCP server fails on Windows with spawn npx ENOENT (or EINVAL) because npx is npx.cmd. Set command to cmd and args to /c npx … so a shell launches it.
SPAWN ERROR: ENOENT spawn npx ENOENTA stdio MCP server registered with "command": "npx" fails to start on Windows. On Windows, npx is not an executable but the batch file npx.cmd, and Node.js cannot launch a .cmd without a shell. Change command to cmd and put /c and npx at the front of args.
Clients often show only Failed to connect instead of this message. In a public Claude Code issue, claude mcp list printed:
plugin:context7:context7: npx -y @upstash/context7-mcp - Failed to connectplugin:playwright:playwright: npx @playwright/mcp@latest - Failed to connect[1] Confirm this is the cause. The same config works on Linux or macOS but not on Windows, and other MCP servers that launch an .exe connect fine on the same machine. This is different from Executable not found in $PATH, where npx is missing from PATH entirely (see Connect an MCP server to Claude Code and diagnose "not connected"). In PowerShell, run where.exe npx and check that it prints npx.cmd.
[2] Understand why. The Node.js docs say that on Windows, .bat and .cmd files are not executable on their own without a terminal; they must be launched with child_process.spawn() and the shell option, or by spawning cmd.exe and passing the file as an argument. Two public issues summed up the same cause:
| How it is launched | Result (as reported) |
|---|---|
spawn('npx', …) | ENOENT: the bare name npx does not resolve to the .cmd |
spawnSync('npx.cmd', …) | EINVAL: since Node.js 18.20.2 and 20.12.2, a security fix (CVE-2024-27980) refuses to run .cmd without a shell |
spawn('cmd', ['/c', 'npx', …]) | Works |
So renaming the command to npx.cmd is not a fix; on current Node it only turns the error into EINVAL.
[3] Wrap the config with cmd /c. Change the server entry in .mcp.json or your client's config file:
{ "mcpServers": { "context7": { "command": "cmd", "args": ["/c", "npx", "-y", "@upstash/context7-mcp"] } }}To register it with the Claude Code CLI, everything after -- is passed through as the server command:
> claude mcp add --transport stdio context7 -- cmd /c npx -y @upstash/context7-mcpThen check with claude mcp list or /mcp in a session that the server connects. Quote any argument path that contains spaces (a caution from the Node.js docs).
[4] If a plugin added the server, expect your edit to be overwritten. Issue #58510 reported that several official marketplace plugins (context7, playwright and others) ship "command": "npx" as is and fail on Windows; the workaround there was editing plugin manifests under ~/.claude/plugins/cache/…, which the reporter called fragile. The plugin cache can be re-downloaded on update, so registering the same server yourself as in step 3 and disabling the plugin's server lasts longer.
[5] Or drop npx altogether. Install the server package with npm install -g and launch its entry file with node, a real executable, so no .cmd is involved. The entry file path differs per package, so check that package's instructions. You lose the always-latest behavior of npx -y and must upgrade yourself.
[6] Until it is fixed, the workaround is the only way. In the Claude Code repository, #58510 was closed as stale on 2026-07-14 (not planned), and #68221, which reported the Windows EINVAL, was closed by a maintainer as a duplicate of #58510. As of 2026-10, the changelog (through 2.1.310) has no entry about launching MCP servers through a shell, and the Claude Code MCP docs no longer carry a Windows cmd /c note. The 2.1.119 entry mentions removing a false-positive "Windows requires 'cmd /c' wrapper" MCP config warning.
If the server connects but drops right away, see Fix MCP error -32000: Connection closed (stdio server exited).