Skip to content
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

MCP servers fail to connect with npx on Windows #40

Closed
naif0s opened this issue Nov 25, 2024 · 108 comments
Closed

MCP servers fail to connect with npx on Windows #40

naif0s opened this issue Nov 25, 2024 · 108 comments
Labels
bug Something isn't working

Comments

@naif0s
Copy link

naif0s commented Nov 25, 2024

image

I am on Windows with the latest desktop version, I have enabled developer mode and I am in Europe

@sean-lynch
Copy link
Contributor

Can you share your %APPDATA%\Claude\claude_desktop_config.json? (In case this doesn't make sense, I'm referring to step 2 in the Windows quickstart guide here: https://modelcontextprotocol.io/quickstart#installation)

@naif0s
Copy link
Author

naif0s commented Nov 25, 2024

image

@jwross24
Copy link

jwross24 commented Nov 25, 2024

The docs are a bit confusing, and I had a similar issue. You should add the individual MCP servers under the mcpServers key in the JSON like so.

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": [
        ...
      ]
    },
    "memory": {
      "command": "npx",
      "args": [...]
    }
  }
}

They should then show up correctly in the Developer config.

image

@naif0s
Copy link
Author

naif0s commented Nov 25, 2024

image

Thank you, it works! Now, how do I integrate Github?

@jwross24
Copy link

jwross24 commented Nov 25, 2024

You should use the github config that you had before, instead of the filesystem and memory configs that I have. You can add it as another key after filesystem and memory, though those configs won't work exactly as I have written since I omitted the args key for brevity.

You can try:

{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": ["-y",  "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>"
      }
    }
  }
}

@naif0s
Copy link
Author

naif0s commented Nov 25, 2024

OK Thanks, it's super cool for your help. But well... it's not working. I entered the key correctly but when I ask Claude, for example to create an issue, it won't do it

image

@jspahrsummers
Copy link
Member

Are you able to get the GitHub server working with the MCP Inspector? That will help narrow down whether this is a desktop app issue, or a problem with the server setup.

@geelen
Copy link
Contributor

geelen commented Nov 26, 2024

I've got almost the exact same situation. I have two servers configured:

{
  "mcpServers": {
    "sqlite": {
      "command": "uvx",
      "args": ["mcp-server-sqlite", "--db-path", "/Users/glen/src/experiments/claude-local-sqlite"]
    },
    "brave_search": {
      "command": "npx",
      "args": ["@modelcontextprotocol/server-brave-search"],
      "env": {
        "BRAVE_API_KEY": "<redacted>"
      }
    }
  }
}

My debug log looks fine:

image

Settings looks fine:

image

But no 🔌 icon in the chat window:

image

And a flat refusal to do anything with the connections:

image

@geelen
Copy link
Contributor

geelen commented Nov 26, 2024

Update: just tried on my windows machine, and got the exact same result. Is it possible this is geoblocked in Australia?

@ProRedCat
Copy link
Contributor

ProRedCat commented Nov 26, 2024

Same issue here, there is no 🔌, I do have the filesystem server running but I get a message in Claude Desktop of it failing to attach to the MCP server.

image

image

To add more context based on what geelen said, I am from New Zealand and running on Windows so could be georestrictions, or it could be some device setup.

Having issues running MCPInspector as well so debugging is a bit difficult
image

@ProRedCat
Copy link
Contributor

ProRedCat commented Nov 26, 2024

Update on my end, I switched over to a MacBook as there seemed to be some issues with running this on Windows see: modelcontextprotocol/inspector#76

For the filesystem server it is now working as well as the Github server. The region locked theory is wrong, it's just device configuration/OS support.

For the SQLite and Brave Search the issues #37 #42 may be helpful for the others in this thread as there seems to be some issues with pathing sometimes - though I am still facing issues on Windows.

@geelen
Copy link
Contributor

geelen commented Nov 26, 2024

You're quite right. I had a typo in the path to my DB! That was crashing things, even stopping me from adding other tools.

@Sunwood-ai-labs
Copy link

I'm also experiencing issues with the filesystem server on Windows. Here's my configuration:

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

@timurkhakhalev
Copy link

Same behavior on Windows 11 and Mac OS. Claude desktop 0.71.1 version on both devices.

@Da1sypetals
Copy link

I'm also experiencing issues with the filesystem server on Windows. Here's my configuration:

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

The same problem with me. My configuration :

{
    "mcpServers": {
        "filesystem": {
            "command": "npx",
            "args": [
                "-y",
                "@modelcontextprotocol/server-filesystem",
                "A:\\Desktop\\"
            ]
        }
    }
}

@mckaywrigley
Copy link

Experiencing similar issues on Mac OS using Claude Desktop 0.71.1.

@mcgraf
Copy link

mcgraf commented Nov 26, 2024

I am having the same issue on Windows 10 with latest Claude Desktop

@RELMYMathieu
Copy link

Same issue, log file attached:
image

@mike-luabase
Copy link

@mckaywrigley what does your config file look like?

code ~/Library/Application\ Support/Claude/claude_desktop_config.json

@thenameless7741
Copy link

thenameless7741 commented Nov 26, 2024

Here's what works for me (mac):

TL;DR Try using an absolute path and specify the latest Python version in claude_desktop_config.json when configuring uvx.


Detailed version:

I followed the sqlite instructions but ran into a "Could not connect to MCP server sqlite" error.
After enabling developer mode, i checked to the log file through Developer (menu bar) → Open MCP Log File (mcp.log) and found this error "Could not start MCP server sqlite: Error: spawn uvx ENOENT".

The fix was to use an absolute path in claude_desktop_config.json, e.g.

> which uvx
/usr/local/Homebrew/bin/uvx

After restarting Claude, the "Attach from MCP" button still wasn't appearing next to "Upload files" button.
Checking mcp-server-sqlite.log (in the same directory as mcp.log), I saw this error:

No solution found when resolving tool dependencies:
Because the current Python version (3.9.1) does not satisfy Python>=3.10
(omitted)

Since i have a newer Python installed (via miniconda), I resolved this by passing an extra --python arg to uvx, using the absolute path to python binary.

My full JSON config file:

{
  "mcpServers": {
    "sqlite": {
      "command": "/usr/local/Homebrew/bin/uvx",
      "args": [
        "--python",
        "/usr/local/Homebrew/Caskroom/miniconda/base/bin/python3",
        "mcp-server-sqlite",
        "--db-path",
        "/Users/<user>/test.db"
      ]
    }
  }
}

@jspahrsummers
Copy link
Member

@thenameless7741 Just to check, are you on an Intel Mac? /usr/local/Homebrew isn't searched as part of the path right now, but that's something we could fix.

@jspahrsummers
Copy link
Member

jspahrsummers commented Nov 26, 2024

Sorry folks, and thanks for your patience! For npx calls in particular, we believe there's an issue with how Claude Desktop is launching subprocesses on Windows, which modelcontextprotocol/typescript-sdk#68 (once integrated) should hopefully fix. 🤞

As a workaround, you should be able to npm install -g the MCP servers you care about, and use node to invoke them directly (instead of npx).

@thenameless7741
Copy link

thenameless7741 commented Nov 26, 2024

@jspahrsummers I'm still using the old Homebrew setup on my M1 and haven't migrated over to the /opt directory yet. I suspect there are a few others out there in the same boat as me.

@oscarcalvo
Copy link

@jspahrsummers FYI, I'm using Windows. The memory server is installed globally, but it’s still not working. The closest I’ve gotten is with this config, which starts the server, but after 1 minute, Claude shows the same error: 'Couldn't attach...'

"mcpServers": {
"memory": {
"command": "mcp-server-memory",
"args": []
}
}

@rkaradas
Copy link

@oscarcalvo As @jspahrsummers mentioned, you have to use node directly, like this

{
	"mcpServers" : {
		"filesystem": {
			"command": "node",
			"args": [
			"C:\\Program Files\\nodejs\\node_modules\\@modelcontextprotocol\\server-filesystem\\dist\\index.js", 
			"C:\\"
			]
		}
	}
}

@oscarcalvo
Copy link

@rkaradas You are right, thanks

@timur-khakhalev
Copy link

Any ways to access mcp-server inside WSL?

I've tried this but no luck:

"command": "wsl",
            "args":
            [
                "bash",
                "-ic",
                "node /home/timur/dev/personal/mcp/mcp-server-jina/build/index.js"
            ],
"command": "node",
            "args":
            [
                "\\wsl.localhost\\Ubuntu-22\\home\\timur\\dev\\personal\\mcp\\mcp-server-jina\\build\\index.js"
            ],

@naif0s
Copy link
Author

naif0s commented Nov 26, 2024

@oscarcalvo As @jspahrsummers mentioned, you have to use node directly, like this

{
	"mcpServers" : {
		"filesystem": {
			"command": "node",
			"args": [
			"C:\\Program Files\\nodejs\\node_modules\\@modelcontextprotocol\\server-filesystem\\dist\\index.js", 
			"C:\\"
			]
		}
	}
}

THANKS YOU !!!!!!!

@evalstate
Copy link
Contributor

Since it's the only server you have configured, here's what I'd do (i've just tested this from scratch).

  • Rename your claude_desktop_config.json file to claude_desktop_config.old
  • Open PowerShell, and download the script from earlier to a folder
  • Run Set-ExecutionPolicy Bypass -Scope Process in powershell
  • Run .\mcp-install.ps1 @modelcontextprotocol/server-filesystem
  • Edit your claude_desktop_config.json folder and add the folders you want to use (don't forget to add a comma after the first argument).
  • Start Claude and enjoy.

If that still doesn't work, paste the content of the Logs folder in here.

@mchen-227
Copy link

image
Hm... may I doing something wrong?

Since it's the only server you have configured, here's what I'd do (i've just tested this from scratch).

  • Rename your claude_desktop_config.json file to claude_desktop_config.old
  • Open PowerShell, and download the script from earlier to a folder
  • Run Set-ExecutionPolicy Bypass -Scope Process in powershell
  • Run .\mcp-install.ps1 @modelcontextprotocol/server-filesystem
  • Edit your claude_desktop_config.json folder and add the folders you want to use (don't forget to add a comma after the first argument).
  • Start Claude and enjoy.

If that still doesn't work, paste the content of the Logs folder in here.

@evalstate
Copy link
Contributor

evalstate commented Dec 30, 2024

Sure, I wouldn't run that from system32.

From there I would:

  • cd ~ -> (takes you to home folder)
  • curl -o mcp-install.ps1 https://llmindset.co.uk/scripts/mcp-install.ps1 -> (downloads and save the install script to your home folder)
  • .\mcp-install.ps1 @modelcontextprotocol/server-filesystem -> (installs the server)

Once that's done, you can then edit the claude_desktop_config file to add the folders you want to use.

[EDITED - I messed up the curl command, sorry]

@evalstate
Copy link
Contributor

Edit bump

@mchen-227
Copy link

Sure, I wouldn't run that from system32.

From there I would:

  • cd ~ -> (takes you to home folder)
  • curl -o mcp-install.ps1 https://llmindset.co.uk/scripts/mcp-install.ps1 -> (downloads and save the install script to your home folder)
  • .\mcp-install.ps1 @modelcontextprotocol/server-filesystem -> (installs the server)

Once that's done, you can then edit the claude_desktop_config file to add the folders you want to use.

[EDITED - I messed up the curl command, sorry]

Thank you for your relentless efforts trying to help :))))...btw Happy 2025~~~
I tried what you've recommended, still no luck, here's the code, not sure i've done something wrong, apprecaite any insight you might have :)

Before I ran the Pwershell Script, I made sure i'm running from system64 tho it says system32 - reason why it's saying system32 is because "On bit64 Windows The folder C:\Windows\System32\ actually holds 64-bit system files - according to ChatGPT".....
I also made sure that the "claude_desktop_config.json" has been renamed to "claude_desktop_config.old".
Here comes the screenshots.....

image
At this point, a new "claude_desktop_config.json" file has been created in folder C:\Users\meizh\AppData\Roaming\Claude
I opened the json file and saw this script.
image
I opened Claude to see this error msg
image
Then I overrode the json script to below... saved and relaunched Claude...
image
Saw this error msg.... "Could not attach to MCP server server-filesystem"
image

Side question - it's been a hell of a workaround trying to add one MCP to Claude, is it going to be the same for all other MCP's? I'm also looking to add the Brave Search one....

@evalstate
Copy link
Contributor

OK - looks like its nearly there. Go in to settings, developer and click here to open the logs folder.
image

In there you should find a file called mcp-server-filesystem.log. Show us the contents of that.

For what it's worth, I got my server-filesystem to fail by specifying an invalid path on startup.

Side question:- once this issue is solved, you should be all set :)

@mchen-227
Copy link

mchen-227 commented Dec 31, 2024

OK - looks like its nearly there. Go in to settings, developer and click here to open the logs folder. image

In there you should find a file called mcp-server-filesystem.log. Show us the contents of that.

For what it's worth, I got my server-filesystem to fail by specifying an invalid path on startup.

Side question:- once this issue is solved, you should be all set :)

Exciting!!
here's what i have.. is it about the y arg?
image

image

@evalstate
Copy link
Contributor

evalstate commented Dec 31, 2024

OK - so the error message makes it look like Claude is reading a claude_desktop_config.json which still has a "-y" in the args section of the Config file... so perhaps there is more than one config file.

Can you re-check what is in the claude_desktop_config.json file by opening it from here:

image

That will open an explorer window with the file highlighted. Right-click, open in notepad or vscode and lets have a look what's in that specific one.

@mchen-227
Copy link

OK - so the error message makes it look like Claude is reading a claude_desktop_config.json which still has a "-y" in the args section of the Config file... so perhaps there is more than one config file.

Can you re-check what is in the claude_desktop_config.json file by opening it from here:

image

That will open an explorer window with the file highlighted. Right-click, open in notepad or vscode and lets have a look what's in that specific one.

Sure thing.
I clicked on "Edit Config" and was redicted to C:\Users\meizh\AppData\Roaming\Claude
I then opened "claude_desktop_config.json"
this is what i have (pretty sure i took the -y out):
image

@evalstate
Copy link
Contributor

🤔.

OK. Can you go back to the logs folder, delete all the files in there, restart Claude Desktop and then see what's there? Perhaps we are looking at a stale log file with the old config in.

Claude is still giving the error message, right?

:)

@mchen-227
Copy link

mchen-227 commented Dec 31, 2024

🤔.

OK. Can you go back to the logs folder, delete all the files in there, restart Claude Desktop and then see what's there? Perhaps we are looking at a stale log file with the old config in.

Claude is still giving the error message, right?

:)

Yep - still the same error.
okay - i deleted all files in "logs" folder and relaunched Claude same error
image
However now in the logs folder I only see 2 files?
image

@evalstate
Copy link
Contributor

Is there any content in either of them?

@mchen-227
Copy link

Is there any content in either of them?

yep
image
image

@evalstate
Copy link
Contributor

Cool. So we know that Node.js is installed and running.

The error message in the log file is saying it can't find the server-filesystem MCP Server code (which is odd because npm should have downloaded it earlier).

Let's check 2 things before going further:

Go back to powershell and run the following:

node --version

Should return v22.12.0

Then run: npm root -g

This will show us the download directory - it should come back c:\program files\nodejs\node_modules. I'm wondering if you are on a virtual desktop environment?

@mchen-227
Copy link

mchen-227 commented Dec 31, 2024

I'm not on a virtual machine but here's the result......did i install nodejs in the wrong folder..../?
image

@hemangjoshi37a
Copy link

hemangjoshi37a commented Jan 1, 2025

Just better idea is dont use node and use python instead for this MCP thing, it just works.

Never create any MCP server using node but use python instead

@mchen-227
Copy link

Just better idea is dont use node and use python instead for this MCP thing, it just works.

Never create any MCP server using node but use python instead

Hi... thank you for the solution.... I'm not sure how to use python to do this, have limited coding experience... i simpily followed an youtube video thinking it'd be easy.... sigh...

@BindingOx
Copy link

BindingOx commented Jan 1, 2025

I would like to add, for windows users, I fixed my issue by doing to following:

Completely Uninstalling:

How to Completely Remove Node.js from Windows ? - GeeksforGeeks

Installing node the right way

installing: install | npm Docs

Note

Don't use fnm method or winget, I have to change too many things when using MCPs
Don't use installer per the official docs
Node.js — Download Node.js®

We strongly recommend using a Node version manager to install Node.js and npm. We do not recommend using a Node installer, since the Node installation process installs npm in a directory with local permissions and can cause permissions errors when you run npm packages globally.

Or "Method 2" from: How to Install Node.js on Windows: Top 4 Methods

nvm install latest
nvm use ...
node -v

@evalstate
Copy link
Contributor

Check whether there is a @modelcontextprotocol folder under c:\users\meizh\appdata\roaming\npm\node_modules. If so change the path
under "args": it from "C:\\Program Files\\nodejs\\..." to c:\\users\\meizh\\AppData\\Roaming\\npm\\node_modules\\@modelcontextprotocol\\server-filesystem\\dist\\index.js.

and restart Claude

@mchen-227
Copy link

Check whether there is a @modelcontextprotocol folder under c:\users\meizh\appdata\roaming\npm\node_modules. If so change the path under "args": it from "C:\\Program Files\\nodejs\\..." to c:\\users\\meizh\\AppData\\Roaming\\npm\\node_modules\\@modelcontextprotocol\\server-filesystem\\dist\\index.js.

and restart Claude

hmmm... maybe that's the problem. I do not have the “@modelcontextprotocol" folder .....
image

@hemangjoshi37a
Copy link

Just better idea is dont use node and use python instead for this MCP thing, it just works.

Never create any MCP server using node but use python instead

Hi... thank you for the solution.... I'm not sure how to use python to do this, have limited coding experience... i simpily followed an youtube video thinking it'd be easy.... sigh...

First of all you are very beautiful. And python is actually very easy, in fact the easiest language out there, you can learn in a day or two.

@mchen-227
Copy link

mchen-227 commented Jan 1, 2025

Check whether there is a @modelcontextprotocol folder under c:\users\meizh\appdata\roaming\npm\node_modules. If so change the path under "args": it from "C:\\Program Files\\nodejs\\..." to c:\\users\\meizh\\AppData\\Roaming\\npm\\node_modules\\@modelcontextprotocol\\server-filesystem\\dist\\index.js.

and restart Claude

I GOT IT!!!! problem could be 3-fold

  1. I tried globally reinstall the library in PS.... npm install -g @modelcontextprotocol/server-filesystem
  2. For whatever reason, system is not liking the destination "C:\Users\meizh\Documents" so I recreated a new folder for Claude (tho this could very well not be the true issue but I recreated a folder anyway and updated that config.json file).
  3. I never "End Task” when closing out Claude, I normally just click on "File--> Exit". I tried to End Task in Task Manager this time around after updating json. Not sure if this has been an issue for everyone, but I've seen some people mention the same on YT.

Thank you for your relentless help!!!! HAPPY 2025 :)
image

@mchen-227
Copy link

Just better idea is dont use node and use python instead for this MCP thing, it just works.
Never create any MCP server using node but use python instead

Hi... thank you for the solution.... I'm not sure how to use python to do this, have limited coding experience... i simpily followed an youtube video thinking it'd be easy.... sigh...

First of all you are very beautiful. And python is actually very easy, in fact the easiest language out there, you can learn in a day or two.

thank you thank you! Yes I'm learning py, just not as quick haha, very little coding background, baby steps. Thanks for the help!

@mchen-227
Copy link

I would like to add, for windows users, I fixed my issue by doing to following:

Completely Uninstalling:

How to Completely Remove Node.js from Windows ? - GeeksforGeeks

Installing node the right way

installing: install | npm Docs

Note

Don't use fnm method or winget, I have to change too many things when using MCPs Don't use installer per the official docs Node.js — Download Node.js®

We strongly recommend using a Node version manager to install Node.js and npm. We do not recommend using a Node installer, since the Node installation process installs npm in a directory with local permissions and can cause permissions errors when you run npm packages globally.

Or "Method 2" from: How to Install Node.js on Windows: Top 4 Methods

nvm install latest
nvm use ...
node -v

Thanks for the solution. npm install did work. I was able to configure file system :)

@adi-prasetyo
Copy link

Just wanted to add my solution to this without uninstalling node or using nvm on windows:

Check where your node is

PS D:\Javascript\foldername> where.exe node
C:\Users\username\AppData\Local\fnm_multishells\13228_1736585930049\node.exe

claude_desktop_config.json

{
  "mcpServers": {
    "filesystem": {
      "command": "C:\\Users\\username\\AppData\\Local\\fnm_multishells\\13228_1736585930049\\npx.cmd",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "D:\\Javascript\\foldername"
      ],
      "env": {
        "PATH": "C:\\Users\\username\\AppData\\Local\\fnm_multishells\\13228_1736585930049;%PATH%",
        "NODE_PATH": "C:\\Users\\username\\AppData\\Local\\fnm_multishells\\13228_1736585930049\\node_modules"
      }
    }
  }
}

The key is to use absolute path for npx command, then adding env PATH and NODE_PATH

@mchen-227
Copy link

mchen-227 commented Jan 15, 2025 via email

@theScrod
Copy link

Check whether there is a @modelcontextprotocol folder under c:\users\meizh\appdata\roaming\npm\node_modules. If so change the path under "args": it from "C:\\Program Files\\nodejs\\..." to c:\\users\\meizh\\AppData\\Roaming\\npm\\node_modules\\@modelcontextprotocol\\server-filesystem\\dist\\index.js.
and restart Claude

I GOT IT!!!! problem could be 3-fold

  1. I tried globally reinstall the library in PS.... npm install -g @modelcontextprotocol/server-filesystem
  2. For whatever reason, system is not liking the destination "C:\Users\meizh\Documents" so I recreated a new folder for Claude (tho this could very well not be the true issue but I recreated a folder anyway and updated that config.json file).
  3. I never "End Task” when closing out Claude, I normally just click on "File--> Exit". I tried to End Task in Task Manager this time around after updating json. Not sure if this has been an issue for everyone, but I've seen some people mention the same on YT.

Thank you for your relentless help!!!! HAPPY 2025 :) image

This worked for me on Windows - needed to stop the Claude.exe task in task manager and then start the app again in order for it to really read and install the packages noted in my mcp config. Simply closing the app on windows and starting a new instance is not a full restart and does not seem to trigger a fresh look at the config, so trial and error adjustments there were not reflecting readily until I tried the full claude.exe process kill in task manager. Thanks for the tip!

@evalstate
Copy link
Contributor

ctrl+q on windows does a "proper" quit, to save anyone the bother of using task manager :)

wish someone had told me that earlier too.

@Ranteck
Copy link

Ranteck commented Mar 4, 2025

Sigue sucediendo lo mismo, lo solucione haciendo esto

{
  "mcpServers": {
    "MetaMCP": {
      "command": "C:\\Program Files\\nodejs\\node.exe",
      "args": [
        "C:\\Users\\{{user}}\\AppData\\Roaming\\npm\\node_modules\\@metamcp\\mcp-server-metamcp\\dist\\index.js",
        "-y"
      ],
      "env": {
        "METAMCP_API_KEY": "sk_mt_FVKm0K0sg5sZHrYi7IDNRK31MrwwobzmxMLxn3hK7Qkydfd6P1clrL0F7rX5ePFt",
        "METAMCP_API_BASE_URL": "http://localhost:12005"
      }
    }
  }
}

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