Featured image of post 在Windows(WSL2)上将MCP与Codex CLI配合使用

在Windows(WSL2)上将MCP与Codex CLI配合使用

在Windows(WSL2 Ubuntu 24.04)上使用Codex CLI连接到Roblox Studio的MCP(studio-rust-mcp-server)。

好的,请看简体中文翻译:

关于 Codex CLI 在 Windows 上仅支持 WSL2 的问题

目前,Codex CLI 在 Windows 上仅支持 WSL2。 因此,我上网查找并安装了 WSL2 的 Ubuntu 24.04 版本。 我还参考了下面的 deepwiki 链接来安装 Codex CLI。

https://deepwiki.com/openai/codex

以下是 deepwiki 上关于 Codex CLI 的 MCP 示例:

~/.codex/config.toml:

1
2
3
[mcp_servers.deepwiki]
command = "npx"
args = ["-y", "mcp-remote", "https://mcp.deepwiki.com/sse"]

从下一个本地 MCP 开始就无法正常工作了。

WSL2 镜像模式网络

自 Windows 11 22H2 版本起,引入了一种名为“镜像模式”的功能。

https://learn.microsoft.com/zh-cn/windows/wsl/networking#mirrored-mode-networking

使用此模式,无论是从 Windows 主机还是从 WSL2 的 Ubuntu 客户机,都可以连接到像 http://127.0.0.1:8000 这样的 URL。

设置方法如下

C:\Users\<user>\.wslconfig:

1
2
[wsl2]
networkingMode=mirrored

这样,基于网络的本地 MCP 就可以使用了。 以下是 Blender 的 Codex CLI 的 MCP 示例

~/.codex/config.toml:

1
2
3
[mcp_servers.blender]
command = "uvx"
args = ["blender-mcp"]

在 WSL2 上使用 stdio(标准输入/输出)的 MCP

我使用了一个名为 studio-rust-mcp-server 的 MCP 来操作 Roblox Studio。 我指定了 Windows 构建的可执行文件,但它无法正常工作。

在尝试了各种方法后,作为最后的手段,我在 Ubuntu 上进行了构建,结果成功了。 我已将使用方法写在了 README.md 文件中。

https://github.com/takoyakisoft/studio-rust-mcp-server-wsl2

~/.codex/config.toml:

1
2
3
[mcp_servers.roblox-studio]
command = "rbx-studio-mcp-linux"
args = ["--stdio"]

我放弃了使用 supergateway(它能将 MCP 的 stdio 转换为 SSE),因为它在与 Roblox Studio 连接时出现了错误。

附加内容:将 gpt-5-mini 设置为默认模型

虽然默认模型是 gpt-5,但 gpt-5-mini 也能很好地工作。

~/.codex/config.toml:

1
2
3
4
5
profile = "gpt-5-mini"

[profiles.gpt-5-mini]
model = "gpt-5-mini"
model_reasoning_effort = "high"
使用 Hugo 构建
主题 StackJimmy 设计