一键导入
codexmcp-claude-codex-collaboration
Enable seamless collaboration between Claude Code and Codex using MCP protocol for multi-agent AI coding workflows
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Enable seamless collaboration between Claude Code and Codex using MCP protocol for multi-agent AI coding workflows
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | codexmcp-claude-codex-collaboration |
| description | Enable seamless collaboration between Claude Code and Codex using MCP protocol for multi-agent AI coding workflows |
| triggers | ["how do I connect Claude Code with Codex","set up CodexMCP for multi-agent collaboration","use Claude Code and Codex together","configure MCP bridge between AI coding assistants","enable parallel AI coding agents","manage sessions between Claude and Codex","troubleshoot CodexMCP connection","implement multi-round dialogue with Codex"] |
Skill by ara.so — Codex Skills collection.
CodexMCP is an MCP (Model Context Protocol) server that enables seamless collaboration between Claude Code and Codex. It bridges these two AI coding assistants, allowing Claude Code to handle architecture and planning while Codex handles implementation and debugging, with features like session persistence, parallel execution, and reasoning trace tracking.
CodexMCP provides:
Ensure you have:
uv tool installed (installation guide)Windows (PowerShell):
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
Linux/macOS:
curl -LsSf https://astral.sh/uv/install.sh | sh
1. Remove official Codex MCP (if installed):
claude mcp remove codex
2. Install CodexMCP:
claude mcp add codex -s user --transport stdio -- uvx --from git+https://github.com/GuDaStudio/codexmcp.git codexmcp
3. Verify installation:
claude mcp list
Expected output:
codex: uvx --from git+https://github.com/GuDaStudio/codexmcp.git codexmcp - ✓ Connected
4. (Optional) Auto-approve MCP interactions:
Edit ~/.claude/settings.json and add mcp__codex__codex to the allow list.
Add to ~/.claude/CLAUDE.md for optimal collaboration:
## Core Instruction for CodeX MCP
At any time, you must consider how to collaborate with Codex and leverage the MCP tools it provides.
**Mandatory steps:**
1. After forming initial analysis of user requirements, inform Codex of the requirements and initial thoughts, and ask it to refine the analysis and implementation plan.
2. Before implementing specific coding tasks, **must request a code implementation prototype from Codex** (require Codex to only provide unified diff patch, strictly prohibit any real code modifications). After obtaining the prototype, you **must use it only as a logical reference, rewrite the code modification** to form enterprise-grade, highly readable, highly maintainable code before implementing the actual programming changes.
3. Whenever concrete coding behavior is completed, **must immediately use Codex to review code changes and corresponding requirement completion**.
4. Codex only provides reference; you **must have your own thinking and even question Codex's answers**. You and Codex must continuously debate to find the only path to truth.
## Codex Tool Invocation Specification
### Tool Parameters
**Required:**
- `PROMPT` (string): Task instruction for Codex
- `cd` (Path): Working directory root path
**Optional:**
- `sandbox` (string): "read-only" (default), "workspace-write", "danger-full-access"
- `SESSION_ID` (UUID | null): Continue previous session (default: None for new session)
- `skip_git_repo_check` (boolean): Allow running outside Git repo (default: False)
- `return_all_messages` (boolean): Return all messages including reasoning (default: False)
- `image` (List[Path] | null): Attach image files to initial prompt
- `model` (string | null): Specify model (default: user config)
- `yolo` (boolean | null): Run all commands without approval (default: False)
- `profile` (string | null): Config profile from ~/.codex/config.toml
### Best Practices
- **Always save SESSION_ID** for multi-round dialogue
- Use `sandbox="read-only"` for safe prototyping
- Set `return_all_messages=True` for detailed debugging
- Ensure `cd` points to an existing directory
codex ToolCodexMCP provides a single MCP tool called codex that executes AI-assisted coding tasks.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
PROMPT | str | ✅ | - | Task instruction for Codex |
cd | Path | ✅ | - | Working directory root path |
sandbox | Literal["read-only", "workspace-write", "danger-full-access"] | ❌ | "read-only" | Sandbox policy |
SESSION_ID | UUID | None | ❌ | None | Session ID for continuation |
skip_git_repo_check | bool | ❌ | False | Allow non-Git repos |
return_all_messages | bool | ❌ | False | Return full reasoning trace |
image | List[Path] | None | ❌ | None | Attach images to prompt |
model | str | None | ❌ | None | Specify model |
yolo | bool | None | ❌ | False | Skip all approvals |
profile | str | None | ❌ | None | Config profile name |
Success:
{
"success": true,
"SESSION_ID": "550e8400-e29b-41d4-a716-446655440000",
"agent_messages": "Codex response text...",
"all_messages": [] // Only when return_all_messages=True
}
Failure:
{
"success": false,
"error": "Error message"
}
# In Claude Code, invoke Codex for code review
# (This is conceptual - actual invocation happens through MCP)
tool_params = {
"PROMPT": "Review the authentication logic in src/auth.py for security issues",
"cd": "/path/to/project",
"sandbox": "read-only",
"return_all_messages": True
}
# MCP tool call returns:
{
"success": True,
"SESSION_ID": "abc-123",
"agent_messages": "Found potential SQL injection in line 45..."
}
# First request: Get implementation plan
params_1 = {
"PROMPT": "Analyze requirements for user authentication feature",
"cd": "/path/to/project",
"sandbox": "read-only"
}
# Returns: SESSION_ID = "session-xyz"
# Second request: Continue the session
params_2 = {
"PROMPT": "Now generate a unified diff patch for the authentication module",
"cd": "/path/to/project",
"SESSION_ID": "session-xyz", # Continue previous conversation
"sandbox": "read-only"
}
# Third request: Ask follow-up questions
params_3 = {
"PROMPT": "What about edge cases for token expiration?",
"cd": "/path/to/project",
"SESSION_ID": "session-xyz",
"sandbox": "read-only"
}
# Task A: Bug investigation (isolated session)
task_a = {
"PROMPT": "Debug memory leak in data processor",
"cd": "/path/to/project",
"sandbox": "read-only"
}
# Returns: SESSION_ID_A = "task-a-123"
# Task B: Feature prototyping (separate isolated session)
task_b = {
"PROMPT": "Create prototype for caching layer",
"cd": "/path/to/project",
"sandbox": "read-only"
}
# Returns: SESSION_ID_B = "task-b-456"
# Both tasks run independently without context interference
# Enable full message history for debugging
params = {
"PROMPT": "Optimize database query performance in reports module",
"cd": "/path/to/project",
"sandbox": "read-only",
"return_all_messages": True # Get full reasoning chain
}
# Returns:
{
"success": True,
"SESSION_ID": "debug-session",
"agent_messages": "Optimized query reduces execution time...",
"all_messages": [
{"role": "reasoning", "content": "Analyzing query structure..."},
{"role": "tool_call", "content": "read_file reports/queries.py"},
{"role": "tool_result", "content": "...file contents..."},
{"role": "reasoning", "content": "Identified N+1 query pattern..."},
# ... full trace
]
}
# Attach architecture diagram for context
params = {
"PROMPT": "Review this architecture and suggest improvements",
"cd": "/path/to/project",
"image": ["/path/to/architecture.png", "/path/to/flowchart.svg"],
"sandbox": "read-only"
}
{
"PROMPT": "Based on this architecture, create implementation prototype for auth service",
"cd": "/path/to/project",
"sandbox": "read-only"
}
{
"PROMPT": "Review the auth service implementation for security and best practices",
"cd": "/path/to/project",
"SESSION_ID": "previous-session-id",
"sandbox": "read-only"
}
{
"PROMPT": "Investigate null pointer exception in payment processor at line 234",
"cd": "/path/to/project",
"sandbox": "read-only",
"return_all_messages": True # Get detailed trace
}
{
"PROMPT": "Analyze technical debt in legacy payment module",
"cd": "/path/to/project",
"sandbox": "read-only"
}
Problem: codex: ... - ✗ Not Connected
Solutions:
# Check MCP configuration
claude mcp list
# Reinstall CodexMCP
claude mcp remove codex
claude mcp add codex -s user --transport stdio -- uvx --from git+https://github.com/GuDaStudio/codexmcp.git codexmcp
# Restart Claude Code
# (Close and reopen the application)
Problem: Session context is lost between calls
Solutions:
SESSION_ID from previous response is passed to next callSESSION_ID is a valid UUIDcd path is used across session calls# ✅ Correct: Save and reuse SESSION_ID
response_1 = codex_tool(PROMPT="First task", cd="/project")
session_id = response_1["SESSION_ID"]
response_2 = codex_tool(
PROMPT="Continue task",
cd="/project",
SESSION_ID=session_id # Reuse here
)
# ❌ Wrong: Not passing SESSION_ID
response_2 = codex_tool(PROMPT="Continue task", cd="/project") # New session!
Problem: Tool fails silently or returns "directory not found"
Solutions:
# ✅ Use absolute paths
params = {
"cd": "/home/user/projects/myapp",
"PROMPT": "..."
}
# ✅ Or resolve relative paths first
import os
params = {
"cd": os.path.abspath("./myapp"),
"PROMPT": "..."
}
# ❌ Don't use relative paths directly
params = {
"cd": "./myapp", # May not resolve correctly
"PROMPT": "..."
}
Problem: Codex refuses to run outside Git repository
Solutions:
# Option 1: Initialize Git repo
# $ cd /path/to/project
# $ git init
# Option 2: Skip the check (not recommended for production)
params = {
"PROMPT": "...",
"cd": "/path/to/project",
"skip_git_repo_check": True # Bypass Git requirement
}
Problem: Codex cannot write files when needed
Solutions:
# For read-only analysis (safest, default)
params = {"sandbox": "read-only"}
# For workspace modifications
params = {"sandbox": "workspace-write"}
# For full access (use with caution)
params = {"sandbox": "danger-full-access"}
# Or skip sandbox entirely (not recommended)
params = {"yolo": True}
Problem: Using wrong model or hitting rate limits
Solutions:
# Use specific model
params = {
"PROMPT": "...",
"cd": "/project",
"model": "claude-3-opus" # Specify model
}
# Use custom profile from ~/.codex/config.toml
params = {
"PROMPT": "...",
"cd": "/project",
"profile": "production" # Load specific config
}
Problem: Codex gives unexpected results
Solutions:
# Enable full message trace
params = {
"PROMPT": "...",
"cd": "/project",
"return_all_messages": True # See full reasoning chain
}
# Inspect the response
response = codex_tool(**params)
for msg in response.get("all_messages", []):
print(f"{msg['role']}: {msg['content']}")
Edit ~/.codex/config.toml:
[profiles.production]
model = "claude-3-opus"
max_tokens = 8192
temperature = 0.3
[profiles.experimental]
model = "claude-3-sonnet"
max_tokens = 16384
temperature = 0.7
Use in CodexMCP:
params = {
"PROMPT": "...",
"cd": "/project",
"profile": "production" # Load this profile
}
CodexMCP respects standard Codex CLI environment variables:
# Set default model
export CODEX_MODEL="claude-3-opus"
# Set API key (if needed)
export ANTHROPIC_API_KEY="sk-ant-..."
# Custom config location
export CODEX_CONFIG_PATH="~/.config/codex/custom.toml"
# Step 1: Claude analyzes requirements
# (Manual interaction with user)
# Step 2: Claude asks Codex for implementation plan
plan_response = codex_tool(
PROMPT="Create implementation plan for user authentication with JWT tokens",
cd="/path/to/project",
sandbox="read-only"
)
session_id = plan_response["SESSION_ID"]
# Step 3: Claude asks for code prototype
prototype_response = codex_tool(
PROMPT="Generate unified diff patch for JWT auth implementation",
cd="/path/to/project",
SESSION_ID=session_id,
sandbox="read-only"
)
# Step 4: Claude refines and implements
# (Claude writes actual code based on prototype)
# Step 5: Claude asks Codex to review
review_response = codex_tool(
PROMPT="Review the implemented JWT authentication for security issues",
cd="/path/to/project",
SESSION_ID=session_id,
sandbox="read-only",
return_all_messages=True
)
# Step 6: Claude addresses feedback and iterates
sandbox="read-only" for Codex prototyping to prevent accidental changescd parameterreturn_all_messages when debugging or tracing reasoningskip_git_repo_check sparingly)Convert attached object images into code-only, animation-ready procedural Three.js models through guided sculpting workflow
Create and manage AI video storyboard projects with automated asset generation through Codex Storyboard workspace
Continue-thinking middleware that detects and handles reasoning truncation in Codex/OpenAI Responses-compatible APIs
Desktop manager for OpenAI Codex CLI with prompt injection, provider switching, and TOML/Auth visualization
Inject unrestricted developer mode instructions into Codex CLI (GPT-5.5) to bypass content filters
Install and use TradingCodex to build Codex-native investment research workflows with fixed-role agents, order approval gates, and local Django service plane