TLDR:
1 solution to this problem is to make sure the path where you install the server doesn’t contain spaces.
e.g:
node C:/my projects/mcpserver/build/index.js will fail because of a space in “my projects”
node C:/projects/mcpserver/build/index.js will work as there are no spaces
notes:
I’m on windows 11 and I’ve tried forward and backslashes and they both work. I just tried forward slashes first, so copying the path of the index.js file in the build folder also works.
I run nvm and I’ve also tried running the server global with spaces in the path and that also didn’t work, with or without full paths to node.exe and the index.js file and with or without quotes around the full paths - Getting rid of spaces in the path was my solution.
You don’t need to run the server manually before adding the command - the command will start the server automatically - just in case you weren’t sure. You should, however, first try to start and stop the server manually before adding it to cursor so you know the server starts without errors.
This isn’t the only possible cause or solution - I’m sure there are other reasons why it may fail to find tools.
How I found out:
In my case I had: D:\My Data\Projects.…
When I tried adding (or refreshing) any MCP server that’s installed in a subdirectory in the path above I briefly see a terminal flashing and a node executable being added and removed to the task manager. I wanted to know what is going on and used the free sysinternals ProcessMonitor tool to check what cursor is trying to execute.
I set the command in the add MCP server without quotes around the path and got this when I refreshed the server:
(Still not allowed to upload multiple images in 1 post so had to post a screenshot of the edit screen which makes it hard to read…)
Just posted a reply below in this thread which may work for you if you have any spaces in the full path to the index.js file. I haven’t tried with npx and just use: node full/path/to/build/index.js (no quotes, no full path to node, not using global node or messing with system variables). Both forward and backslashes work.
All MCP configurations that use npx do not work for me in Cursor on Windows.
2025-02-11 13:21:06.390 [error] [MCP] Failed to connect to stdio server with command 'npx -y @smithery/cli@latest run @smithery-ai/server-sequential-thinking --config "{}"': A system error occurred (spawn npx ENOENT)
2025-02-11 13:21:06.390 [error] [MCP] Error listing tools for stdio server npx -y @smithery/cli@latest run @smithery-ai/server-sequential-thinking --config "{}": A system error occurred (spawn npx ENOENT)
I get the spawn npx ENOENT error for all MCP servers when trying to configure with npx.
I have tried the full path to npx in the command, different types of formatting to the command, etc., and nothing seems to work.
For anyone on windows, I have found that the following directive is super happy_mode:
“Wrap all commands into a .ps1 and execute that”
Cursor is a curmudgeon in that it always falls back to *nix and attempts a && often…
By enforcing that all executions get wrapped into .ps1 for powersshell executution, you get the added benefit that you have a history of ALL agentic actions, and then, I layer that it should always save these to /scripts and that it verbossely comments what its doing… AND then you can tell the agent to make a directory of these tools AND you can tell it to populate a DB table of the various things with descriptiopns and such.
Whereby, one could start a library of tools that come out of the bot.
For example, if in one project you need to slurp a csv and transmogrify and pipe to whatever, save that workflow as an agentic .ps1 regardless of how many .pys its going to call…
You can wrap any config like API keys in a startup script and include it in the build. e.g. you place you API keys in a .env file in your root folder and include the start-server.js script in the build.
#!/usr/bin/env node
// Load environment variables from .env file
import { fileURLToPath } from 'url';
import { dirname, resolve } from 'path';
import { config } from 'dotenv';
// Get the directory where this script is located
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
// Load .env file from the project root (two levels up if in build directory)
const envPath = resolve(__dirname, '..', '.env');
config({ path: envPath });
// Import and run the server
import('./index.js').catch((error) => {
console.error('Failed to start server:', error);
process.exit(1);
});
in the index.js file you then simply refer to the key in the .env file:
I had the same issue using NVM. The answer here is to switch to your preferred node version, globally install the dependency so npm i -g @modelcontextprotocol/server-sequential-thinking, then set the direct path on the node version and the dependency within that node version.
So: C:/Users/<username>/AppData/Roaming/nvm/v<version>/node.exe C:/Users/<username>/AppData/Roaming/nvm/v<version>/node_modules/@modelcontextprotocol/server-postgres/dist/index.js <your-connection-string>
Me too - I have an stdio server and every conceivably way I could start it all fails. The IDE spawns the code (3 times in a row) immediately killing it with signal 255 every time.
This looks incredibly useful, but could you perhaps explain a couple extra things? What are you putting into the .ps1 file (do you have any example of something working you can point us all to maybe?) and I assume you put the full path with forward slashes for the “command” prompt, right ?
I’m on windows 11 and I’m trying to configure the GitHub MCP but I can’t get it to work.
The only way I can see “something” working is if I use the absolute paths to node and the server script, so it looks like C:\node\node.exe C:\Users\Juan\AppData\Roaming\npm\node_modules\@modelcontextprotocol\server-github\dist\index.js, but there are two problems here:
When cursor executes the command a new Terminal window is opened which is annoying and if I close it, the MCP server stops working.
The second thing is the authentication token it requires, if I do something like set GITHUB_PERSONAL_ACCESS_TOKEN=my_token && C:\node\node.exe C:\Users\Juan\AppData\Roaming\npm\node_modules\@modelcontextprotocol\server-github\dist\index.js it doesn’t work anymore.