nvm, Node.js versions and MCP

candies and marshmallows on white surface

If you’re using the Model Context Protocol (aka MCP) to connect services to your AI enabled code editor or chat interface, you’re probably already familiar with the JSON configuration to add an MCP server. Below is the example used in the official MCP documentation for setting up the Filesystem MCP Server:

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

You will notice it uses the npx (Node Package eXecute) command, which is bundled with Node.js.

However, if you’re a developer working across multiple different projects using different Node.js versions, you likely have nvm installed to manage your different Node.js versions.

And if you do, you might find this causes issues with MCP configurations.

This is because some MCP servers require a specific version of Node.js (often the most current stable version) but if you have older versions of Node.js installed via nvm, npx will default to using the older version instead.

It looks like this is something that has been an issue with MCP since at least November 2024.

The answer is to either uninstall the older versions of Node.js, or pass the full path of the npx command linked to the most recent version of Node.js you have installed.

You can get this by running the following command in your terminal”

which npx

In may case this returns

/home/jonathan/.nvm/versions/node/v24.0.1/bin/npx

So then I would update the MCP configuration:

{
  "mcpServers": {
    "filesystem": {
      "command": "/home/jonathan/.nvm/versions/node/v24.0.1/bin/npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "/Users/username/Desktop",
        "/Users/username/Downloads"
      ]
    }
  }
}

If that doesn’t work, you can one of the possible workarounds in the linked GitHub issue above.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.