Codex Mcp Tool

io.github.x51xxx由 GitHub 账号 x51xxx 发布v2.2.0更新于 Oct 24, 2026

MCP server bridging AI assistants to OpenAI Codex CLI for code analysis and review

概览

AI 生成的概览

将 AI 助手连接到 OpenAI Codex CLI,使其能在本地分析代码、进行多轮会话、审查改动并生成图片。

可以做什么
用 @ 语法引用文件或目录,分析并解释代码,可指定模型、推理强度和会话,也可批量执行多个 Codex 任务或运行原生改动审查。执行任务后用 shell 命令验证并自动重试修复,还能输出结构化的 OLD/NEW 补丁用于重构。通过 Codex 内置图片工具生成或编辑图片,并保存到指定路径。用结构化创意框架进行头脑风暴。查看会话、技能、CLI 健康状况、版本与连接状态,并读取缓存的改动模式分块。
适用场景
适合已在使用 Codex CLI、希望让 Claude 或 Cursor 等助手把代码分析、重构、审查或“执行—验证—修复”循环交给它完成的场景,也可搭配本地 Ollama 或 LM Studio 模型。同样适合借助同一 Codex 登录进行图片生成和结构化头脑风暴。
运行要求
通过 npx 以 stdio 在本地运行,需要 Node.js 18+,并已安装且登录 Codex CLI(0.95.0 或更新版本)。可选环境变量 CODEX_MAX_SESSIONS、CODEX_MCP_CWD、CODEX_SESSION_TTL_MS 用于调整会话与工作目录;使用本地模型需运行 Ollama 或 LM Studio。仅支持桌面客户端。
安装前请注意
Codex 可以写入文件并执行 shell 命令:沙箱与审批设置、addDirs 和 overwrite 等选项决定其可改动范围,使用前应确认。图片生成使用你的 ChatGPT 登录并写入磁盘,未设置 overwrite 时会保留已有文件。提示词和引用的代码会发送给所配置的模型提供方,若选择本地提供方则发送到本地。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Codex Mcp Tool,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

Codex MCP Server

MCP server connecting Claude/Cursor to Codex CLI. Enables code analysis via @ file references, multi-turn conversations, sandboxed edits, and structured change mode.

Features

  • File Analysis — Reference files with @src/, @package.json syntax
  • Multi-Turn Sessions — Conversation continuity with workspace isolation
  • Native Resume — Uses codex resume for context preservation (CLI v0.36.0+)
  • Local OSS Models — Run with Ollama or LM Studio via localProvider
  • Web Search — Research capabilities with search: true
  • Sandbox Mode — Safe automation with explicit sandbox and approval policies
  • Change Mode — Structured OLD/NEW patch output for refactoring
  • Brainstorming — SCAMPER, design-thinking, lateral thinking frameworks
  • Health Diagnostics — CLI version, features, and session monitoring
  • Cross-Platform — Windows, macOS, Linux fully supported

Quick Start

bash
claude mcp add codex-cli -- npx -y @trishchuk/codex-mcp-tool

Prerequisites: Node.js 18+, Codex CLI installed and authenticated.

Configuration

json
{  "mcpServers": {    "codex-cli": {      "command": "npx",      "args": ["-y", "@trishchuk/codex-mcp-tool"]    }  }}

Config locations: macOS: ~/Library/Application Support/Claude/claude_desktop_config.json | Windows: %APPDATA%\Claude\claude_desktop_config.json

Usage Examples

javascript
// File analysis'explain the architecture of @src/';'analyze @package.json and list dependencies';
// With specific model'use codex with model gpt-5.6-sol to analyze @algorithm.py';
// Multi-turn conversations (v1.4.0+)'ask codex sessionId:"my-project" prompt:"explain @src/"';'ask codex sessionId:"my-project" prompt:"now add error handling"';
// Brainstorming'brainstorm ways to optimize CI/CD using SCAMPER method';
// Sandbox mode'use codex sandbox:true to create and run a Python script';
// Web search'ask codex search:true prompt:"latest TypeScript 5.7 features"';
// Local OSS model (Ollama)'ask codex localProvider:"ollama" model:"qwen3:8b" prompt:"explain @src/"';

Tools

ToolDescription
ask-codexExecute Codex CLI with files, models, sessions, and safety controls
batch-codexRun multiple atomic Codex tasks sequentially or concurrently
review-changesRun the native non-interactive Codex review command
do-actExecute, verify with a shell command, and retry fixes
image-genGenerate or edit images with Codex's built-in image_gen tool
brainstormGenerate ideas with structured creative frameworks
list-sessionsView, delete, or clear MCP conversation mappings
list-skillsList skills visible from the selected workspace
healthDiagnose CLI installation, version, features, and sessions
fetch-chunkRetrieve a chunk from cached change-mode output
pingTest the MCP connection
helpReturn current codex --help output
versionReport Codex CLI, Node.js, platform, and package versions
timeout-testExercise keepalive and timeout behavior

Image generation

image-gen drives Codex's built-in image_gen tool, so it uses your ChatGPT login and needs no OPENAI_API_KEY. That tool only accepts a prompt and reference image paths: Codex picks the image model and pixel size, and there are no size, quality, format or mask arguments. image-gen therefore puts all steering into a structured prompt (use case, asset type, style, composition, exact text, reference roles, edit invariants, aspect ratio, presets) and tells the Codex host model to relay it instead of improvising.

javascript
// New image, 16:9, exact Cyrillic headline, copied into the project'image-gen prompt:"YouTube cover about AI coding agents" aspect:"wide" text:"АГЕНТИ БЕЗ ХАОСУ" presets:["thumbnail","exact-text"] outputPath:"assets/cover.png"';
// Edit: change only the headline, keep everything else'image-gen editImage:"assets/cover.png" prompt:"Replace the headline text" text:"ЧАСТИНА 2" preserve:["people and background"] outputPath:"assets/cover.png"';

Images are saved by Codex under $CODEX_HOME/generated_images/<thread>/ and copied to outputPath when given; an existing file is kept and the copy is written as a -v2 sibling unless overwrite: true. The result reports each file's dimensions and alpha channel, so a transparentBackground request that came back opaque is flagged.

Models

By default the model parameter is omitted and Codex CLI applies the default model from your ~/.codex/config.toml (for example model = "gpt-6.1-sol"). Pass model only when you need to override the configured default for a single call. Reasoning depth is calibrated per tool:

  • ask-codex — uses the Codex CLI default reasoning (medium). Increase it only when the task needs more planning or checking.
  • brainstorm, do-act, review-changes — default reasoningEffort: "high" (creative ideation, act-check-fix loops, and code review benefit from deeper reasoning).
ModelRecommendation
gpt-6.1-solLatest workhorse for coding and everyday work (CLI 0.159+)
gpt-6-astraFrontier intelligence for the most demanding work
gpt-6-solPrevious-generation workhorse
gpt-6-lunaFast and affordable; easier, repeatable tasks
gpt-5.6-solOlder-generation workhorse
gpt-5.6-terraOlder balanced model for straightforward work
gpt-5.6-lunaOlder fast, efficient model
gpt-5.5Legacy — Codex steers callers to gpt-5.6-sol

Sol, Astra and Terra models expose max and ultra reasoning; Luna models top out at max, and gpt-5.5 at xhigh. ultra may delegate work to subagents; most tasks should remain on medium or high. Pass a concrete slug — the bare moving aliases gpt-6 and gpt-5.6 are rejected by the API. gpt-6.1-sol is rejected by Codex CLI 0.157.x with the same 400 an unknown slug gets; upgrade with npm install -g @openai/codex@latest.

Key Features

Session Management (v1.4.0+)

Multi-turn conversations with workspace isolation:

javascript
{ "prompt": "analyze code", "sessionId": "my-session" }{ "prompt": "continue from here", "sessionId": "my-session" }{ "prompt": "start fresh", "sessionId": "my-session", "resetSession": true }

Environment:

  • CODEX_SESSION_TTL_MS - Session TTL (default: 24h)
  • CODEX_MAX_SESSIONS - Max sessions (default: 50)

Codex CLI version

Requires Codex CLI 0.95.0 or newer. On older versions the server fails with an explicit upgrade message rather than silently dropping unsupported flags. Upgrade with npm install -g @openai/codex@latest; run the health tool to see the detected version.

Troubleshooting: "codex not found"

MCP clients launched from a GUI (Dock, Finder, Start menu) inherit a minimal PATH that excludes Homebrew, nvm, and volta directories, so codex may work from a terminal but not from the app. The server searches those locations automatically; if it still cannot find the CLI, pin it explicitly:

json
{ "env": { "CODEX_CLI_PATH": "/opt/homebrew/bin/codex" } }

Find the value with which codex. Run the health tool to see which executable was resolved and how.

Local OSS Models (v1.6.0+)

Run with local Ollama or LM Studio instead of OpenAI:

javascript
// Ollama{ "prompt": "analyze @src/", "localProvider": "ollama", "model": "qwen3:8b" }
// LM Studio{ "prompt": "analyze @src/", "localProvider": "lmstudio", "model": "my-model" }
// Auto-select provider{ "prompt": "analyze @src/", "oss": true }

Requirements: Ollama running locally with a model that supports tool calling (e.g. qwen3:8b).

Advanced Options

ParameterDescription
modelModel selection
sessionIdEnable conversation continuity
sandboxCompatibility automation: workspace-write + never
searchEnable web search
changeModeStructured OLD/NEW edits
addDirsAdditional writable directories
toolOutputTokenLimitCap response verbosity (100-10,000)
reasoningEffortlow, medium, high, xhigh, max, ultra
ossUse local OSS model provider
localProviderLocal provider: lmstudio or ollama
strictConfigFail on unknown Codex configuration keys
ephemeralDo not persist Codex session files
ignoreUserConfigIgnore $CODEX_HOME/config.toml
ignoreRulesIgnore execpolicy .rules files

CLI Compatibility

Validated against Codex CLI 0.144.3. The server keeps older feature guards, but current releases are recommended. Notable current behavior:

  • --full-auto and approval policy on-failure have been removed by Codex CLI.
  • MCP sandbox: true / fullAuto: true remain compatibility aliases for --sandbox workspace-write --ask-for-approval never; they do not bypass the sandbox.
  • Native --search is used without the deprecated web_search_request feature.
  • Current exec flags include --strict-config, --ephemeral, --ignore-user-config, and --ignore-rules.

Troubleshooting

bash
codex --version    # Check CLI versioncodex login        # Authenticate

Use health tool for diagnostics: 'use health verbose:true'

Migration

v2.5.x → v2.6.0: Codex CLI 0.159.2 model sync and a new image-gen tool. Added gpt-6.1-sol (needs Codex CLI 0.159+), gpt-6-sol and gpt-6-luna. Breaking: dropped gpt-5.4-mini, which now returns HTTP 400.

v2.4.x → v2.5.0: Codex CLI 0.153.4 compatibility pass; added gpt-6-astra. Breaking: dropped gpt-5.4 and the moving alias gpt-5.6 (both now rejected with HTTP 400), and removed the untrusted approval policy, which Codex CLI 0.153.x no longer parses.

v2.3.x → v2.4.0: Codex CLI 0.144.3 compatibility audit; added GPT-5.6 Sol/Terra/Luna, max/ultra reasoning, current exec flags, native-only search, and safe compatibility handling for the removed --full-auto flag and on-failure approval policy.

v2.2.x → v2.3.0: gpt-5.5 as new default, added gpt-5.4-mini, dropped retired models (gpt-5.3-codex-spark, gpt-5.2-codex, gpt-5.1-codex-max, gpt-5.1-codex-mini).

v2.0.x → v2.1.0: gpt-5.4 as new default model, updated fallback chain.

v1.5.x → v1.6.0: Local OSS model support (localProvider, oss), gpt-5.3-codex default model, xhigh reasoning effort.

v1.3.x → v1.4.0: New sessionId parameter, list-sessions/health tools, structured error handling. No breaking changes.

License

MIT License. Not affiliated with OpenAI.


Documentation | Issues | Inspired by jamubc/gemini-mcp-tool

来源:README.md,提交 ab1238f

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v2.2.0最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分