Run MCP servers in WSL

It seems the workaround for us Win11 + WSL users is to install Node on our Windows devices and prepend a cmd /c or /k to run it there.

I really don’t want to add anything to my Windows install, as everything else is nicely contained within the WSL instance.

Please can I request that, if the user is connected to WSL, that the MCP servers also run there!

8 Likes

@mwtj42 are you saying that if you insert:

Name: Browser tools
Type: Command
Command: cmd /c npx @agentdeskai/browser-tools-mcp or cmd /k npx @agentdeskai/browser-tools-mcp

You get a successful connection? I cannot, I am running WSL and Win11, I’d be happy with that result.

cmd /c npx -y @agentdeskai/[email protected]

is hit or miss, sometimes it works, and sometimes it doesn’t

I ran the required additional(?) server in my WSL instance
npx @agentdeskai/browser-tools-server

which suggested it had connected, but Agent died everytime it polled getNetwork - possibly due to the borked 0.46.4 update though…

Hopefully the UX will be ironed out soon for a smooth experience using MCP!

3 Likes

Whoa, that worked for me! Thanks! You have my vote.

The workaround is particularly inappropriate for the mcp-package-docs server, which will try to run python etc locally to look up docs, meaning that users will have to maintain having the same packages on both wsl and windows

1 Like

yeah, agree.

I want everything in WSL, please!

FINALLY figured this out:

wsl bash -c 'npx -y @agentdeskai/[email protected]

or

{
“mcpServers”: {
“browser-tools”: {
“command”: “wsl”,
“args”: [
“bash”,
“-c”,
“‘npx -y @agentdeskai/[email protected]’”
],
“enabled”: true
}
}
}

will launch the MCP server using WSL!

Thanks to the new Browsertools docs:

1 Like

My terminal opens and stay open after this last command and if I close them I get failed to create client

yeah, the open blank terminal is a known thing on Windows - I don’t think there’s a workaround yet.

so those working with wsl cannot use mcp?

WSL works ok with MCP - you can either run the server on your Win install using cmd /c , or directly in WSL setting that as your command in .json

However, either way will launch a blank terminal that has to remain open for each MCP server


any help on the command? I have been trying different ones proposed here in the forum but none seems to be working

You’ve used both approaches simultaneously!

wsl bash (server on WSL)

OR

cmd /c (server on Windows)

I am having difficulty working with MCP servers. For example, when analyzing web applications, I encounter an issue while taking screenshots and reading Word files. I receive the message:

“Your conversation is too long. Please try creating a new conversation or shortening your messages. Start new thread with Summary.”

In such cases, what should I do? Maybe my MCP server settings are incorrect. If anyone understands MCP server configurations, please help.

My JSON configuration is as follows:

{
  "mcpServers": {
    "puppeteer": {
      "command": "cmd",
      "args": [
        "/c",
        "npx",
        "-y",
        "@smithery/cli@latest",
        "run",
        "@smithery-ai/puppeteer"
      ]
    },
    "filesystem": {
      "command": "cmd",
      "args": [
        "/c",
        "npx",
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "C:"
      ]
    },
    "sequential-thinking": {
      "command": "cmd",
      "args": [
        "/c",
        "npx",
        "-y",
        "@modelcontextprotocol/server-sequential-thinking"
      ]
    },
    "brave-search": {
      "command": "cmd",
      "args": [
        "/c",
        "npx",
        "-y",
        "@smithery/cli@latest",
        "run",
        "@smithery-ai/brave-search",
        "--config",
        "{\"braveApiKey\":\"c4be44bf-957e-4706-aa50-808bbdb6cb23\"}" 
      ]
    }
  }
}

If anyone knows how to fix this issue, please let me know.

Hello mikececco,
Switching my default Node.js version from 14 to 18 fixed the issue, but it was still buggy. I had to restart the app multiple times and refresh the MCP server connection.
“nvm alias default 18”

i use wsl with zsh, should i change “bash” to “zsh”?

I use the same setup and no, you still use the “bash” command

I think I have finally solved the issue for my particular situation, I hope it helps others here.

I am using WSL and nvm and I eventually worked out that when Cursor calls WSL bash, the WSL bash instance has no knowledge of the current user’s nvm install, npx nor their profile

So first you should enter which npx at a wsl prompt to find out where npx is installed

You will also need to check where your .nvm setup folder is located as well

So the solution is to manually initialise nvm and also to use the full location paths:

{
  "mcpServers": {
    "browser-tools": {
      "command": "wsl",
      "args": [
        "bash",
        "-c",
        "'source /home/hyprgk/.nvm/nvm.sh && /home/hyprgk/.nvm/versions/node/v20.18.0/bin/npx -y @agentdeskai/[email protected]'"
      ],
      "enabled": true
    }
  }
}

Obviously you should replace “/home/hyprgk/” with your own home folder

1 Like

      "browser-tools": {
        "command": "cmd.exe",
        "args": [
          "/c",
          "npx -y @agentdeskai/[email protected]"
        ],
        "enabled": true
      },

Make sure to gitclone the mcp browser-tools and run the command in the pull directory “npx @agentdeskai/[email protected]” using the CMD as ADMIN.

you’ll have to navigate to the folder and run the command to make sure it will run

Then u install globally, make sure to have node installed globally in your computer, u run the command “npx @agentdeskai/[email protected]

Note: there are 2 differents comands to run, once you do this, you can go to your mcp.json and run the script for browser-tools

1 Like

Is this still working for you?