Skip to content

Instantly share code, notes, and snippets.

@feveromo
Last active January 9, 2025 03:01
Show Gist options
  • Save feveromo/7a340d7795fca1ccd535a5802b976e1f to your computer and use it in GitHub Desktop.
Save feveromo/7a340d7795fca1ccd535a5802b976e1f to your computer and use it in GitHub Desktop.
MCP-Windows

Setting Up MCP Servers on Windows

A step-by-step guide to setting up Model Context Protocol (MCP) servers for Claude Desktop on Windows.

Prerequisites

  1. Install Node.js (v18.x or later)

    • Download from: https://nodejs.org/
    • Verify installation by opening Command Prompt (CMD) and running:
      node --version
      npm --version
      where node
      npm root -g
    • Note down the paths returned by the last two commands - you'll need them later
  2. Install Python 3.10 or later (for Python-based servers)

Installation Steps

1. Install Package Managers

Open Command Prompt (CMD) as administrator and run:

# For Python-based servers
npm install -g uv

2. Install MCP Servers

You have multiple options for installing and configuring servers:

Option A: Global NPM Installation (Recommended for getting started)

# Install core servers globally
npm install -g @modelcontextprotocol/server-filesystem
npm install -g @modelcontextprotocol/server-memory
npm install -g @modelcontextprotocol/server-brave-search

Option B: Using NPX (Alternative for package-managed servers)

Some servers can be run directly through npx without global installation:

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

Option C: Local Development Setup

For locally developed or modified servers, point directly to their dist files:

{
  "mcpServers": {
    "sequential-thinking": {
      "command": "node",
      "args": ["C:\\Users\\YourUsername\\Dev\\servers\\src\\sequentialthinking\\dist\\index.js"],
      "env": {
        "DEBUG": "*"
      }
    }
  }
}

Python-based Servers

Some MCP servers are Python-based and require different installation steps. Here's how to set them up:

Fetch Server

# Install the fetch server using pip
pip install mcp-server-fetch

# Configure in claude_desktop_config.json:
{
  "mcpServers": {
    "fetch": {
      "command": "python",
      "args": [
        "-m",
        "mcp_server_fetch"
      ],
      "env": {
        "DEBUG": "*"
      }
    }
  }
}

The fetch server provides web content fetching capabilities and converts HTML to markdown for easier consumption by LLMs. It requires Python 3.10 or later.

3. Configure Claude Desktop

  1. Navigate to: %AppData%\Claude Desktop\
  2. Create or edit claude_desktop_config.json
  3. Use this configuration structure (replace paths with your actual Node.js and npm paths):
{
  "globalShortcut": "Ctrl+Space",
  "mcpServers": {
    "sqlite": {
      "command": "uvx",
      "args": ["mcp-server-sqlite", "--db-path", "C:\\Users\\YourUsername\\test.db"]
    },
    "filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "C:\\Users\\YourUsername\\Downloads",
        "C:\\Users\\YourUsername\\Documents",
        "C:\\Users\\YourUsername\\Desktop"
      ],
      "env": {
        "DEBUG": "*"
      }
    },
    "memory": {
      "command": "C:\\Program Files\\nodejs\\node.exe",
      "args": [
        "C:\\Users\\YourUsername\\AppData\\Roaming\\npm\\node_modules\\@modelcontextprotocol\\server-memory\\dist\\index.js"
      ],
      "env": {
        "DEBUG": "*"
      }
    },
    "mcp-installer": {
      "command": "npx",
      "args": [
        "@anaisbetts/mcp-installer"
      ]
    }
  }
}

Important Notes:

  • Replace YourUsername with your Windows username
  • For npx-based installations, the -y flag automatically accepts installation prompts
  • Local development paths should point to the compiled dist/index.js files
  • The DEBUG environment variable helps with troubleshooting
  • You can mix and match installation methods based on your needs:
    • Use npx for quick testing or occasional use
    • Use global installations for better performance
    • Use local paths for development or customized versions

Verification & Troubleshooting

Verify Installations

# List installed packages
npm list -g --depth=0

# Test individual servers directly
node C:\Users\YourUsername\AppData\Roaming\npm\node_modules\@modelcontextprotocol\server-memory\dist\index.js

Common Issues

  1. "Could not attach to MCP server"

    • Verify all paths in config match your system exactly
    • Make sure all packages are installed globally (-g flag)
    • Test servers directly using the node command as shown above
    • Run Claude Desktop as administrator
  2. PowerShell Security Errors

    • Use Command Prompt (CMD) instead
    • Or run Set-ExecutionPolicy RemoteSigned -Scope CurrentUser in PowerShell as admin
  3. Server not showing in Claude

    • Ensure you have Claude Desktop Pro subscription
    • Make sure you have the latest Claude Desktop version
    • Look for the MCP icon in the interface
    • Restart Claude Desktop after configuration changes
    • Verify JSON syntax in config file

Tips

  • Always use global installations (npm install -g)
  • Use absolute paths to both Node.js and server files
  • Keep DEBUG env variable for troubleshooting
  • Restart Claude Desktop after config changes
  • Run Claude Desktop as administrator when testing new configurations
@Caldis
Copy link

Caldis commented Nov 27, 2024

save my day, thanks

@t851029v2
Copy link

many thanks!

@AndrewDonelson
Copy link

AndrewDonelson commented Nov 29, 2024

I have done and verified everything here. I think its because I dont have the Plugin Icon next to chat or a developer tab in my Claude Desktop. Why? I have been pro account for at least 6 months. I have the icon for 2 experimental features enabled. Thats it.

update
I guess i was running old Claude Desktop (that i was opening). Reinstalled and now its opening the node windows for each MCP server. But after about 30 seconds Claude Desktop tells me "Could not attach to MCP {XXXX}" for each.

Screenshot of all relevant info:

Claude_MCP_Issues

@uforiaio
Copy link

uforiaio commented Nov 29, 2024

You sir are an officer and a gentleman! I had a pretty good idea of the problem, but you pinpointed it. Thank you so much!! :)

Planned on spending a few hours on this today, and you just saved me a lot of time!

If you want to test if it will work, just run this with whatever module. If it doesn't load, check your environmental variables or the path, if you are not sure, run an npm install -g uv and copy the output.

To test it before going any further, I ran powershell as an admin and tested each module:

node C:\Users\yourname\AppData\Roaming\npm\node_modules\@modelcontextprotocol\server-memory\dist\index.js

Depending on how many versions of nodejs you are running, it may be best to just use the absolute path, but ymmv.

Thanks!!!

@sumankwan
Copy link

I have done and verified everything here. I think its because I dont have the Plugin Icon next to chat or a developer tab in my Claude Desktop. Why? I have been pro account for at least 6 months. I have the icon for 2 experimental features enabled. Thats it.

update I guess i was running old Claude Desktop (that i was opening). Reinstalled and now its opening the node windows for each MCP server. But after about 30 seconds Claude Desktop tells me "Could not attach to MCP {XXXX}" for each.

Screenshot of all relevant info:

Claude_MCP_Issues

same issue with mine, any update? thanks

@uforiaio
Copy link

Ask Claude to help you through it, I ran into several issues with a few of the MCP servers. It helped me with formatting and fixing them. The humor is not lost on me ... :)

@BESTProduction
Copy link

Can you help me how to add a filesystem here?

@RaptorX
Copy link

RaptorX commented Dec 1, 2024

Open PowerShell as administrator and run...

In Windows 11 Powershell has certain restrictions and when trying to do this step i get this error/warning:

image

Using CMD instead or bypassing the security exception fixes the issue.

I noticed that follwing this thread instead: modelcontextprotocol/servers#75 (comment)
was working for me and then noticed that he instructed to use CMD instead of PowerShell

Maybe this document should be updated to add that warning or add a work around for people encountering this issue.

@us254
Copy link

us254 commented Dec 13, 2024

the discussion from the GitHub issue "How to configure windows filesystem?" (modelcontextprotocol/servers#75) and a guide based on the information shared there.

Recap of the Core Problem

The main issue is the difficulty in connecting MCP servers, particularly the filesystem server, to Claude Desktop on Windows. encountering the "Could not attach to MCP server" error message.

Solution from @ChanMeng666

  1. Global Installation: Instead of using npx (which runs packages without installing them), install all MCP server packages globally using npm install -g. This ensures they are readily available.
  2. Absolute Paths: Use full, absolute paths to both the node.exe executable and the server's index.js file within the claude_desktop_config.json configuration. This eliminates ambiguity about where the files are located.
  3. Administrator Rights: Run Claude Desktop as an administrator to ensure it has the necessary permissions to access files and run servers.

**Detailed Step-by-Step Guide **

1. Prerequisites

  • Node.js and npm:

    • Download and install the latest LTS version of Node.js from https://nodejs.org/.
    • Verification: Open Command Prompt (CMD) as an administrator and run:
      node --version
      npm --version
      where node
      npm root -g
    • Important: Note down the paths returned by where node (e.g., D:\Program\nvm\node.exe) and npm root -g (e.g., D:\Program\nvm\node_modules). You'll need these for the configuration later.
  • Python 3.10+ (for Python-based servers like mcp-server-fetch):

2. Install MCP Servers Globally

  • Open Command Prompt (CMD) as an administrator.

  • Run the following commands to install the necessary server packages globally:

    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
    npm install -g @modelcontextprotocol/server-gdrive

    These commands will install the servers globally on your system.

3. Install Python-Based Servers
If you intend to use any of the Python-based servers, you should install them with pip. For example, to install the fetch server:

  • Open Command Prompt (CMD) as an administrator.

  • Run the following commands to install the mcp-server-fetch package:

    pip install mcp-server-fetch

4. Verify Installation

  • In the same administrator CMD window, run the following commands to check if the packages were installed correctly:

    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
    npm list -g @modelcontextprotocol/server-gdrive
  • You should see output similar to this (the version numbers might be different):

    D:\Program\nvm\node_modules
    `-- @modelcontextprotocol/[email protected]
    

5. Configure Claude Desktop

  • Locate Configuration File:

    • Go to %AppData%\Claude Desktop\ (paste this into the Windows Explorer address bar).
  • Edit claude_desktop_config.json:

    • Create this file if it doesn't exist.
    • Open it in a text editor (like Notepad++ or VS Code).
  • Configuration Content:

    • Carefully adapt the following configuration to your system.
    • Replace the example paths with the actual paths you obtained in Step 1.
    • Use double backslashes \\ in all Windows paths.
    • Add API keys to the env sections if needed (e.g., for brave-search, google-maps, and github).
    • Add the folders that you want to be available for the Claude model in the filesystem server args section.
    {
      "mcpServers": {
        "sqlite": {
          "command": "uvx",
          "args": [
            "mcp-server-sqlite",
            "--db-path",
            "D:\\Your\\Path\\To\\test.db"
          ]
        },
        "filesystem": {
          "command": "D:\\Program\\nvm\\node.exe",
          "args": [
            "D:\\Program\\nvm\\node_modules\\@modelcontextprotocol\\server-filesystem\\dist\\index.js",
            "D:\\Folder\\To\\Make\\Available",
            "D:\\Another\\Folder\\To\\Make\\Available"
          ]
        },
        "github": {
          "command": "D:\\Program\\nvm\\node.exe",
          "args": [
            "D:\\Program\\nvm\\node_modules\\@modelcontextprotocol\\server-github\\dist\\index.js"
          ],
          "env": {
            "GITHUB_PERSONAL_ACCESS_TOKEN": "your_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": "your_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": "your_google_maps_api_key"
          }
        },
        "gdrive": {
          "command": "D:\\Program\\nvm\\node.exe",
          "args": [
            "D:\\Program\\nvm\\node_modules\\@modelcontextprotocol\\server-gdrive\\dist\\index.js"
          ]
        },
        "fetch": {
          "command": "uvx",
          "args": [
            "mcp-server-fetch"
          ]
        }
      },
      "globalShortcut": "Ctrl+Q"
    }

6. Apply Changes and Restart

  • Save the claude_desktop_config.json file.
  • Completely close Claude Desktop.
  • Restart Claude Desktop as an administrator (right-click on the Claude Desktop icon and select "Run as administrator").

7. Verification and Troubleshooting

  • Check for the MCP Icon: After restarting, you should see the MCP icon in the Claude Desktop interface. This indicates that Claude is attempting to connect to the servers.
  • Enable Developer Mode (Optional but Recommended): In Claude Desktop, go to the menu (usually represented by three lines or dots) -> Help -> Enable Developer Mode. Then, in the Developer menu, you can open the MCP Log File to see more detailed information about the server connections.
  • Troubleshooting "Could not attach to MCP server":
    • Verify Paths: Double-check that all paths in your claude_desktop_config.json are exactly correct and use double backslashes (\\). Use the dir command in CMD to verify that the files and directories exist at those paths.

    • Check Server Logs: If you enabled Developer Mode, look at the MCP Log File for any error messages.

    • Test Servers Individually: Open a new CMD window as an administrator and try running each server directly using the node command and the path to the server's index.js file. For example:

      "D:\Program\nvm\node.exe" "D:\Program\nvm\node_modules\@modelcontextprotocol\server-memory\dist\index.js"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment