コンテンツにスキップ

【MCP】 VSCode でコマンド実行のセットアップが失敗する

背景

VSCode から MCP server を起動すると、npxやbunx、uvxなどのコマンドを見つけられずに失敗することがあった。実行ファイルの絶対パスを指定したところ起動できたので、その設定例を紹介する。

MCP server は、Playwright や Context7 などの外部ツールを LLM から呼び出せるようにするものだ。

問題

次のような設定で MCP server をセットアップしたところ、コマンドの実行が失敗した。

1
2
3
4
5
6
7
8
{
  "mcpServers": {
    "sequential-thinking": {
      "command": "bunx",
      "args": ["-y", "@modelcontextprotocol/server-sequential-thinking"]
    }
  }
}
VSCode MCP Server Error
Connection state: Error spawn bun ENOENT

対応

bunx や npx、uvx などを使ったセットアップがうまくできなかったが、次のようにバイナリのパスを直接指定することで解決できた。

commandの指定 結果
bunx(コマンド名のみ) Error spawn bun ENOENT
/home/user/.bun/bin/bun(絶対パスの例) セットアップに成功する
1
2
3
4
5
6
7
8
{
  "mcpServers": {
    "sequential-thinking": {
      "command": "/home/user/.bun/bin/bun",
      "args": ["x", "-y", "@modelcontextprotocol/server-sequential-thinking"]
    }
  }
}

/home/user/.bun/bin/bunは例なので、手元でcommand -v bunを実行して確認した絶対パスに置き換える。

参考