Skip to content

MCP Servers Don't Work with NVM #64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
combdn opened this issue Nov 26, 2024 · 66 comments
Open

MCP Servers Don't Work with NVM #64

combdn opened this issue Nov 26, 2024 · 66 comments
Labels
bug Something isn't working

Comments

@combdn
Copy link

combdn commented Nov 26, 2024

Problem

When using NVM (Node Version Manager), the standard installation and usage instructions for MCP servers don't work. The app tries to use an incorrect Node and fails.

Workaround

  1. Avoid npx, install packages globally.
  2. Use absolute paths to both the Node executable and server script.

Example:

{  
  "mcpServers": {
    "puppeteer": {
      "command": "/Users/username/.nvm/versions/node/v22.11.0/bin/node",
      "args": [
        "/Users/username/.nvm/versions/node/v22.11.0/lib/node_modules/@modelcontextprotocol/server-puppeteer/dist/index.js"
      ]
    }
  }
}

OS: macOS 15.1.1 (24B91)

@mckaywrigley
Copy link

mckaywrigley commented Nov 26, 2024

I also ran into issues with the recommended npx setup, and I was able to successfully reproduce this workaround - fixes it completely.

MCPs now install and attach correctly within Claude Desktop.

@lborgav
Copy link

lborgav commented Nov 27, 2024

This workaround works fine

@adam91holt
Copy link

I can confirm this is working for me too.

You may have a different node.js version installed so just do the following for puppeteer as an example

npm i -g @modelcontextprotocol/server-puppeteer
cd /Users/YOUR_USERNAME/.nvm/versions/node
ls
>>> v14.17.6        v16.19.0        v18.14.0        v18.20.4

Then I ended up with this and it works sweet!

{
  "mcpServers": {
    "puppeteer": {
      "command": "/Users/YOUR_USERNAME/.nvm/versions/node/v18.20.4/bin/node",
      "args": [
        "/Users/YOUR_USERNAME/.nvm/versions/node/v18.20.4/lib/node_modules/@modelcontextprotocol/server-puppeteer/dist/index.js"
      ]
    }
  }
}

@jspahrsummers
Copy link
Member

The challenge with NVM is that it seems to mostly work by installing a very complicated shell function into your shell profile. It'd be great if we could figure out your preferred Node version via NVM, but I haven't found a good way to do that—open to ideas!

@jspahrsummers jspahrsummers added the bug Something isn't working label Nov 27, 2024
@jspahrsummers
Copy link
Member

jspahrsummers commented Nov 27, 2024

Cross-linking: see #40 for Windows workaround steps as well

@lolochka
Copy link

lolochka commented Dec 4, 2024

Unfortunately, the issue is still reproducible on Mac with nvm installed.

OS: macOS 15.1.1
Claude: 0.7.5
Locally I have checked that all packages are available with inputted paths.

The SQlite server is working correctly, but tools for server-filesystem doesn't appear

My settings

{
  "mcpServers": {
    "sqlite": {
      "command": "uvx",
      "args": ["mcp-server-sqlite", "--db-path", "/Users/user/test.db"]
    },
    "filesystem": {
      "command": "/Users/user/.nvm/versions/node/v22.11.0/bin/node",
      "args": [
        "-y",
        "/Users/user/.nvm/versions/node/v22.11.0/lib/node_modules/@modelcontextprotocol/server-filesystem/dist/index.js",
        "/Users/user/claude"
      ]
    }
  }
}

@mlaugharn
Copy link

suggestion: the same way that there is the mcpServers field, can there also be an eg mcpShell field? Or maybe a shell or source key per individual server, eg "shell": "source /Users/user/mcp.sh" ? Might introduce 'too much' flexibility but it could make mcp more usable/transparent to tinker with.

@daaain
Copy link

daaain commented Dec 8, 2024

I was struggling to get MCP working yesterday, the error messages in the logs were unhelpful, and the most confusing of all is that it just started working today. This might not be the repo for this request, but it would be really useful if it was explicily documented which shell Claude Desktop is using to start the MCP services.

To your question @jspahrsummers, wouldn't nvm alias default work?

@jspahrsummers
Copy link
Member

Unfortunately no, the environment for GUI apps is completely different from what you see on the command line.

@daaain
Copy link

daaain commented Dec 9, 2024

Unfortunately no, the environment for GUI apps is completely different from what you see on the command line.

Ah right, I had a look and to answer my own question, assuming that Claude Desktop's Electron implementation uses the MCP TS SDK, it's node:child_process spawn with shell: false.

@combdn
Copy link
Author

combdn commented Dec 9, 2024

In the meantime, I have migrated from NVM to mise, and now, if I start the Claude app from my shell (open -a Claude), it can correctly use node and npm (it didn’t work with NVM). That might be a workaround for some people with the same problem.

PS Apple seems to have removed an option to set up the environment for the GUI apps through the launch agents. But I'm not sure. I didn’t dive too deep into it.

@daaain
Copy link

daaain commented Dec 9, 2024

I was going to say check if path.join(process.env.HOME, '.nvm/nvm-exec') exists and if so, use it, but then also realised that path won't be the same for Windows and the config JSON doesn't specify if the MCP server is Node or Python and using npx -y is just a convention, so can't assume anything.

Feels like the current implementation is in a bit of an uncanny valley between being very open for people to run whatever they want while also very limited by the GUI spawned non-shell process 🤔 I'm wondering if offering the option to either use bundled runtimes for simplicity or running in a full shell for flexibility would be useful? That's what Mac Git GUIs I've used have been doing to solve similar issues. Or WASM 😅

Or actually, maybe having a separate daemon process to make this easier, especially if there are plans to integrate Claude deeper for computer use?

Edit: actually, ~/.nvm/alias/default is a simple text file with the NVM default node version, so if it exists then it can be used to construct a platform dependent path to the Node binary.

BTW MCPs stopped working with my Claude Desktop again, the errors in logs suggest it might be a command argument concat issue?

mcp-server-webresearch.log:

ERROR: You must supply a command.

Execute binaries from npm packages.

  npx [options] <command>[@version] [command-arg]...
...

mcp-server-filesystem.log

command not found: /Users/dain/Desktop

With the config:

{
  "globalShortcut": "",
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "/Users/dain/Desktop"
      ]
    },
    "webresearch": {
      "command": "npx",
      "args": ["-y", "@mzxrai/mcp-webresearch"]
    }
  }
}

@lynnbright
Copy link

lynnbright commented Dec 10, 2024

This workaround works for me. Thanks a lot! 🙏
Here's how I successfully installed the MCP servers.

Environment

  • macOS 14.3
  • Claude 0.7.5

Installation Steps

  1. Check your Node.js version:
node -v
# Example output: v18.17.0
  1. Clone and set up the repository:
git clone <repository-url>
cd <repository-name>
npm install
npm run build
npm link

Configure claude_desktop_config.json

Locate Required Paths

  1. Find your Node.js executable path:
cd ~/.nvm/versions/node
ls  # List available Node versions
cd v18.17.0/bin  # Replace with your version
pwd  # Copy this path + /node for the command field
# Example output: /Users/lynnbright/.nvm/versions/node/v18.17.0/bin/node
  1. Find the built file path:
cd ~/.nvm/versions/node/v18.17.0/lib/node_modules/linear-mcp-server/build
pwd  # Copy this path + /index.js for the args field
# Example output: /Users/lynnbright/.nvm/versions/node/v18.17.0/lib/node_modules/linear-mcp-server/build/index.js

Example Configuration

{
  "mcpServers": {
    "sqlite": {
      "command": "uvx",
      "args": [
        "mcp-server-sqlite",
        "--db-path",
        "/Users/lynnbright/test.db"
      ]
    },
    "linear": {
      "command": "/Users/lynnbright/.nvm/versions/node/v18.17.0/bin/node",
      "args": [
        "/Users/lynnbright/.nvm/versions/node/v18.17.0/lib/node_modules/linear-mcp-server/build/index.js"
      ],
      "env": {
        "LINEAR_API_KEY": "lin_api_xxxx"
      }
    },
    "notion": {
      "command": "/Users/lynnbright/.nvm/versions/node/v18.17.0/bin/node",
      "args": [
        "/Users/lynnbright/.nvm/versions/node/v18.17.0/lib/node_modules/notion/build/index.js"
      ],
      "env": {
        "NOTION_API_TOKEN": "ntn_xxxxx"
      }
    }
  }
}

Final Step

Restart Claude Desktop.

CleanShot 2024-12-10 at 12 32 46@2x

@laulauland
Copy link

FNM (https://github.com/Schniz/fnm) doesn't work either but the workaround worked!

@mearleycf
Copy link

In the meantime, I have migrated from NVM to mise, and now, if I start the Claude app from my shell (open -a Claude), it can correctly use node and npm (it didn’t work with NVM). That might be a workaround for some people with the same problem.

PS Apple seems to have removed an option to set up the environment for the GUI apps through the launch agents. But I'm not sure. I didn’t dive too deep into it.

This is the way. Mise is an infinitely better tool than NVM.

@gannonh
Copy link
Contributor

gannonh commented Dec 20, 2024

Interesting. Btw, the NVM issue goes away if you're only managing 1 version of node. I discovered this inadvertently setting up a new machine. Will check out Mise. First I've heard of it.

@serverlesspolska
Copy link

serverlesspolska commented Dec 27, 2024

This is the way. Mise is an infinitely better tool than NVM.

Even if it is. Nevertheless, nvm is very popular, and it would be nice if it were supported by Claude MCP.

@zaphodtx
Copy link

The challenge with NVM is that it seems to mostly work by installing a very complicated shell function into your shell profile. It'd be great if we could figure out your preferred Node version via NVM, but I haven't found a good way to do that—open to ideas!

Same goes for Volta (volta.sh).

@lonecruisader
Copy link

the npx way worked for me by just deleting the ~/.nvm folder, for Claude Desktop Mac. You can try this if you aren't actively using nvm for development

@ddura
Copy link

ddura commented Apr 7, 2025

Based on the previous approaches mention that create a bash script that selects a specific version of node that was installed via nvm, I created a slightly modified version of that script that selects the version aliased as default:

#!/usr/bin/env bash

export NVM_DIR="$HOME/.nvm"
# Load nvm
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

# Use the default node version
nvm use default > /dev/null

# Run npx with passed arguments
exec npx "$@"

@avxkim
Copy link

avxkim commented Apr 7, 2025

Thanks @jonigl, your snippet was super helpful! 🙌 Just a small tweak — this version should work even if the Node version changes:

/usr/local/bin/npx-for-claude:

#!/usr/bin/env bash
NODE_VERSIONS_DIR="$HOME/.nvm/versions/node"
LATEST_NODE_VERSION=$(ls -v "$NODE_VERSIONS_DIR" | grep "^v" | sort -V | tail -n 1)
export PATH="$NODE_VERSIONS_DIR/$LATEST_NODE_VERSION/bin:$PATH"
exec npx "$@"
It's been working on my end — will keep testing it out :)

thanks, that worked for me!

@akirilyuk
Copy link

I found the same behaviour when working the MCP servers where npx could not be found and cause a ENOENT.

I am using a Mac so my default shell is zsh. Passing the actual shell via os.userInfo().shell using import os from 'os'

https://github.com/modelcontextprotocol/typescript-sdk/blob/main/src/client/stdio.ts#L122

Fixed the issue for me.

Here is the related PR: modelcontextprotocol/typescript-sdk#289

@creddaiah
Copy link

I'm encountering a strange issue. I'm using nvm with multiple Node.js versions installed on a Mac M1. The MCP server

@modelcontextprotocol/server-filesystem

works perfectly fine for me without any additional setup. A couple of other MCP Servers are also working without any extra configuration. They inlude:

"filesystem": {
      "transport": 'stdio',
      "command": 'npx',
      "args": [
          '-y',
          '@modelcontextprotocol/server-filesystem',
          './filesystem_test'
      ]
}
"memory": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-memory"]
}
"airbnb": {
        "command": "npx",
        "args": ["-y", "@openbnb/mcp-server-airbnb"],
        "transport": "stdio"
},

However, most other MCP Servers are failing with the following error:

Error: spawn npx ENOENT

I’ve tried all the solutions mentioned in this thread, but none of them worked for the failing MCP Servers.

Here are some examples of the MCP Servers that are failing:

  • @modelcontextprotocol/server-gitlab
  • firecrawl-mcp
  • @modelcontextprotocol/server-github

I even tested this on a completely fresh Mac (without using nvm, and with Node.js installed directly), and I'm still seeing the same issue with these failing MCP Servers.

On a side note, same thing is happening with MCP servers with docker setup.

For exmaple:

{
  "mcpServers": {
    "github": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "GITHUB_PERSONAL_ACCESS_TOKEN",
        "ghcr.io/github/github-mcp-server"
      ],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>"
      }
    }
  }
}

Error: spawn docker ENOENT

I have docker installed in my machine and it is running.

@akirilyuk
Copy link

I'm encountering a strange issue. I'm using nvm with multiple Node.js versions installed on a Mac M1. The MCP server

@modelcontextprotocol/server-filesystem

works perfectly fine for me without any additional setup. A couple of other MCP Servers are also working without any extra configuration. They inlude:

"filesystem": {
      "transport": 'stdio',
      "command": 'npx',
      "args": [
          '-y',
          '@modelcontextprotocol/server-filesystem',
          './filesystem_test'
      ]
}
"memory": {
     "command": "npx",
     "args": ["-y", "@modelcontextprotocol/server-memory"]
}
"airbnb": {
       "command": "npx",
       "args": ["-y", "@openbnb/mcp-server-airbnb"],
       "transport": "stdio"
},

However, most other MCP Servers are failing with the following error:

Error: spawn npx ENOENT

I’ve tried all the solutions mentioned in this thread, but none of them worked for the failing MCP Servers.

Here are some examples of the MCP Servers that are failing:

  • @modelcontextprotocol/server-gitlab
  • firecrawl-mcp
  • @modelcontextprotocol/server-github

I even tested this on a completely fresh Mac (without using nvm, and with Node.js installed directly), and I'm still seeing the same issue with these failing MCP Servers.

On a side note, same thing is happening with MCP servers with docker setup.

For exmaple:

{
  "mcpServers": {
    "github": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "GITHUB_PERSONAL_ACCESS_TOKEN",
        "ghcr.io/github/github-mcp-server"
      ],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>"
      }
    }
  }
}

Error: spawn docker ENOENT

I have docker installed in my machine and it is running.

Did you try my solution? You can use patch-package to make it work. And install os as a dependency for your own project.

@creddaiah
Copy link

creddaiah commented Apr 9, 2025

I'm encountering a strange issue. I'm using nvm with multiple Node.js versions installed on a Mac M1. The MCP server

@modelcontextprotocol/server-filesystem

works perfectly fine for me without any additional setup. A couple of other MCP Servers are also working without any extra configuration. They inlude:

"filesystem": {
      "transport": 'stdio',
      "command": 'npx',
      "args": [
          '-y',
          '@modelcontextprotocol/server-filesystem',
          './filesystem_test'
      ]
}
"memory": {
     "command": "npx",
     "args": ["-y", "@modelcontextprotocol/server-memory"]
}
"airbnb": {
       "command": "npx",
       "args": ["-y", "@openbnb/mcp-server-airbnb"],
       "transport": "stdio"
},

However, most other MCP Servers are failing with the following error:

Error: spawn npx ENOENT

I’ve tried all the solutions mentioned in this thread, but none of them worked for the failing MCP Servers.
Here are some examples of the MCP Servers that are failing:

  • @modelcontextprotocol/server-gitlab
  • firecrawl-mcp
  • @modelcontextprotocol/server-github

I even tested this on a completely fresh Mac (without using nvm, and with Node.js installed directly), and I'm still seeing the same issue with these failing MCP Servers.
On a side note, same thing is happening with MCP servers with docker setup.
For exmaple:

{
  "mcpServers": {
    "github": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "GITHUB_PERSONAL_ACCESS_TOKEN",
        "ghcr.io/github/github-mcp-server"
      ],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>"
      }
    }
  }
}

Error: spawn docker ENOENT

I have docker installed in my machine and it is running.

Did you try my solution? You can use patch-package to make it work. And install os as a dependency for your own project.

Yes, I tried it but unfortunately it didn't work. Funny part is few MCPs are working without any issue.

Below are the changes I applied

diff --git a/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js b/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js
index 745218a..48f5b08 100644
--- a/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js
+++ b/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js
@@ -1,6 +1,8 @@
 import spawn from "cross-spawn";
 import process from "node:process";
 import { ReadBuffer, serializeMessage } from "../shared/stdio.js";
+import os from "os"
+
 /**
  * Environment variables to inherit by default, if an environment is not explicitly given.
  */
@@ -57,11 +59,12 @@ export class StdioClientTransport {
             throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");
         }
         return new Promise((resolve, reject) => {
+            console.log(os.userInfo().shell);
             var _a, _b, _c, _d, _e, _f;
             this._process = spawn(this._serverParams.command, (_a = this._serverParams.args) !== null && _a !== void 0 ? _a : [], {
                 env: (_b = this._serverParams.env) !== null && _b !== void 0 ? _b : getDefaultEnvironment(),
                 stdio: ["pipe", "pipe", (_c = this._serverParams.stderr) !== null && _c !== void 0 ? _c : "inherit"],
-                shell: false,
+                shell: os.userInfo().shell || false,
                 signal: this._abortController.signal,
                 windowsHide: process.platform === "win32" && isElectron(),
                 cwd: this._serverParams.cwd,

And below is the error I am getting

/bin/bash
env: node: No such file or directory
Error: MCPClientError: Failed to connect to stdio server "github": McpError: MCP error -32000: Connection closed

@creddaiah
Copy link

I got this working now. Below is what I did.

I updated the env used in spawn() of @modelcontextprotocol/sdk to explicitly include the current PATH.

Below is the patch I applied to the @modelcontextprotocol/sdk package:

  • Kept shell set to false (unchanged)
  • Explicitly added PATH to the env passed to spawn()
diff --git a/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js b/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js
index 745218a..9c5ea39 100644
--- a/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js
+++ b/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js
@@ -1,6 +1,7 @@
 import spawn from "cross-spawn";
 import process from "node:process";
 import { ReadBuffer, serializeMessage } from "../shared/stdio.js";
+
 /**
  * Environment variables to inherit by default, if an environment is not explicitly given.
  */
@@ -59,7 +60,10 @@ export class StdioClientTransport {
         return new Promise((resolve, reject) => {
             var _a, _b, _c, _d, _e, _f;
             this._process = spawn(this._serverParams.command, (_a = this._serverParams.args) !== null && _a !== void 0 ? _a : [], {
-                env: (_b = this._serverParams.env) !== null && _b !== void 0 ? _b : getDefaultEnvironment(),
+                env: {
+                    ...((_b = this._serverParams.env) !== null && _b !== void 0 ? _b : getDefaultEnvironment()),
+                    PATH: process.env.PATH,
+                },
                 stdio: ["pipe", "pipe", (_c = this._serverParams.stderr) !== null && _c !== void 0 ? _c : "inherit"],
                 shell: false,
                 signal: this._abortController.signal,
 

This resolves the following issues:

  • env: node: No such file or directory
  • Error: spawn npx ENOENT
  • Error: spawn docker ENOENT

Everything is working smoothly now across all MCPs.

@CANntyield
Copy link

when i am trying vscode copilot mcp, I counter this problem. i have fixed this.
i find vscode is default to use bash to run mcp command,but my nvm config not in bash.
Background

  • macos
  • vscode copilot mcp
  • use nvm

Solution

  1. vim ~/.bash_profile
  2. export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
  3. save (vim save file operation: esc -> !wq -> enter)
  4. reset vscode

Reference
nvm config bash detail

@vanb
Copy link

vanb commented Apr 12, 2025

This seems to be an issue with the host app not loading nvm, rather than the MCP servers. For example, Claude Code works with NvM and these standard JSON params just fine, while Claude Desktop does not. For Claude Desktop, the only solution above that worked for me was using full path to node and full path to globally installed MCP package.

@BobDickinson
Copy link

I have an Electron app which was working fine calling servers via npx until I bundled it. A bundled Electron app (assuming Claude Desktop is similar) doesn't have access to the system path, so you have to pass a PATH env var to the StdioClientTransport that points to the node bin directory, but that will not be enough. npx also uses a variety of shell commands (including "sh" itself) so the PATH you send in has to contain a path to those as well (/bin).

I was able to get npx servers to work in this environment without even needing to pass the full path to npx, just making sure to pass the correct PATH env var.

Note: If you pass the full path to npx as the command, but you don't also provide a PATH env var that points to node bin, npx will fail to find and launch node and you'll get the "env: node: No such file or directory"

Here's an example:

{
  "filesystem": {
    "command": "npx",
    "args": [
      "-y",
      "@modelcontextprotocol/server-filesystem",
      "/Users/bob/Documents/GitHub/teamspark-workbench/test_files"
    ],
    "env": {
      "PATH": "/Users/bob/.nvm/versions/node/v20.10.0/bin:/bin"
    }
  }
}

I'd be curious if this works in Claude Desktop.

@zalom
Copy link

zalom commented Apr 26, 2025

Thank you, @BobDickinson! This worked, now we just need to update the official documentation 😊.

@notflip
Copy link

notflip commented Apr 29, 2025

@BobDickinson Are you using the docker version of LibreChat? I'm getting errors: Connection failed: spawn /Users/miguelstevens/.nvm/versions/node/v20.10.0/bin/node ENOENT, the folder does exist on my Mac, but I suppose docker doesn't have access to it.

@sag1v
Copy link

sag1v commented Apr 29, 2025

It would be nice if we could pass the command (or other fields) as dynamic commands.

For example:

{
  "mcpServers": {
    "my-server": {
      "command": "$(which npx)",
      "args": ["-y", "@my-mcp-server"],
      "env": {
        "PATH": "$(which node) | sed 's//node$//'"
      }
    }
  }
}

@WaiNaat
Copy link

WaiNaat commented Apr 30, 2025

My problem was caused by Claude Desktop using the lowest version of node in /Users/me/.nvm/versions/node/ directory. Solved it by just deleting other versions in this folder.

@johnrhombus
Copy link

johnrhombus commented Apr 30, 2025

@WaiNaat has the answer. I have (had) multiple versions of node installed via NVM.

Removing the older versions fixed the issue, and Claud was able to connect to my MCP server with no problem.

This seems like a bug (maybe?) in the Claud app? Why is it trying to use a version of node that is lower than my default version set via nvm alias default 20 nor even the minimum acceptable version defined in package.json for the MCP server like so:

"engines": {
    "node": ">=18"
  }

I even verified in terminal that which npx returns a path to v20 node, which is my default.

It seems like where ever Claud is getting a version of npx for an old node version. After I removed all my old node versions and left 18+ installed, it worked.

@sag1v
Copy link

sag1v commented Apr 30, 2025

I assume Claude is using the default Node version. It likely starts a terminal session where the default version is automatically loaded.

@genesiscz
Copy link

Similar issue:

==> /Users/Martin/Library/Logs/Claude/mcp-server-github.log <==

ERROR: You must supply a command.

Execute binaries from npm packages.

  npx [options] <command>[@version] [command-arg]...

  npx [options] [-p|--package <package>]... <command> [command-arg]...

  npx [options] -c '<command-string>'

  npx --shell-auto-fallback [shell]


Options:
  --package, -p          Package to be installed.                       [string]
  --cache                Location of the npm cache.                     [string]
  --always-spawn         Always spawn a child process to execute the command.
                                                                       [boolean]
  --no-install           Skip installation if a package is missing.    [boolean]
  --userconfig           Path to user npmrc.                            [string]
  --call, -c             Execute string as if inside `npm run-script`.  [string]
  --shell, -s            Shell to execute the command with, if any.
                                                       [string] [default: false]
  --shell-auto-fallback  Generate shell code to use npx as the "command not
                         found" fallback.
                                   [string] [choices: "", "bash", "fish", "zsh"]
  --ignore-existing      Ignores existing binaries in $PATH, or in the local
                         project. This forces npx to do a temporary install and
                         use the latest version.                       [boolean]
  --quiet, -q            Suppress output from npx itself. Subcommands will not
                         be affected.                                  [boolean]
  --npm                  npm binary to use for internal operations.
  [string] [default: "/Users/Martin/.nvm/versions/node/v14.18.1/lib/node_modules
                                                           /npm/bin/npm-cli.js"]
  --node-arg, -n         Extra node argument when calling a node binary.[string]
  --version, -v          Show version number                           [boolean]
  --help, -h             Show help                                     [boolean]

For the full documentation, see the manual page for npx(1).
2025-05-04T17:56:18.613Z [github] [info] Server transport closed

==> /Users/Martin/Library/Logs/Claude/mcp.log <==
2025-05-04T17:56:18.613Z [info] [github] Server transport closed

==> /Users/Martin/Library/Logs/Claude/mcp-server-github.log <==
2025-05-04T17:56:18.613Z [github] [info] Client transport closed
2025-05-04T17:56:18.613Z [github] [info] Server transport closed unexpectedly, this is likely due to the process exiting early. If you are developing this MCP server you can add output to stderr (i.e. `console.error('...')` in JavaScript, `print('...', file=sys.stderr)` in python) and it will appear in this log.
2025-05-04T17:56:18.613Z [github] [error] Server disconnected. For troubleshooting guidance, please visit our [debugging documentation](https://modelcontextprotocol.io/docs/tools/debugging) {"context":"connection"}
2025-05-04T17:56:18.613Z [github] [info] Client transport closed

==> /Users/Martin/Library/Logs/Claude/mcp.log <==
2025-05-04T17:56:18.613Z [info] [github] Client transport closed
2025-05-04T17:56:18.613Z [info] [github] Server transport closed unexpectedly, this is likely due to the process exiting early. If you are developing this MCP server you can add output to stderr (i.e. `console.error('...')` in JavaScript, `print('...', file=sys.stderr)` in python) and it will appear in this log.
2025-05-04T17:56:18.613Z [error] [github] Server disconnected. For troubleshooting guidance, please visit our [debugging documentation](https://modelcontextprotocol.io/docs/tools/debugging)
2025-05-04T17:56:18.613Z [info] [github] Client transport closed

==> /Users/Martin/Library/Logs/Claude/mcp-server-github.log <==
2025-05-04T17:58:11.707Z [github] [info] Initializing server...

==> /Users/Martin/Library/Logs/Claude/mcp.log <==
2025-05-04T17:58:11.707Z [info] [github] Initializing server...

==> /Users/Martin/Library/Logs/Claude/mcp-server-github.log <==
2025-05-04T17:58:11.760Z [github] [info] Server started and connected successfully

==> /Users/Martin/Library/Logs/Claude/mcp.log <==
2025-05-04T17:58:11.760Z [info] [github] Server started and connected successfully

==> /Users/Martin/Library/Logs/Claude/mcp-server-github.log <==
2025-05-04T17:58:11.762Z [github] [info] Message from client: {"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"claude-ai","version":"0.1.0"}},"jsonrpc":"2.0","id":0}

==> /Users/Martin/Library/Logs/Claude/mcp.log <==
2025-05-04T17:58:11.762Z [info] [github] Message from client: {"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"claude-ai","version":"0.1.0"}},"jsonrpc":"2.0","id":0}

==> /Users/Martin/Library/Logs/Claude/mcp-server-github.log <==

I installed everything as global

bun add --global @modelcontextprotocol/inspector @modelcontextprotocol/server-sequential-thinking @modelcontextprotocol/server-filesystem @modelcontextprotocol/server-github @modelcontextprotocol/server-puppeteer @modelcontextprotocol/server-brave-search

and then this configuration worked

{
  "mcpServers": {
    "github": {
      "command": "mcp-server-github",
      "args": [],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "token"
      }
    },
    "sequential-thinking": {
      "command": "mcp-server-sequential-thinking",
      "args": [],
      "env": {}
    },
    "puppeteer": {
      "command": "mcp-server-puppeteer",
      "args": [],
      "env": {}
    },
    "playwright": {
      "command": "bunx",
      "args": ["@executeautomation/playwright-mcp-server"],
      "env": {}
    },
    "brave-search": {
      "command": "mcp-server-brave-search",
      "env": {
        "BRAVE_API_KEY": "token"
      }
    },
    "filesystem": {
      "command": "mcp-server-filesystem",
      "args": [
        "/Users/Martin/......"
      ]
    }
  }
}

Result:

Image

@SeanLF
Copy link

SeanLF commented May 4, 2025

Facing the same issue with mise

However, using the mise exec command (see doc) worked for me:

{
  "mcpServers": {
    "filesystem": {
      "command": "mise",
      "args": [
        "exec",
        "node",
        "--",
        "npx",
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "/Users/sean/Desktop",
        "/Users/sean/Downloads"
      ]
    }
  }
}

Think nvm exec should work the same (again, see doc)

@nathanredblur
Copy link

nathanredblur commented May 5, 2025

{
  "filesystem": {
    "command": "npx",
    "args": [
      "-y",
      "@modelcontextprotocol/server-filesystem",
      "/Users/bob/Documents/GitHub/teamspark-workbench/test_files"
    ],
    "env": {
      "PATH": "/Users/bob/.nvm/versions/node/v20.10.0/bin:/bin"
    }
  }
}

I'd be curious if this works in Claude Desktop.

Works! In my case, I use nodenv and this solves the problem without require doing a lot of changes.

"mcpServers": {
    "playwright": {
      "command": "npx",
      "args": [
        "@playwright/mcp@latest"
      ],
      "env": {
        "PATH": "/Users/nathanredblur/.nodenv/versions/20/bin/:bin"
      }
    }
}

I heard that if you install node app using regular installer, solve this problem, but, whose wants that?

@genesiscz
Copy link

I heard that if you install node app using regular installer, solve this problem, but, whose wants that?

@nathanredblur what's wrong on doing

bun add --global @playwright/mcp and just not risk it downloading the latest every single time you run the MCP server?

@nathanredblur
Copy link

Nothing,
also, you don't download the MCP every time, npx cache the version, only check if there is a new version and then download it. so, you always have the latest version, but you can fix the version just setting a version after the @ like @playwright/[email protected]

@mattrossman
Copy link

For anyone else who uses proto to manage Node version, I found a similar "env" workaround by including /Users/<username>/.proto/tools/node/<version>/bin on PATH, e.g.

{
	"mcpServers": {
		"memory": {
			"command": "npx",
			"args": [
				"-y",
				"@modelcontextprotocol/server-memory"
			],
			"env": {
				"PATH": "/Users/foo/.proto/tools/node/23.9.0/bin:/bin"
			}
		}
	}
}

Using ls /Users/<username>/.proto/tools/node to find the available version directories.

Confusingly when I ran

which npx

I see a path like /Users/username/.proto/tools/node/globals/bin/npx so logically you'd think including /Users/username/.proto/tools/node/globals/bin on PATH would work, but it failed with vague EOENT or EPIPE errors until I provided the versioned path which I only found from poking inside directories.

Claude Desktop seems to be super picky about locating these binaries, even trying to use ~ to reference my home directory broke it. I wish the debugging process for this could be easier, and I wish the app would behave more like my terminal when resolving commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests