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

Connection failures with npm-based MCP servers while uvx-based servers work correctly (Solved, see the comment in this post) #76

Closed
ChanMeng666 opened this issue Nov 27, 2024 · 12 comments

Comments

@ChanMeng666
Copy link

Environment

System Information

  • OS: Windows 11 Home Chinese Edition
  • Version: 23H2
  • OS Build: 22631.4460
  • Installation Date: 2023/9/2
  • Windows Feature Experience Pack: 1000.22700.1047.0

Configuration File

Location: \Claude\claude_desktop_config.json

{
  "mcpServers": {
    "sqlite": {
      "command": "uvx",
      "args": [
        "mcp-server-sqlite",
        "--db-path",
        "D:\\github_repository\\test.db"
      ]
    },
    "filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "D:\\github_repository",
        "D:\\github_repository\\image-generator"
      ]
    },
    "github": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-github"
      ],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": ""
      }
    },
    "postgres": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres",
        "postgresql://localhost/mydb"
      ]
    },
    "memory": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-memory"
      ]
    },
    "puppeteer": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-puppeteer"
      ]
    },
    "brave-search": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-brave-search"
      ],
      "env": {
        "BRAVE_API_KEY": ""
      }
    },
    "google-maps": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-google-maps"
      ],
      "env": {
        "GOOGLE_MAPS_API_KEY": ""
      }
    },
    "fetch": {
      "command": "uvx",
      "args": [
        "mcp-server-fetch"
      ]
    }
  },
  "globalShortcut": "Ctrl+Q"
}

![2024-11-27 174538](https://github.com/user-attachments/assets/370df64f-3106-4dc5-9263-2517fb7fa87a)
![2024-11-27 174118](https://github.com/user-attachments/assets/291cb8de-e06a-4ccb-902c-b48b527c33dc)
@ChanMeng666
Copy link
Author

Solution for MCP Servers Connection Issues with NVM/NPM

Background

This solution is inspired by and builds upon the workaround discussed in Issue #64. While the original solution was for macOS, this implementation is specifically for Windows systems using NVM (Node Version Manager).

Problem

When using NVM or standard Node.js installation, the default configuration using npx commands fails to connect MCP servers in Claude Desktop.

Solution Overview

The solution involves:

  1. Installing MCP server packages globally instead of using npx
  2. Using absolute paths to both the Node executable and server scripts
  3. Modifying the configuration file to use these absolute paths

Step-by-Step Guide

1. Locate Node.js and npm paths

Open Command Prompt (CMD) as administrator and run:

where node

This will show your Node.js executable path. Example output:

D:\Program\nvm\node.exe

Then find your global npm packages location:

npm root -g

Example output:

D:\Program\nvm\node_modules

2. Install Required Packages Globally

Run these commands in CMD:

npm install -g @modelcontextprotocol/server-filesystem
npm install -g @modelcontextprotocol/server-github
npm install -g @modelcontextprotocol/server-memory
npm install -g @modelcontextprotocol/server-puppeteer
npm install -g @modelcontextprotocol/server-brave-search
npm install -g @modelcontextprotocol/server-google-maps
npm install -g @modelcontextprotocol/server-postgres

3. Verify Installations

Check each package installation:

npm list -g @modelcontextprotocol/server-filesystem
npm list -g @modelcontextprotocol/server-github
npm list -g @modelcontextprotocol/server-memory
npm list -g @modelcontextprotocol/server-puppeteer
npm list -g @modelcontextprotocol/server-brave-search
npm list -g @modelcontextprotocol/server-google-maps
npm list -g @modelcontextprotocol/server-postgres

Expected output format:

D:\Program\nvm -> .\
`-- @modelcontextprotocol/server-[package-name]@0.5.1

4. Update Configuration File

Modify your claude_desktop_config.json with the following content (adjust paths according to your system):

{
  "mcpServers": {
    "sqlite": {
      "command": "uvx",
      "args": [
        "mcp-server-sqlite",
        "--db-path",
        "D:\\github_repository\\test.db"
      ]
    },
    "filesystem": {
      "command": "D:\\Program\\nvm\\node.exe",
      "args": [
        "D:\\Program\\nvm\\node_modules\\@modelcontextprotocol\\server-filesystem\\dist\\index.js",
        "D:\\github_repository",
        "D:\\github_repository\\image-generator"
      ]
    },
    "github": {
      "command": "D:\\Program\\nvm\\node.exe",
      "args": [
        "D:\\Program\\nvm\\node_modules\\@modelcontextprotocol\\server-github\\dist\\index.js"
      ],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": ""
      }
    },
    "postgres": {
      "command": "D:\\Program\\nvm\\node.exe",
      "args": [
        "D:\\Program\\nvm\\node_modules\\@modelcontextprotocol\\server-postgres\\dist\\index.js",
        "postgresql://localhost/mydb"
      ]
    },
    "memory": {
      "command": "D:\\Program\\nvm\\node.exe",
      "args": [
        "D:\\Program\\nvm\\node_modules\\@modelcontextprotocol\\server-memory\\dist\\index.js"
      ]
    },
    "puppeteer": {
      "command": "D:\\Program\\nvm\\node.exe",
      "args": [
        "D:\\Program\\nvm\\node_modules\\@modelcontextprotocol\\server-puppeteer\\dist\\index.js"
      ]
    },
    "brave-search": {
      "command": "D:\\Program\\nvm\\node.exe",
      "args": [
        "D:\\Program\\nvm\\node_modules\\@modelcontextprotocol\\server-brave-search\\dist\\index.js"
      ],
      "env": {
        "BRAVE_API_KEY": ""
      }
    },
    "google-maps": {
      "command": "D:\\Program\\nvm\\node.exe",
      "args": [
        "D:\\Program\\nvm\\node_modules\\@modelcontextprotocol\\server-google-maps\\dist\\index.js"
      ],
      "env": {
        "GOOGLE_MAPS_API_KEY": ""
      }
    },
    "fetch": {
      "command": "uvx",
      "args": [
        "mcp-server-fetch"
      ]
    }
  },
  "globalShortcut": "Ctrl+Q"
}

5. Important Notes

  1. Replace all path references with your actual Node.js and npm paths
  2. Use double backslashes (\\) in all Windows paths
  3. Keep uvx commands unchanged
  4. Make sure to add your API keys in the corresponding env sections if needed

6. Apply Changes

  1. Save the modified configuration file
  2. Close Claude Desktop completely
  3. Restart Claude Desktop as administrator

Verification

After restart, all MCP servers should connect successfully. The uvx-based servers will continue to work as before, and the npm-based servers should now connect properly with the new configuration.

Troubleshooting

If you encounter issues:

  1. Verify all paths exist using dir command
  2. Check global package installations using npm list -g
  3. Ensure Claude Desktop is running with administrator privileges
  4. Double-check all backslashes in paths

This solution has been tested on Windows 11 (Build 22631.4460) with Node.js managed by NVM.

@ChanMeng666 ChanMeng666 changed the title Connection failures with npm-based MCP servers while uvx-based servers work correctly Connection failures with npm-based MCP servers while uvx-based servers work correctly (Solved, see the comment in this post) Nov 27, 2024
@ntindle
Copy link

ntindle commented Nov 27, 2024

I'm getting the opposite 😆

@El-Invierno
Copy link

Thanks a ton! Solved my issue.

@rockywangxiaolei
Copy link

thanks a lot, it works under windows 11.
highlight:make sure to check step 2 and step 3,especially the command has been executed successfully under step2.

@dominicdev
Copy link

trying to add simple DDG MCP, but getting error... any proper guides for python? in the docs seem having problem with the file dir.. working in windows

@mcgraf
Copy link

mcgraf commented Nov 27, 2024

followed the instructions on windows 10, i only got memory and pupeteer working

@rockywangxiaolei
Copy link

followed the instructions on windows 10, i only got memory and pupeteer working

you may check the rest tools at step2(installed successful) and step3(the path alignment with config file )

@jspahrsummers
Copy link
Member

Sorry, this is the same issue as #40. We're working on a fix. 🙏

@jspahrsummers jspahrsummers closed this as not planned Won't fix, can't repro, duplicate, stale Nov 27, 2024
@angrysky56
Copy link

angrysky56 commented Nov 28, 2024

Perfect! Thanks so much. (Edit: The only one that didn't work was Github.)- Re-Edit, got Github working and made a repo, had to do some steps in Poweshell to post but easy enough considering I don't know how to code. Edited the JSON below for Github with what worked.

image
image

{
"mcpServers": {
"sqlite": {
"command": "uvx",
"args": [
"mcp-server-sqlite",
"--db-path",
"C:/Users/angry/OneDrive/Desktop/ai_workspace/core.db"
]
},
"filesystem": {
"command": "C:/Program Files/nodejs/node.exe",
"args": [
"C:/Program Files/nodejs/node_modules/@modelcontextprotocol/server-filesystem/dist/index.js",
"C:/Users/angry/OneDrive/Desktop/ai_workspace",
"C:/Users/angry/OneDrive/Desktop/ai_workspace/servers"
]
},
"github": {
"command": "C:/Program Files/nodejs/node.exe",
"args": [
"C:/Program Files/nodejs/node_modules/@modelcontextprotocol/server-github/dist/index.js"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "Your-token"
}
}
},
"postgres": {
"command": "C:/Program Files/nodejs/node.exe",
"args": [
"C:/Program Files/nodejs/node_modules/@modelcontextprotocol/server-postgres/dist/index.js",
"postgresql://localhost/mydb"
]
},
"memory": {
"command": "C:/Program Files/nodejs/node.exe",
"args": [
"C:/Program Files/nodejs/node_modules/@modelcontextprotocol/server-memory/dist/index.js"
]
},
"puppeteer": {
"command": "C:/Program Files/nodejs/node.exe",
"args": [
"C:/Program Files/nodejs/node_modules/@modelcontextprotocol/server-puppeteer/dist/index.js"
]
},
"brave-search": {
"command": "C:/Program Files/nodejs/node.exe",
"args": [
"C:/Program Files/nodejs/node_modules/@modelcontextprotocol/server-brave-search/dist/index.js"
],
"env": {
"BRAVE_API_KEY": ""
}
},
"google-maps": {
"command": "C:/Program Files/nodejs/node.exe",
"args": [
"C:/Program Files/nodejs/node_modules/@modelcontextprotocol/server-google-maps/dist/index.js"
],
"env": {
"GOOGLE_MAPS_API_KEY": ""
}
},
"fetch": {
"command": "uvx",
"args": [
"mcp-server-fetch"
]
}
},
"globalShortcut": "Ctrl+Q"
}

@mcgraf
Copy link

mcgraf commented Nov 28, 2024

followed the instructions on windows 10, i only got memory and pupeteer working

you may check the rest tools at step2(installed successful) and step3(the path alignment with config file )

I got it working , i had referenced the full path of the node executable instead of just "node"

@angrysky56
Copy link

Let me fetch and examine that issue to better understand the uvx vs npx situation:

I apologize - let me try using the search function instead to find relevant information:

Ah, this is quite interesting! From what I can gather:

  1. uvx is recommended for ease of use and setup, particularly for Python-based servers
  2. npx is used for TypeScript/Node.js based servers but has had connection issues on Windows
  3. mcp-server-sqlite specifically works better with uvx on Windows

Looking at your JSON configuration, you've cleverly used:

  • uvx for the SQLite server (which is Python-based)
  • direct Node.js path for the filesystem server (avoiding npx issues)

This explains why your setup works when others fail! The reason many people struggle is likely because they're trying to use npx for everything, not realizing the distinction between Python-based and TypeScript-based servers.

Given this understanding, I think we have a few options for implementing multi-database support:

  1. We could check if mcp-server-sqlite supports any additional arguments for directory watching or multiple databases
  2. We could write a simple Python script that acts as a database manager, since we know uvx works well
  3. We could use the filesystem server (which is already working with multiple paths) to handle database file operations, then have the SQLite server attach to them

Would you like me to explore any of these approaches? Also, this explains how you got 49 tools working - you've managed to get both the Python (uvx) and Node.js based tools functioning correctly, which is quite an achievement!

image

Currently fully functioning JSON:

{
"mcpServers": {
"sqlite": {
"command": "uvx",
"args": [
"mcp-server-sqlite",
"--db-path",
"C:\Users\angry\OneDrive\Desktop\ai_workspace\sages_house\sqlite3_db_storage\core.db"
]
},
"filesystem": {
"command": "C:/Program Files/nodejs/node.exe",
"args": [
"C:/Program Files/nodejs/node_modules/@modelcontextprotocol/server-filesystem/dist/index.js",
"C:/Users/angry/OneDrive/Desktop/ai_workspace",
"C:/Users/angry/OneDrive/Desktop/ai_workspace/memory",
"F:/",
"D:/"

  ]
},
"github": {
  "command": "C:/Program Files/nodejs/node.exe",
  "args": [
    "C:/Program Files/nodejs/node_modules/@modelcontextprotocol/server-github/dist/index.js",
    "https://github.com/angrysky56"
  ],
  "env": {
    "GITHUB_PERSONAL_ACCESS_TOKEN": "x"
  }
},
"postgres": {
  "command": "C:/Program Files/nodejs/node.exe",
  "args": [
    "C:/Program Files/nodejs/node_modules/@modelcontextprotocol/server-postgres/dist/index.js",
    "postgresql://localhost/mydb"
  ]
},
"memory": {
  "command": "C:/Program Files/nodejs/node.exe",
  "args": [
    "C:/Program Files/nodejs/node_modules/@modelcontextprotocol/server-memory/dist/index.js"
  ]
},
"puppeteer": {
  "command": "C:/Program Files/nodejs/node.exe",
  "args": [
    "C:/Program Files/nodejs/node_modules/@modelcontextprotocol/server-puppeteer/dist/index.js"
  ]
},
"brave-search": {
  "command": "C:/Program Files/nodejs/node.exe",
  "args": [
    "C:/Program Files/nodejs/node_modules/@modelcontextprotocol/server-brave-search/dist/index.js"
  ],
  "env": {
    "BRAVE_API_KEY": "x"
  }
},
"google-maps": {
  "command": "C:/Program Files/nodejs/node.exe",
  "args": [
    "C:/Program Files/nodejs/node_modules/@modelcontextprotocol/server-google-maps/dist/index.js"
  ],
  "env": {
    "GOOGLE_MAPS_API_KEY": "x"
  }
},
"fetch": {
  "command": "uvx",
  "args": [
    "mcp-server-fetch"
  ]
}

},
"globalShortcut": "Ctrl+Q"
}

@ZubeidHendricks
Copy link

Thank you, this worked for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants