0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

WSL2 + VScode + MCP のコマンドがうまく通らないときの対処

Posted at

WSLでMCPを動かす際の設定

なにが起きているか

MCPの設定項目は大体下記のように node のパッケージを npx 越しに起動する形になります。

{
  "mcp": {
    "servers": {
      "playwright": {
        "command": "npx",
        "args": [
          "@playwright/mcp@latest"
        ]
      }
    }
  }
}

ただ、現在の設定では、Windows側のnpxが実行されます。(WSL内でvscodeを開いていてもこれは発生します)なので、基本的に WSL コマンド越しに npx をたたくことになるんですが、パスが Windows 環境のものが使用されるため、おそらくうまく動作しないと思います。WSLを使っている方は Windows環境にほとんどなにも入っていないと思いますので、、、

改善された設定案

ということで、改善案としてはとりあえずフルパスを指定しておけば問題ありません。
ただ、これ以外にも解決策はあると思うのでだれかいい方法があれば教えてください。

{
  "mcp": {
    "servers": {
      "filesystem": {
        "command": "wsl",
        "args": [
          "bash",
          "-c",
          "/usr/bin/npx -y @modelcontextprotocol/server-filesystem /src/projects/test"
        ]
      }
    }
  }
}
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?