Fix it on Windows
The official modelcontextprotocol/servers README: "On Windows, wrap npx with cmd /c". In claude_desktop_config.json:
{
"mcpServers": {
"memory": {
"command": "cmd",
"args": ["/c", "npx", "-y", "@modelcontextprotocol/server-memory"]
}
}
}
The same README says to leave uvx entries unchanged: uvx doesn't need the wrapper.
In Claude Code the launch command goes after --, so the same idea is:
claude mcp add --transport stdio memory -- cmd /c npx -y @modelcontextprotocol/server-memory
(Claude Code's docs show the -- form; adding cmd /c applies the README's Windows rule to it.)
Why Windows needs it
On Windows, npx is a script, not a program. Node's docs: ".bat and .cmd files are not executable on their own without a terminal", and their own example runs one through cmd.exe /c. Node's process layer (libuv) only looks for .com and .exe when it searches PATH, so a bare npx isn't found: ENOENT.
If you get spawn EINVAL instead: you pointed command at npx.cmd directly. Since the April 2024 Node security release (CVE-2024-27980), "Node.js will now error with EINVAL if a .bat or .cmd file is passed to child_process.spawn" without a shell. Use cmd /c as above.
Error mentions ${APPDATA}
The MCP docs: if the server's log shows ${APPDATA} inside a path, add the expanded value to the server's env, for example "env": {"APPDATA": "C:\\Users\\you\\AppData\\Roaming"}. The same page notes npx may keep failing if npm isn't installed globally: npm install -g npm.
Fix it on macOS and Linux
- In a terminal, find the real path:
which npx(orwhich uvx,which node). - Put that full path in
command, for example"command": "/opt/homebrew/bin/npx". - Restart the app completely.
Why: tools installed with nvm, asdf, Homebrew or uv (which puts uvx in ~/.local/bin) are added to PATH by your shell profile. The MCP docs: servers launched over stdio "inherit only a limited subset of environment variables automatically". VS Code's FAQ describes the same thing for apps started from the macOS dock: "you don't have access to those environment settings".
Alternatively, set PATH for that one server in its env block. Node looks the command up "using the options.env.PATH environment variable if env is in the options object".
Check it the official way
- Run the exact command yourself in a terminal, with the same arguments. If it fails there, fix the install first (the Filesystem server, for example, needs Node.js 24 or later).
- Read the logs. Claude Desktop:
~/Library/Logs/Claude(macOS),%APPDATA%\Claude\logs(Windows),~/.config/Claude/logs(Linux).mcp.loghas connection failures;mcp-server-NAME.loghas that server's stderr. Claude Code:/mcpshows each server's status. - Restart fully after editing the config, then try a request that needs the server's tools.
Variants of the same error
| You see | Means |
|---|---|
spawn npx ENOENT / spawn uvx ENOENT | That command isn't on the PATH the app sees |
spawn node ENOENT | Same, for node (common with nvm). VS Code shows it as Connection state: Error spawn node ENOENT |
spawn claude ENOENT | A client running claude mcp serve can't find claude: use its full path (which claude) |
spawn EINVAL | Windows, npx.cmd passed directly: use cmd /c |
Running Claude Code, Codex or Cursor on real repos, or shipping an AI agent? A Quick Review ($149 / ₹13,900, 1 working day) checks one repo, config or setup for leaked keys, risky agent permissions and MCP servers. Request a Quick Review
FAQ
What does spawn npx ENOENT mean?
The app tried to start your MCP server with npx and couldn't find the npx command. The server itself may be fine. It is a PATH or Windows script problem.
How do I fix spawn npx ENOENT on Windows?
Set command to cmd and put /c, npx and the package in args, as the official MCP servers README says: "command": "cmd", "args": ["/c", "npx", "-y", "<package>"].
Why does npx work in my terminal but not in Claude Desktop?
Your terminal loads your shell profile, which adds nvm, Homebrew or uv to PATH. An app started from the dock or Start menu doesn't. Use the full path from which npx, or set PATH in the server's env.
Why do I get spawn EINVAL instead of ENOENT?
Since Node's April 2024 security release, passing a .cmd file such as npx.cmd to spawn without a shell is refused with EINVAL. Use cmd /c npx instead.
Related errors
- VS Code: MCP server was unable to start successfully
- MCP error -32000: Connection closed
- Codex not working on Windows
Sources
Read 2 Dec 2026. These tools change often: if a step no longer matches, the linked page wins.
- modelcontextprotocol/servers README (Windows: wrap npx with cmd /c): github.com/modelcontextprotocol/servers
- Node.js docs: child_process (spawning .bat and .cmd files on Windows): nodejs.org/api/child_process.html
- Node.js April 2024 security releases (CVE-2024-27980, spawn EINVAL): nodejs.org/en/blog/vulnerability/april-2024-security-releases-2
- libuv source: src/win/process.c (Windows command search): github.com/libuv/libuv/blob/v1.x/src/win/process.c
- MCP docs: Debugging: modelcontextprotocol.io/docs/tools/debugging
- MCP docs: Connect to local MCP servers: modelcontextprotocol.io/docs/develop/connect-local-servers
- VS Code FAQ: Resolving shell environment: code.visualstudio.com/docs/supporting/faq
- uv docs: Storage (where uvx is installed): docs.astral.sh/uv/reference/storage/
- Claude Code docs: MCP: code.claude.com/docs/en/mcp
- MCP config checker: scan your mcp.json for hard-coded tokens, unpinned servers and risky access
- mcp.json config check: the same checks as a local Python check
- MCP server security scanner: check an MCP server's source before you install it
- MCP server safety directory: hand-checked grades for popular MCP servers