claude-code-codex-agents
Allows Claude Code to delegate tasks to OpenAI's GPT-5.4 via Codex CLI, returning structured execution reports including tool usage, file changes, timing, and errors.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@claude-code-codex-agents Refactor src/auth.py to use async/await"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
claude-code-codex-agents
Give Claude Code structured Codex traces, not raw output.
For Claude Code users who want GPT-5.4 as a real tool: claude-code-codex-agents parses the entire JSONL event stream from Codex CLI and returns a structured execution report -- which tools it used, which files it touched, how long it took, and what went wrong. No other Codex MCP bridge does this.

graph LR
A["Claude Code<br/>(Opus 4.6)"] -->|MCP Protocol| B["claude-code-codex-agents<br/>MCP Server"]
B -->|"subprocess + stdin"| C[Codex CLI]
C -->|JSONL stream| B
C -->|API call| D["OpenAI API<br/>(GPT-5.4)"]
B -->|Structured Report| AWithout vs With claude-code-codex-agents
Without -- You call Codex CLI and get a wall of text. You don't know what tools it used, what files it changed, or if it actually succeeded.
With claude-code-codex-agents -- Claude Code gets a structured execution trace:
[Codex gpt-5.4] Completed
⏱ Execution time: 8.3s
🧵 Thread: 019d436e-4c39-7093-b7ed-f8a26aca7938
📦 Tools used (3):
✅ read_file — src/auth.py
✅ edit_file — src/auth.py
✅ shell — python -m pytest tests/
📁 Files touched (1):
• src/auth.py
━━━ Codex Response ━━━
Fixed the authentication logic. Token validation order was incorrect.Related MCP server: Codex MCP Server
Why claude-code-codex-agents?
There are 6+ Codex MCP bridges on GitHub. Here's what makes this one different:
Other bridges | claude-code-codex-agents | |
Output | Raw text dump | Structured trace (tools, files, timing, errors) |
Parallel tasks | 1 at a time | Up to 6 simultaneous |
Session continuity | Stateless | threadId persistence across calls |
Security | Pass-through | 3-tier sandbox + terminal injection prevention |
Tests | Few or none | 59 tests (parsing, security, sessions, edge cases, agent lifecycle) |
Review | Basic or none | Adversarial Review Loop (GPT-5.4 challenges Claude's code) |
Key Features
Full JSONL Trace Parsing -- Every Codex event (tool calls, file ops, errors) parsed into a structured report
Parallel Execution -- Run up to 6 Codex tasks simultaneously via
parallel_executeSession Management -- Continue previous threads with
session_continue(threadId persistence)Agent Lifecycle -- Run Codex as a background Claude Code-style worker via
spawn_codex_agent,send_codex_agent_input, andwait_codex_agentAdversarial Review Loop -- GPT-5.4 reviews Claude's code from a different perspective
Sandbox Security -- 3-tier policy (read-only / workspace-write / danger-full-access) + terminal injection prevention
Cross-Model Discussion -- Get GPT-5.4's opinion on design decisions via
discussZero External Dependencies -- Just FastMCP + Codex CLI. No databases, no Docker, no config files
Japanese Native -- Full Japanese prompt and report support
59 Tests -- Comprehensive coverage including security, parsing, session management, agent lifecycle, and edge cases
Quick Start
1. Install Codex CLI
npm install -g @openai/codex
codex login2. Install claude-code-codex-agents
git clone https://github.com/tsunamayo7/claude-code-codex-agents.git
cd claude-code-codex-agents
uv sync3. Add to your MCP client
Claude Code (~/.claude/settings.json):
{
"mcpServers": {
"claude-code-codex-agents": {
"type": "stdio",
"command": "uv",
"args": ["run", "--directory", "/path/to/claude-code-codex-agents", "python", "server.py"],
"env": { "PYTHONUTF8": "1" }
}
}
}{
"mcpServers": {
"claude-code-codex-agents": {
"command": "uv",
"args": ["run", "--directory", "/path/to/claude-code-codex-agents", "python", "server.py"],
"env": { "PYTHONUTF8": "1" }
}
}
}Add to your MCP settings:
{
"claude-code-codex-agents": {
"command": "uv",
"args": ["run", "--directory", "/path/to/claude-code-codex-agents", "python", "server.py"],
"env": { "PYTHONUTF8": "1" }
}
}Tools
Tool | Description | Sandbox |
| Delegate tasks to Codex with structured trace report | workspace-write |
| Same as execute, plus full event timeline | workspace-write |
| Run up to 6 tasks simultaneously | read-only |
| Adversarial code review by GPT-5.4 | read-only |
| Code explanation (brief/medium/detailed) | read-only |
| Code generation with optional file output | workspace-write |
| Get GPT-5.4's perspective on design decisions | read-only |
| Continue a previous Codex thread | workspace-write |
| List session history with thread IDs | - |
| Launch a background Codex worker with | role-based |
| Continue a background Codex worker with follow-up instructions | same as agent |
| Wait for an agent turn and fetch the last structured result | - |
| Inspect tracked background Codex agents | - |
| Close an idle Codex agent | - |
| Check Codex CLI status and auth | - |
Claude Code-Style Agents
The new agent lifecycle tools let Claude Code treat Codex more like a persistent sub-agent than a one-shot CLI call.
Use
spawn_codex_agentto start a background worker with a role preset:defaultfor balanced execution,explorerfor read-heavy investigation,workerfor implementation.Use
send_codex_agent_inputto continue the same worker after you read its last result.Use
wait_codex_agentto poll for completion without blocking other work.Use
list_codex_agentsandclose_codex_agentto manage idle workers.
Real-World Example: Adversarial Code Review
Claude Code writes code, then asks GPT-5.4 to review it:
[Codex Review] GPT-5.4 Review Result
⏱ Execution time: 15.7s
━━━ Codex Response ━━━
- [CRITICAL] `run(cmd)` calls `os.system(cmd)` directly -- command injection
if `cmd` contains user input. Use `subprocess.run([...], shell=False)`.
- [WARNING] `divide(a, b)` raises ZeroDivisionError when b == 0.
Add a pre-check or explicit error message.
- [INFO] No type hints on function signatures. Add `def divide(a: float,
b: float) -> float:` for readability.Real-World Example: Parallel Execution
Analyze multiple tasks simultaneously:
[Parallel Execution Complete] 3 tasks
━━━ Task 1 ✅ ━━━
Instruction: Analyze src/auth.py for security issues
⏱ 5.2s
...
━━━ Task 2 ✅ ━━━
Instruction: Review database query patterns in src/db.py
⏱ 7.8s
...
━━━ Task 3 ✅ ━━━
Instruction: Check error handling in src/api.py
⏱ 4.1s
...Architecture
sequenceDiagram
participant C as Claude Code
participant H as claude-code-codex-agents
participant X as Codex CLI
participant O as OpenAI API
C->>H: MCP tool call (execute)
H->>H: _validate() + _enforce_sandbox()
H->>X: subprocess (stdin prompt)
X->>O: API request (GPT-5.4)
O-->>X: Response
X-->>H: JSONL event stream
H->>H: parse_jsonl_events() → CodexTrace
H->>H: _sanitize() → format_report()
H-->>C: Structured reportSecurity Model
Sandbox Mode | File Write | Shell Exec | Use Case |
| Blocked | Blocked | Review, explain, discuss |
| CWD only | Allowed | Execute, generate |
| Anywhere | Allowed | Full system access (use with caution) |
Additional protections:
ANSI/OSC escape sequence sanitization (terminal injection prevention)
Input validation on all parameters
Process kill on timeout
--ephemeralflag (no persistent Codex state)
Development
# Setup
git clone https://github.com/tsunamayo7/claude-code-codex-agents.git
cd claude-code-codex-agents
uv sync --extra dev
# Run tests (59 tests)
uv run pytest tests/ -v
# Run server directly
uv run python server.pyProject structure: Single file (server.py, ~820 lines). Easy to read, modify, and contribute.
Use Cases
Cross-Model Code Review -- Claude writes code, GPT-5.4 reviews it. Eliminates single-model bias.
Parallel Codebase Analysis -- Analyze 6 files simultaneously, get structured reports for each.
Design Discussion -- Get GPT-5.4's alternative perspective on architectural decisions via
discuss.Session-Based Refactoring -- Large refactoring across multiple
session_continuecalls with context preservation.AI Second Opinion -- When Claude's answer seems off, ask GPT-5.4 for a sanity check.
Requirements
Python 3.12+
Codex CLI (
npm install -g @openai/codex)OpenAI account (Codex CLI must be authenticated via
codex login)uv (recommended) or pip
Related Projects
Helix Ecosystem
helix-ai-studio — All-in-one AI chat studio with 7 providers, RAG, MCP tools, and pipeline
helix-pilot — GUI automation MCP server — AI controls Windows desktop via local Vision LLM
helix-agent — Extend Claude Code with local Ollama models — cut token costs by 60-80%
helix-sandbox — Secure sandbox MCP server — Docker + Windows Sandbox
Alternative Codex Bridges
codex-plugin-cc -- Official OpenAI plugin for Claude Code
codex-mcp-server -- Alternative Codex MCP bridge (Node.js)
License
Available Tools
15 toolsclose_codex_agentB
Close an idle Codex agent and keep its last known result.
Inputs: agent_id (required). Returns: object
discussA
Codex CLI(GPT-5.4)と対話的にアイデアを深掘り。別視点の意見を得る。
Args: topic: 議論したいトピック context: 追加コンテキスト(現在の設計案、課題など)
Inputs: topic (required), context. Returns: result
executeB
Codex CLI(GPT-5.4)にタスクを委譲。実行過程を構造化レポートで返す。
Args: prompt: 実行するタスクの説明(日本語OK) cwd: 作業ディレクトリ(空の場合はカレント) model: 使用モデル(デフォルト: gpt-5.4) sandbox: サンドボックスモード(read-only/workspace-write/danger-full-access) timeout: タイムアウト秒数
Inputs: prompt (required), cwd, model, sandbox, +1 more. Returns: result
explainA
Codex CLI(GPT-5.4)にコードの解説・分析を依頼。
Args: code: 解説対象のコード language: プログラミング言語 detail_level: 詳細レベル(brief/medium/detailed)
Inputs: code (required), language, detail_level. Returns: result
generateA
Codex CLI(GPT-5.4)にコード生成を依頼。
Args: description: 生成するコードの説明(日本語OK) language: プログラミング言語 cwd: 作業ディレクトリ output_file: 出力ファイルパス(空の場合はコードを返す)
Inputs: description (required), cwd, language, output_file. Returns: result
list_codex_agentsA
List all tracked background Codex agents.
Inputs: no named parameters. Returns: object
parallel_executeA
複数タスクをサブプロセスで並列実行し、全結果をまとめて返す。
各タスクの実行過程が個別にトレースされ、構造化レポートで返る。
Args: tasks: タスクリスト(改行区切り。各行が1つのタスク) model: 使用モデル sandbox: サンドボックスモード cwd: 作業ディレクトリ timeout: 全体タイムアウト秒数
Inputs: tasks (required), cwd, model, sandbox, +1 more. Returns: result
reviewA
Codex CLI(GPT-5.4)にコードレビューを依頼。Adversarial Review Loopの実行部分。
Args: code: レビュー対象のコード language: プログラミング言語 focus: レビューの焦点(カンマ区切り: bugs,security,performance,readability)
Inputs: code (required), focus, language. Returns: result
send_codex_agent_inputA
Continue an existing background Codex agent with a new instruction.
Inputs: message (required), agent_id (required), timeout. Returns: object
session_continueA
前回のCodexセッション(スレッド)を引き継いで継続実行。
thread_idを省略すると最新のセッションを自動で引き継ぐ。
Args: prompt: 続きの指示(日本語OK) thread_id: 引き継ぐスレッドID(省略時は最新) model: 使用モデル sandbox: サンドボックスモード timeout: タイムアウト秒数
Inputs: prompt (required), model, sandbox, timeout, +1 more. Returns: result
session_listA
Codexセッション(スレッド)の履歴一覧を表示。session_continueで使用するthread_idを確認できる。
Inputs: no named parameters. Returns: result
spawn_codex_agentC
Start a background Codex worker with a Claude Code-style lifecycle.
Inputs: prompt (required), cwd, model, sandbox, +3 more. Returns: object
statusB
Codex CLIの状態とセッション情報を確認
Inputs: no named parameters. Returns: result
trace_executeA
Codex実行の全イベントトレースを返す。デバッグ・分析用の詳細モード。
executeと同じ実行だが、全JSONLイベントのタイムラインも含む。
Args: prompt: 実行するタスクの説明 cwd: 作業ディレクトリ model: 使用モデル sandbox: サンドボックスモード timeout: タイムアウト秒数
Inputs: prompt (required), cwd, model, sandbox, +1 more. Returns: result
wait_codex_agentC
Wait for a background Codex agent to finish its current turn.
Inputs: agent_id (required), timeout. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 15 tools
Most tools have distinct purposes, but 'execute' and 'trace_execute' are nearly identical aside from output detail, and 'session_list' and 'status' both report session info. Descriptions clarify the differences, so agents should generally select correctly.
The majority of tools follow a verb_noun pattern (e.g., execute, review, explain, spawn_codex_agent), but 'session_list', 'session_continue', and 'status' deviate to noun_verb or bare noun. This is a minor inconsistency in an otherwise predictable naming scheme.
15 tools is at the upper boundary of appropriate for a Codex CLI wrapper. The set covers task execution, code analysis, session management, and background agent lifecycle, but a few tools like 'trace_execute' and 'status' feel somewhat redundant with 'execute' and 'session_list', making the set slightly over-sized.
The toolkit covers the core workflows: single, parallel, and traced execution; code review, explanation, generation, and discussion; session listing and continuation; and background agent lifecycle. A notable gap is the lack of a cancellation mechanism for running tasks, but the overall surface is fairly complete for the domain.
Related MCP Connectors
No-data MCP handoff for local Claude Code to Codex harness moves. $49 lifetime.
Source-checked CLI guides and model-aware planning for Claude Code, Codex, and Grok Build.
Shared workspace where Claude, ChatGPT, Codex and Grok share files, tasks, decisions and handoffs.
A paid remote MCP for OpenAI Codex agent coordination MCP, built to return verdicts, receipts, usage
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables Claude to delegate tasks to OpenAI expert models (GPT-5.3-Codex and GPT-5.5) as subagents, with orchestration patterns for safe and effective use.3MIT
- AlicenseNot gradedqualityDmaintenanceIntegrates OpenAI Codex CLI with Claude Code via MCP, enabling code execution, analysis, fixing, and web search within Claude Code.1,915 npm1ISC
- AlicenseNot gradedqualityCmaintenanceEnables Claude Code to call OpenAI Codex for read-only design, deep reasoning, and code review tasks.55 npmMIT
- AlicenseAqualityBmaintenanceEnables Claude Code to delegate coding tasks—investigation, review, long-running background jobs, and optional file edits—to a locally installed OpenAI Codex CLI, with the model and reasoning effort chosen per task and read-only execution by default. Follow-up requests reuse Codex's existing context, and write-enabled delegations can be confined to a managed git worktree so the user's own checkout stays untouched.995 npmMIT