-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Comments
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. |
This workaround works fine |
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"
]
}
}
} |
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! |
Cross-linking: see #40 for Windows workaround steps as well |
Unfortunately, the issue is still reproducible on Mac with nvm installed. OS: macOS 15.1.1 The SQlite server is working correctly, but tools for server-filesystem doesn't appear My settings
|
suggestion: the same way that there is the |
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 |
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 |
In the meantime, I have migrated from NVM to mise, and now, if I start the Claude app from my shell ( 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. |
I was going to say check if 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, 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:
mcp-server-filesystem.log
With the config: {
"globalShortcut": "",
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/dain/Desktop"
]
},
"webresearch": {
"command": "npx",
"args": ["-y", "@mzxrai/mcp-webresearch"]
}
}
} |
This workaround works for me. Thanks a lot! 🙏 Environment
Installation Steps
node -v
# Example output: v18.17.0
git clone <repository-url>
cd <repository-name>
npm install
npm run build
npm link Configure
|
FNM (https://github.com/Schniz/fnm) doesn't work either but the workaround worked! |
This is the way. Mise is an infinitely better tool than NVM. |
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. |
Even if it is. Nevertheless, |
Same goes for Volta (volta.sh). |
the npx way worked for me by just deleting the |
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:
|
thanks, that worked for me! |
I found the same behaviour when working the MCP servers where I am using a Mac so my default shell is 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 |
I'm encountering a strange issue. I'm using nvm with multiple Node.js versions installed on a Mac M1. The MCP server
works perfectly fine for me without any additional setup. A couple of other MCP Servers are also working without any extra configuration. They inlude:
However, most other MCP Servers are failing with the following error:
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:
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:
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
And below is the error I am getting /bin/bash |
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:
This resolves the following issues:
Everything is working smoothly now across all MCPs. |
when i am trying vscode copilot mcp, I counter this problem. i have fixed this.
Solution
Reference |
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 |
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:
I'd be curious if this works in Claude Desktop. |
Thank you, @BobDickinson! This worked, now we just need to update the official documentation 😊. |
@BobDickinson Are you using the docker version of LibreChat? I'm getting errors: |
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$//'"
}
}
}
} |
My problem was caused by Claude Desktop using the lowest version of node in |
@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
I even verified in terminal that 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. |
I assume Claude is using the default Node version. It likely starts a terminal session where the default version is automatically loaded. |
Similar issue:
I installed everything as global
and then this configuration worked
Result: |
However, using the {
"mcpServers": {
"filesystem": {
"command": "mise",
"args": [
"exec",
"node",
"--",
"npx",
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/sean/Desktop",
"/Users/sean/Downloads"
]
}
}
} Think |
Works! In my case, I use
I heard that if you install node app using regular installer, solve this problem, but, whose wants that? |
@nathanredblur what's wrong on doing
|
Nothing, |
For anyone else who uses proto to manage Node version, I found a similar {
"mcpServers": {
"memory": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-memory"
],
"env": {
"PATH": "/Users/foo/.proto/tools/node/23.9.0/bin:/bin"
}
}
}
} Using Confusingly when I ran
I see a path like Claude Desktop seems to be super picky about locating these binaries, even trying to use |
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
npx
, install packages globally.Example:
OS: macOS 15.1.1 (24B91)
The text was updated successfully, but these errors were encountered: