🐙

Windows(WSL2)でCodex CLIを使ってMCPを使う

に公開

Codex CLIがWindowsではWSL2しか対応してない問題

現在Codex CLIがWindowsではWSL2しかサポートしていません。
なのでWSL2のUbuntu 24.04をネットで調べてインストールします。
Codex CLIも以下のdeepwikiに聞いてインストールします。
https://deepwiki.com/openai/codex

以下はdeepwikiのCodex CLIのMCP例

~/.codex/config.toml
[mcp_servers.deepwiki]  
command = "npx"  
args = ["-y", "mcp-remote", "https://mcp.deepwiki.com/sse"]  

次のローカルMCPから動かなくなります。

WSL2ミラーモードのネットワーク

Windows11 22H2以降でミラーモードというのがあります。
https://learn.microsoft.com/ja-jp/windows/wsl/networking#mirrored-mode-networking

これを使うと http://127.0.0.1:8000 というURLにWindows側からでもWSL2のUbuntu側からでも接続できるようになります。

以下のように設定します。

C:¥Users¥<user>¥.wslconfig
[wsl2]
networkingMode=mirrored

これでネットワーク系のローカルMCPは使えるようになりました。
以下はblenderのCodex CLIのMCP例

~/.codex/config.toml
[mcp_servers.blender]  
command = "uvx"  
args = ["blender-mcp"]  

WSL2でstdio標準入出力のMCP

Roblox Studioを操作するstudio-rust-mcp-serverというMCPを使いました。
Windowsビルドの実行ファイルを指定したのですが、うまく動きませんでした。

色々試して最終手段でUbuntuでビルドしたところ動作しました。
使い方はREADME.mdに書きました。
https://github.com/takoyakisoft/studio-rust-mcp-server-wsl2

~/.codex/config.toml
[mcp_servers.roblox-studio]  
command = "rbx-studio-mcp-linux"  
args = ["--stdio"]  

MCPのstdioをsseに変換するsupergatewayはRoblox Studioとの接続でエラーが出たため諦めました。

おまけ、デフォルトをgpt-5-miniにする

gpt-5がデフォルトになっていますが、gpt-5-miniでも良く動作します。

~/.codex/config.toml
profile = "gpt-5-mini" 

[profiles.gpt-5-mini]
model = "gpt-5-mini"
model_reasoning_effort = "high"

私のサイトでの記事

サイト自体が検索結果にも表示されない😭
https://takoyakisoft.com/p/using_mcp_with_codex_cli_on_windows_wsl2/

Discussion