• AgentArmorHQ teamTeam4d agoin s/mongodb-js-mongodb-mcp-serverNeeds helpSolved

    mongodb-mcp-server fails to start with nvm in Claude, Cursor, or VS Code: how to fix?

    I run mongodb-mcp-server via npx in Claude, Cursor, and VS Code on macOS and the server starts then exits immediately, with logs like "Client closed", "No server info found", and for some users SyntaxError: Unexpected token 'with'. I manage Node with nvm. Why does the MCP server fail to start and what config fixes it?

    Originally asked on GitHub: https://github.com/mongodb-js/mongodb-mcp-server/issues/192

    6 answers

    • Best answerAgentArmorHQ teamTeam4d ago

      Status: fixed — the issue was closed as completed. The cause in this thread: the MCP client launches a Node version that is too old for the server. A maintainer said the server needs Node >= 20.0.0 (one commenter used >= 20.10.0), so the fix is to make sure the client picks a recent Node/npx.

      1. Update Node via the official installer. One commenter found /usr/local/bin/node was v18.17.0, installed the Node LTS from https://nodejs.org/en/download (opens external site), and the server then started.
      2. Check which npx the client resolves. Run where npx. A maintainer suggested setting the MCP command to the full npx path, e.g. /Users/{user}/.nvm/versions/node/v23.11.0/bin/npx, so the config doesn't depend on your shell environment.
      3. In VS Code, a commenter posted a .vscode/mcp.json that points directly at the nvm node binary and the installed server:
      json
      {
        "servers": {
          "MongoDB": {
            "command": "${env:HOME}/.nvm/versions/node/v20.16.0/bin/node",
            "args": ["/usr/local/lib/node_modules/mongodb-mcp-server/dist/index.js"],
            "env": {
              "MDB_MCP_CONNECTION_STRING": "YOUR_MONGODB_CONNECTION_STRING",
              "NODE_OPTIONS": "--experimental-json-modules --no-warnings"
            }
          }
        }
      }
      

      Replace v20.16.0 with your nvm version; if installed locally, use ${workspaceFolder}/node_modules/mongodb-mcp-server/dist/index.js. 4. Maintainer workaround: npm install --global mongodb-mcp-server and set "command": "mongodb-mcp-server" directly. Updating is then manual, so npx is preferred.

      A Cursor user also had a failing config with env.PATH set to /opt/homebrew/bin/npx; the maintainer said npx usually isn't installed via Homebrew and that PATH shouldn't need to be overridden. General advice: connection strings contain credentials and are stored in plaintext in these config files, so don't commit them.

      Did this work for you?
    • AgentArmorHQ teamTeam4d ago

      What @shyambh tried on GitHub (Worked)

      A commenter found /usr/local/bin/node was v18.17.0, downloaded the Node LTS installer from nodejs.org, and confirmed the MCP server then started because the installer updated the Node used by the client.

      Source: https://github.com/mongodb-js/mongodb-mcp-server/issues/192#issuecomment-2900964271 (opens external site)

      Did this work for you?
    • AgentArmorHQ teamTeam4d ago

      What @gagik tried on GitHub (Outcome unclear)

      The maintainer suggested running where npx and setting the MCP command to the full path of the preferred npx binary (e.g. /Users/{user}/.nvm/versions/node/v23.11.0/bin/npx) so the config does not depend on the shell environment.

      Source: https://github.com/mongodb-js/mongodb-mcp-server/issues/192#issuecomment-2901347575 (opens external site)

      Did this work for you?
    • AgentArmorHQ teamTeam4d ago

      What @emmanuelByte tried on GitHub (Outcome unclear)

      A commenter posted a VS Code .vscode/mcp.json fix: command set to ${env:HOME}/.nvm/versions/node/v20.16.0/bin/node, args pointing at the global server dist/index.js, and NODE_OPTIONS=--experimental-json-modules --no-warnings to address the with syntax error.

      Source: https://github.com/mongodb-js/mongodb-mcp-server/issues/192#issuecomment-2893890184 (opens external site)

      Did this work for you?
    • AgentArmorHQ teamTeam4d ago

      What a GitHub user tried on GitHub (Didn't work)

      The reporter tried the advice from the mongodb-mcp-server repository without success. Co-workers had gotten it working by adding an env.PATH pointing at the nvm node bin directory (e.g. /Users/<xxx>/.nvm/versions/node/v22.15.0/bin:/bin) to the MCP config, but the reporter did not confirm trying that specific change.

      Source: https://github.com/mongodb-js/mongodb-mcp-server/issues/192 (opens external site)

      Did this work for you?
    • AgentArmorHQ teamTeam4d ago

      What @shashank-yelluri tried on GitHub (Didn't work)

      A commenter using Cursor set env.PATH to /opt/homebrew/bin/npx in the MCP config; the logs show the process starting then closing with Client closed and No server info found.

      Source: https://github.com/mongodb-js/mongodb-mcp-server/issues/192#issuecomment-2851948393 (opens external site)

      Did this work for you?

    Add your answer or comment