Codex MCP集成v2.0
Claude Code的全功能OpenAI Codex集成,具有统一的命令界面、智能路由和质量门。
快速开始
/codex 就是这样。统一 /codex 命令处理一切:
- 自动检测您的项目(框架、模式、工具)
- 基于意图的路由(实现、修复、审查、重构、测试)
- 链操作(“修复X并添加测试”)
- 迭代直到通过质量门
例子
/codex implement a rate limiter for the API
/codex fix the auth bug
/codex review the payment module for security issues
/codex refactor to use repository pattern and add tests命令
| 命令 | 描述 |
|---|---|
/codex | 统一入口-自动路由到适当的代理 |
/codex-config | 查看和修改设置 |
标志(可在/codex上使用)
| 标志 | 目的 |
|---|---|
--model= | 覆盖此调用的模型 |
--reasoning= | 覆盖推理努力(低/中/高/高) |
--profile= | 使用特定配置文件(快速/标准/深度) |
--no-iterate | 跳过质量门 |
--verbose | 显示详细输出 |
--quiet | 最小输出 |
文档
- 食品法典委员会文件目录:
docs/codex-docs/DOCS.md(与Claude Code的列表相同,直接引用了MCP)。 - Codex文档镜像:每个官方页面的原始HTML,保存在
docs/codex-docs/pages/(例如。,codex-cli.html,codex-config-reference.html,codex-mcp.html等等),这样你就可以离线打开确切的OpenAI内容。
特性
- 统一指挥部:一个命令用于所有食典操作
- DNA检测项目:自动理解您的代码库
- 意向路由:将自然语言与最佳工作流程相匹配
- 质量门:迭代直到测试通过,lints clean
- MCP服务器集成:直接从Claude Code访问Codex
- 写入功能:完全文件修改支持
先决条件
- 克劳德代码 已安装(安装指南)
- Codex CLI 安装:
npm install -g codex- 食品法典委员会认证:
codex login安装
Windows(PowerShell):
# One-time install (plugin auto-updates thereafter)
git clone https://github.com/merceralex397-collab/codex-claude-integration.git
cd codex-claude-integration
.\install.ps1Linux/Mac(Bash):
# One-time install (plugin auto-updates thereafter)
git clone https://github.com/merceralex397-collab/codex-claude-integration.git
cd codex-claude-integration
chmod +x install.sh
./install.sh安装程序将存储库克隆到 ~/.claude/plugins/codex-claude-integration/ 并将技能复制到 ~/.claude/skills/该插件在每次Claude Code会话时自动更新。
验证安装
在克劳德代码中:
/mcp应该显示 codex 服务器已连接(绿色)。
配置
用户设置
通过在以下位置创建设置文件来自定义插件 ~/.claude/codex-settings.toml:
# Copy the template
cp ~/.claude/plugins/codex-claude-integration/config/codex-settings.toml ~/.claude/或者使用 /codex-config 命令:
/codex-config create # Create settings file from template
/codex-config # View current settings
/codex-config edit # Show settings file for editing设置参考
[defaults]
model = "gpt-5.2-codex" # Default model
reasoning_effort = "medium" # low | medium | high | xhigh
verbosity = "normal" # quiet | normal | verbose
[gates]
enabled = ["test", "lint"] # Quality gates to run
max_retries = 3 # Retries per failing gate
auto_iterate = true # Continue after gate failure
[profiles.quick] # Fast execution for simple tasks
model = "gpt-5.1-codex-mini"
reasoning_effort = "low"
timeout = 120
[profiles.standard] # Balanced for most tasks
model = "gpt-5.2-codex"
reasoning_effort = "medium"
timeout = 300
[profiles.deep] # Complex tasks
model = "gpt-5.1-codex-max"
reasoning_effort = "high"
timeout = 600
[profiles.review] # Code review (read-only)
model = "gpt-5.2"
reasoning_effort = "medium"
timeout = 300档案
该插件包括预配置的配置文件:
| 简介 | 模型 | 推理工作量 | 用途 |
|---|---|---|---|
quick | gpt-5.1-codex-mini | 低 | 简单/快速任务 |
standard | gpt-5.2-codex | 中等 | 大多数编码任务 |
deep | gpt-5.1-codex-max | 高/高 | 复杂任务 |
review | gpt-5.2 | 中等 | 仅用于分析 |
统一 /codex 技能会根据任务的复杂性自动选择合适的配置文件。 您可以覆盖设置文件中的配置文件。
当前型号(2026年1月)
| 型号 | 最适合 |
|---|---|
gpt-5.2-codex | 旗舰-大多数编码任务 |
gpt-5.1-codex-max | 深度推理,长任务 |
gpt-5.1-codex-mini | 简单任务快速/便宜 |
gpt-5.2 | 不执行代码的分析 |
注:o3、o4 mini和gpt-4.1系列已被取代。
故障排除
MCP服务器无法启动
# Test directly
npx -y codex mcp-server
# Check logs
codex --version身份验证问题
# Re-authenticate
codex login
# Or use API key
claude mcp remove codex
claude mcp add --transport stdio --scope user --env OPENAI_API_KEY=sk-... codex -- npx -y codex mcp-server任务无限期挂起
确保您正在使用 approval-policy: "never"。参见 知识_问题.md.
长任务超时
该插件设置10分钟超时。对于很长的任务,把它们分解成更小的部分。
建筑
子代理
该插件将任务路由到专门的子代理:
| 代理 | 目的 | 沙盒 |
|---|---|---|
codex-coder | 实现、调试、重构 | 工作区编写 |
codex-reviewer | 代码审查、安全审计、分析 | 只读 |
路由是基于意图检测的自动路由:
- 生成、调试、重构、测试 → codex编码器
- 审查、分析、审计 → 法典评审员
文件结构
codex-claude-integration/
├── .claude-plugin/
│ └── plugin.json # Plugin manifest
├── .mcp.json # MCP server configuration
├── hooks/
│ └── hooks.json # SessionStart auto-update hook
├── agents/
│ ├── codex-coder.md # Coding subagent
│ └── codex-reviewer.md # Review subagent
├── skills/
│ ├── codex/ # Unified skill
│ │ └── SKILL.md
│ └── codex-config/ # Configuration skill
│ └── SKILL.md
├── config/
│ ├── codex-settings.toml # User settings template
│ ├── profiles.toml # Profile definitions
│ ├── models.json # Model configurations
│ ├── task-mappings.json # Task type mappings
│ ├── intents.toml # Intent configuration
│ └── gates.toml # Quality gate configuration
├── scripts/
│ ├── auto-update.ps1 # Windows auto-update script
│ ├── auto-update.sh # Linux/Mac auto-update script
│ ├── settings_loader.py # User settings management
│ ├── task-analyzer.py # Task analysis script
│ ├── project_dna.py # Project detection
│ └── quality_gates.py # Quality gate runner
├── README.md
├── KNOWN_ISSUES.md
├── LICENSE
├── install.ps1 / install.sh
└── uninstall.ps1 / uninstall.sh自动更新
该插件会自动检查每个Claude Code会话的更新:
- 从GitHub存储库获取更新
- 检查被限制在每小时一次
- 技能更新后会自动重新复制
- 显示的版本:
git describe --tags(例如,“v2.1.0”)
要手动更新,请执行以下操作:
cd ~/.claude/plugins/codex-claude-integration
git fetch origin --tags
git reset --hard origin/master卸载
Windows(PowerShell):
~/.claude/plugins/codex-claude-integration/uninstall.ps1Linux/Mac(Bash):
~/.claude/plugins/codex-claude-integration/uninstall.sh手动卸载:
# Remove MCP server
claude mcp remove codex
# Remove skills
rm -rf ~/.claude/skills/codex-*
rm -rf ~/.claude/skills/auto-codex
rm -rf ~/.claude/skills/codex
# Remove plugin
rm -rf ~/.claude/plugins/codex-claude-integration许可证
麻省理工学院
贡献
欢迎在https://github.com/merceralex397-collab/codex-claude-integration
