
When Claude Code spawn npx ENOENT shows up for an MCP server, it means one simple thing: Claude Code tried to start your MCP server with the command npx, and it could not find a program called npx in any folder on its PATH. ENOENT is the system’s short code for “no such file or directory”. The server never starts, so its tools never show up.
The fix is to make npx findable for the process that runs Claude Code. Run which npx in your terminal to get its full path, then either add a PATH to the server’s env block in .mcp.json, or point command at Node directly. Watch out for one trap: a full path to npx on its own is often not enough, because npx itself needs node on the PATH.
We broke a working MCP server on purpose in a throwaway project, recorded every message Claude Code showed, and tested four fixes side by side. Below you’ll find the real output, why each fix works or fails, and how to keep this error from coming back.
Browse all our Claude Code tutorials for more fixes and how-tos.
Tested with Claude Code v2.1.332 on macOS on December 6, 2026, with Node.js v25.6.1, npx 11.9.0 and the open-source sequential-thinking MCP server (v2.2.1) as the demo server. Everything ran in a demo folder with a project .mcp.json, so no real setup was changed. Linux uses the same PATH lookup; for Windows, follow the official MCP docs.
Quick Summary: Fixing “spawn npx ENOENT” in Claude Code
Find what you see in the first column. Every row below is something we triggered and checked ourselves on v2.1.332.
| What you see | Cause | Fix | Result in our test |
|---|---|---|---|
ENOENT: Executable not found in $PATH: "npx" | npx is not on the PATH Claude Code got | Add PATH to the server’s env | Connected |
spawn npx ENOENT (raw Node.js form) | Same cause, older or other MCP clients | Same fixes as above | Reproduced with Node |
CONNECTION_CLOSED after you set a full path to npx | npx starts but can’t find node | Add PATH too, or run node directly | Full path alone failed |
which npx prints nothing | Node.js is not installed | Install Node.js, open a new terminal | Check with which |
| Works in one terminal, fails from an IDE or app | The app started Claude Code with a shorter PATH | Set PATH in env, or launch from that terminal | Reproduced with a short PATH |
What “spawn npx ENOENT” Means in Claude Code
Most MCP servers you find online are installed with a one-line launch command such as npx -y some-package. Claude Code saves that as a local stdio server. When a session starts, it runs the command as a child process and talks to it over standard input and output.
To run a bare name like npx, the system checks each folder listed in the PATH environment variable, in order. If no folder has a file called npx, the start fails with ENOENT. The server is marked failed and you get no tools from it.

The key detail is which PATH counts. It is the PATH of the process that started Claude Code, not the PATH you see in some other window. A terminal that loads your shell profile usually has Node’s folder; an editor, launcher or script started another way may not.
ENOENT is never about the MCP package itself. It is about the command in front of it.
How We Reproduced the Error
We made a demo folder, installed the sequential-thinking server into it with npm, and added a project .mcp.json entry with "command": "npx". In a normal terminal, the server connected right away.
Then we opened a shell whose PATH held only the folder with the claude program plus /usr/bin and /bin. That copies what happens when Claude Code starts from a place that never loaded your shell profile, such as an app launcher or a script.
The error in claude mcp get
Running claude mcp get thinking showed the failure clearly. Current versions of Claude Code word it as ENOENT: Executable not found in $PATH: "npx" on the Issue line.

The same error inside the /mcp panel
Inside a session, type /mcp. Failed servers get a red cross. Our two broken entries both show up here, even though they fail for different reasons.

Press Enter on a failed server to open its details. Claude Code translates the error into plain English: npx isn't installed, or isn't on your PATH. It also shows the log file path and where the config lives.

Where the “spawn npx ENOENT” wording comes from
The exact phrase people search for comes from Node.js, which many MCP clients are built on. When a Node program tries to spawn a command that isn’t on PATH, Node reports spawn npx ENOENT. We ran that same spawn in our short-PATH shell to prove it is the same failure.

Anthropic’s own MCP docs use this wording too. In the section about using Claude Code as an MCP server, they warn that a wrong executable path leads to errors like spawn claude ENOENT. So whether you see the raw form or Claude Code’s friendlier text, the fixes are the same.
Step 1: Find Where npx and node Live
Open the terminal where Node.js works for you and run which npx node. Each line is a full path you can use in your config. On our Mac, both live in /opt/homebrew/bin, the Homebrew folder.

Look at the last command in that screenshot: the first line of the npx file is #!/usr/bin/env node. That means npx is a small script that asks the system to find node on PATH. Remember this, because it explains why one popular fix only half works.
If which npx prints nothing, Node.js is not installed, or your terminal can’t see it either. Install Node.js from its official site or your package manager, open a new terminal, and check again before you touch any MCP settings.
Step 2: Try the Fixes for Claude Code spawn npx ENOENT
We put four versions of the same server in one .mcp.json so we could compare them in one run. Here is the file. The first entry is the broken original; the others are three fixes.

Fix 1: Add PATH to the server’s env block (recommended)
Keep "command": "npx" and add an env block with a PATH that starts with your Node folder. In our test this worked on its own: Claude Code found npx through the server’s PATH, and npx found node the same way.
{
"mcpServers": {
"thinking": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-sequential-thinking"],
"env": { "PATH": "/opt/homebrew/bin:/usr/bin:/bin" }
}
}
}Replace /opt/homebrew/bin with the folder which npx printed for you. Keep /usr/bin:/bin at the end so basic system tools still work. If you add the server from the command line, the docs show you can pass the same value with --env, as long as the server name does not come right after --env:
claude mcp add --env PATH=/opt/homebrew/bin:/usr/bin:/bin --transport stdio thinking \
-- npx -y @modelcontextprotocol/server-sequential-thinkingFix 2: Full path to npx (only half a fix)
Many guides tell you to swap npx for its full path. We tried exactly that, and the ENOENT message went away. But the server still failed, now with a different error: CONNECTION_CLOSED: Connection closed.

The debug log tells the real story: we ran claude --debug-file ./debug.log mcp get thinking-fullpath and searched the file for the server’s error output. It read env: node: No such file or directory, which is the #!/usr/bin/env node line from Step 1 failing. So if you use a full path to npx, add the PATH in env as well.
Fix 3: Run node directly, no npx at all
If the package is already installed in your project, you can skip npx and run the server file with the full path to node. Nothing needs to be looked up on PATH, so there is nothing to miss. This connected in our test.
"thinking-node": {
"command": "/opt/homebrew/bin/node",
"args": ["node_modules/@modelcontextprotocol/server-sequential-thinking/dist/index.js"]
}Anthropic’s MCP docs suggest the same idea for a different problem: when a stdio server takes over 3 seconds to start, change its command from npx to the installed program. The catch is that you must update the path yourself if the package moves or you upgrade Node.
Fix 4: Start Claude Code from a terminal that has Node
Sometimes the simplest fix is where you launch from. If the server connects when you run claude in your usual terminal but fails from an editor, launcher or script, that tool is passing a shorter PATH. Launching from the terminal works, but Fix 1 is better because it works no matter how Claude Code starts.
Step 3: Confirm the Server Connects
Run claude mcp list and look for a check mark next to your server. Here is our final run with the short PATH still in place. The plain npx entry and the full-path-only entry still fail, while the env PATH fix and the direct node fix both connect.

Inside a running session, you don’t need to restart. The docs say a stdio server that fails its first connection stays failed until you select Reconnect from its menu in /mcp. On v2.1.284 or later you can also type /mcp reconnect all to retry every failed server at once.
Which Fix Should You Use?
Use this ladder to pick the right fix in a few seconds. Start at the top and stop at the first “Yes”.

| Fix | Works in our test | Best for | Downside |
|---|---|---|---|
PATH in env | Yes | Most people, any launch method | The path is machine-specific |
Full path to npx only | No, CONNECTION_CLOSED | Never on its own | npx still needs node |
Full path to node plus script | Yes | Packages installed in the project | You update paths by hand |
| Launch from a working terminal | Yes | Quick one-off sessions | Breaks again from other launchers |
Sharing .mcp.json With a Team
A project .mcp.json is shared through version control, and Node lives in different folders on different machines. Hard-coding /opt/homebrew/bin will break for a teammate who installed Node somewhere else.
The docs say Claude Code expands environment variables in a server’s command, args and env, using ${VAR} or ${VAR:-default}, so you can write a default and let each person override it with their own variable. For example, "PATH": "${NODE_BIN:-/opt/homebrew/bin}:/usr/bin:/bin" uses NODE_BIN when it is set. If you want the server only for yourself, add it at local scope instead, as our guide to MCP server scopes explains.
One more setting can cause this error by itself. The env vars reference lists CLAUDE_CODE_MCP_ALLOWLIST_ENV: when it is set to 1, stdio servers start with only a safe baseline environment plus their own env, instead of your full shell environment. If you or your company turned that on, giving each server its own PATH is the clean way to go.
Try It Yourself
You can see this error safely in a scratch folder. Make an empty folder, add an MCP server there with npx, then open Claude Code in that folder and paste this prompt:
Run `claude mcp list` and `which npx node`. For any MCP server that
failed with ENOENT or CONNECTION_CLOSED, explain the cause in one line
and show me the exact .mcp.json change that would fix it, using the
paths printed by `which`. Don't edit any file yet.Claude will read the real status and the real paths on your machine, so the suggested fix matches your setup. Review the change before you approve it.
Common Mistakes
- Setting a full path to
npxand stopping there. As our test showed,npxthen fails to findnodeand you getCONNECTION_CLOSEDinstead. - Dropping
/usr/bin:/binfrom thePATHyou set. The server may need basic system tools, and a PATH with only Node’s folder can break them. - Forgetting the double dash in
claude mcp add. The docs explain that everything after--goes to the server, so-ywithout it is read as Claude’s own option. - Putting the server name right after
--env. The CLI reads the name as anotherKEY=valuepair and rejects it, so put--transport stdioin between. - Copying a
.mcp.jsonfrom a teammate without checking paths. Their Node folder may not exist on your machine. - Restarting over and over. Use Reconnect in
/mcpafter each change instead.
Pro Tips
- Run
claude mcp get namebefore anything else. ItsIssueline names the problem in one row. - Read the server’s own error output with
claude --debug-file ./debug.log. Lines withServer stderrshow what the server printed before it quit. Our guide on Claude Code logs covers the debug flags in depth. - If you use a Node version manager,
which npxpoints inside that tool’s folder, and the folder changes when you switch versions. Recheck the path after every Node upgrade. - Test a fix with a second entry, like our
thinking-envpath, before you edit the original. You can compare both in oneclaude mcp list. - A server that starts but quits is a different problem. Our post on MCP error logs walks through
CONNECTION_CLOSED, invalid JSON and pending approval.
Cheat Sheet

Frequently Asked Questions
Why does npx work in my terminal but not in Claude Code?
Claude Code uses the PATH it was started with. If an editor, launcher or script started it, that PATH may not include the folder your shell profile adds for Node. Add a PATH to the server’s env block so it no longer depends on how Claude Code starts.
Is “Executable not found in $PATH” the same as “spawn npx ENOENT”?
Yes. Both mean the system could not find npx in any PATH folder. Node.js prints the raw spawn npx ENOENT form, while Claude Code v2.1.332 shows ENOENT: Executable not found in $PATH: "npx" and, in /mcp, a plain-English version.
Why did the full path to npx give CONNECTION_CLOSED?
Because npx is a script that starts with #!/usr/bin/env node, so it still looks for node on PATH. In our test the debug log showed env: node: No such file or directory. Add a PATH in env, or run node directly with the server’s script.
Where do I put the fix?
In whichever file holds the server: .mcp.json at the project root for project scope, or ~/.claude.json for local and user scope. Our guide to the MCP config file shows each location, and claude mcp get tells you the scope.
Do I need to restart Claude Code after the fix?
No. Open /mcp, select the server and choose Reconnect, or type /mcp reconnect all; a new session also picks up the change. For servers that are only slow to start, see our MCP timeout fix instead.
For more error messages, see our list of common Claude Code errors, our beginner guide to Claude Code MCP, and our overview of Claude AI.
Conclusion
The Claude Code MCP “spawn npx ENOENT” error just means Claude Code could not find npx on the PATH it was given. Run which npx node to find your Node folder, then add that folder to a PATH in the server’s env block, or run node directly with the server’s script. Skip the full-path-to-npx shortcut on its own, since npx still needs node, and confirm the result with claude mcp list or Reconnect in /mcp. The official official MCP docs cover the --env flag, variable expansion and every server status in more detail.


