19
17

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Windows環境で強引にClaude CodeをMCPサーバー化してClaude Desktopから使う

Posted at

はじめに

この記事では、Windows環境でClaude CodeをMCPサーバーとして動かし、
Claude Desktopと接続するための手順を説明します。

注意事項

当記事の手順は、Claude公式が発表する手順とは異なります。
(その意味で、記事タイトル内で"強引に"と記載しました)

記事作成時点(2025/3/22)では、Windows環境でClaude CodeをMCPとして動かすための手順は公開されていませんが、今後公式から発表される可能性は高いため、
当記事の手順を実行する前に、公式ページにて最新情報のご確認をお願いします。

動作環境

  • Windows 11 Pro(24H2)
  • WSL2(Ubuntu 22.04.3 LTS)
  • Node.js 22.7

前提条件

  • WSL2が利用できること
  • Claude Desktopがインストールされていること

最終手順確認日

2025/03/22

手順の流れ

  1. WSLへのClaude Codeのインストール※
  2. PowerShellからClaude Codeを実行できることの確認
  3. Claude DesktopにMCP設定追加

※既にClaude Codeインストール済みの場合は、この手順は省略可

手順

1. WSLの起動

WSLのアイコンかわいいね

image.png

2. WSL上で、nvmのインストールコマンドを実行

※最新のnvmインストール手順は公式から確認

$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.2/install.sh | bash

3. WSL上で、nvm経由でNode.jsのインストール

$ nvm install 22.7

nvmコマンドの実行に失敗する場合
一度WSLを閉じて、再度WSLを開いてコマンドを実行してみてください。

Node.jsのインストールに失敗する場合
既にNode.jsがインストールされている場合、
Node.jsをアンインストールして、再実行すると成功するかもしれません。
(私の環境ではアンインストールが必要でした)

4. WSLにClaude Codeをインストール

$ npm install -g @anthropic-ai/claude-code

5. claudeコマンドの実行確認&Claude Codeのセットアップ

$ claude

Claude Codeのセットアップは下の記事を参考に実施

6. claudeコマンドの実行ファイルのフルパスを確認

下のコマンド実行結果をコピーしておく(次の手順で使用)

$ which claude

7. PowerShellを起動し、WSL上のclaude codeが実行できることの確認

wsl -e bash -l -c "source ~/.nvm/nvm.sh && [claudeの実行ファイルのフルパス]"

Claude Codeを起動出来たら、WSLとPowerShellを閉じて次の手順へ

8. Claude Desktopを開き、MCPサーバーの設定を追加

  1. Claude Desktopを開く
  2. 左上のハンバーガーメニュー > 「File」 > 「Settings」
  3. 「Developer」メニューを開き、「Edit Config」をクリック

image.png

image.png

9. テキストエディタでclaude_desktop_config.jsonを開く

image.png

9. claude_desktop_config.json にMCP設定を追加

PowerShellから動作確認した時のコマンドを参考に、以下の内容を設定

{
  "mcpServers": {
    "claude_code": {
      "command": "wsl",
      "args": [
        "-e",
        "bash",
        "-l",
        "-c",
        "source ~/.nvm/nvm.sh && [claudeの実行ファイルのフルパス] mcp serve"
      ],
      "env": {}
    }
  }
}

10. Claude Desktopを閉じる

  1. 設定画面を閉じる
  2. 左上のハンバーガーメニュー > 「File」 > 「Exit」

image.png

11. Claude Desktopを再度開き、Claude Codeと接続できていることを確認

チャット欄の右下にトンカチ?のマークが出ていれば成功です。

image.png

  1. 左上のハンバーガーメニュー > 「File」 > 「Settings」
  2. 「Developer」メニューを開き、接続状態を確認

「running」になっていればOK!

image.png

おわりに

これでWindowsでもClaude Codeが本格的に動かせるようになりました!
実際のClaude Code活用例についても、今後記事にしたいと思います。

ここまで読んで下さりありがとうございました。

参考リンク

19
17
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
19
17

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?