| 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"] |
CodexMCP: Claude Code & Codex Collaboration
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.
What It Does
CodexMCP provides:
- Multi-round dialogue between Claude Code and Codex with session management
- Parallel task execution with isolated session IDs
- Reasoning trace tracking for detailed debugging insights
- Enhanced error handling and workspace safety controls
- Session persistence across multiple interactions
Installation
Prerequisites
Ensure you have:
- Claude Code v2.0.56+ installed and configured
- Codex CLI v0.61.0+ installed and configured
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
Install CodexMCP
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.
Configuration
Recommended Claude Code System Prompt
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
API Reference
The codex Tool
CodexMCP provides a single MCP tool called codex that executes AI-assisted coding tasks.
Parameters
| 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 |
Return Value
Success:
{
"success": true,
"SESSION_ID": "550e8400-e29b-41d4-a716-446655440000",
"agent_messages": "Codex response text...",
"all_messages": []
}
Failure:
{
"success": false,
"error": "Error message"
}
Usage Patterns
Pattern 1: Single-shot Code Review
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
}
{
"success": True,
"SESSION_ID": "abc-123",
"agent_messages": "Found potential SQL injection in line 45..."
}
Pattern 2: Multi-round Dialogue Session
params_1 = {
"PROMPT": "Analyze requirements for user authentication feature",
"cd": "/path/to/project",
"sandbox": "read-only"
}
params_2 = {
"PROMPT": "Now generate a unified diff patch for the authentication module",
"cd": "/path/to/project",
"SESSION_ID": "session-xyz",
"sandbox": "read-only"
}
params_3 = {
"PROMPT": "What about edge cases for token expiration?",
"cd": "/path/to/project",
"SESSION_ID": "session-xyz",
"sandbox": "read-only"
}
Pattern 3: Parallel Task Execution
task_a = {
"PROMPT": "Debug memory leak in data processor",
"cd": "/path/to/project",
"sandbox": "read-only"
}
task_b = {
"PROMPT": "Create prototype for caching layer",
"cd": "/path/to/project",
"sandbox": "read-only"
}
Pattern 4: Detailed Reasoning Trace
params = {
"PROMPT": "Optimize database query performance in reports module",
"cd": "/path/to/project",
"sandbox": "read-only",
"return_all_messages": True
}
{
"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..."},
]
}
Pattern 5: Image-based 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"
}
Common Workflows
Workflow 1: Claude Architecting + Codex Implementing
- Claude analyzes requirements and creates high-level plan
- Claude invokes Codex with architectural decisions:
{
"PROMPT": "Based on this architecture, create implementation prototype for auth service",
"cd": "/path/to/project",
"sandbox": "read-only"
}
- Codex returns unified diff patch (no actual changes)
- Claude reviews and refines the code
- Claude implements the final version
- Claude asks Codex to review the implementation:
{
"PROMPT": "Review the auth service implementation for security and best practices",
"cd": "/path/to/project",
"SESSION_ID": "previous-session-id",
"sandbox": "read-only"
}
Workflow 2: Bug Investigation
- Claude identifies bug symptoms
- Claude delegates to Codex for detailed investigation:
{
"PROMPT": "Investigate null pointer exception in payment processor at line 234",
"cd": "/path/to/project",
"sandbox": "read-only",
"return_all_messages": True
}
- Codex traces execution flow and identifies root cause
- Claude formulates fix based on Codex insights
- Claude asks Codex to validate the fix
Workflow 3: Code Refactoring
- Claude plans refactoring strategy
- Claude requests Codex analysis:
{
"PROMPT": "Analyze technical debt in legacy payment module",
"cd": "/path/to/project",
"sandbox": "read-only"
}
- Codex identifies patterns and suggests improvements
- Claude implements refactoring in stages
- Codex reviews each stage for consistency
Troubleshooting
Connection Issues
Problem: codex: ... - ✗ Not Connected
Solutions:
claude mcp list
claude mcp remove codex
claude mcp add codex -s user --transport stdio -- uvx --from git+https://github.com/GuDaStudio/codexmcp.git codexmcp
Session Not Persisting
Problem: Session context is lost between calls
Solutions:
- Ensure
SESSION_ID from previous response is passed to next call
- Verify the returned
SESSION_ID is a valid UUID
- Check that the same
cd path is used across session calls
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
)
response_2 = codex_tool(PROMPT="Continue task", cd="/project")
Working Directory Errors
Problem: Tool fails silently or returns "directory not found"
Solutions:
params = {
"cd": "/home/user/projects/myapp",
"PROMPT": "..."
}
import os
params = {
"cd": os.path.abspath("./myapp"),
"PROMPT": "..."
}
params = {
"cd": "./myapp",
"PROMPT": "..."
}
Git Repository Check Failing
Problem: Codex refuses to run outside Git repository
Solutions:
params = {
"PROMPT": "...",
"cd": "/path/to/project",
"skip_git_repo_check": True
}
Sandbox Permission Errors
Problem: Codex cannot write files when needed
Solutions:
params = {"sandbox": "read-only"}
params = {"sandbox": "workspace-write"}
params = {"sandbox": "danger-full-access"}
params = {"yolo": True}
Model Configuration Issues
Problem: Using wrong model or hitting rate limits
Solutions:
params = {
"PROMPT": "...",
"cd": "/project",
"model": "claude-3-opus"
}
params = {
"PROMPT": "...",
"cd": "/project",
"profile": "production"
}
Debugging Reasoning Failures
Problem: Codex gives unexpected results
Solutions:
params = {
"PROMPT": "...",
"cd": "/project",
"return_all_messages": True
}
response = codex_tool(**params)
for msg in response.get("all_messages", []):
print(f"{msg['role']}: {msg['content']}")
Advanced Configuration
Custom Codex Config Profile
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"
}
Environment Variables
CodexMCP respects standard Codex CLI environment variables:
export CODEX_MODEL="claude-3-opus"
export ANTHROPIC_API_KEY="sk-ant-..."
export CODEX_CONFIG_PATH="~/.config/codex/custom.toml"
Integration Examples
Example: Full Development Cycle
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"]
prototype_response = codex_tool(
PROMPT="Generate unified diff patch for JWT auth implementation",
cd="/path/to/project",
SESSION_ID=session_id,
sandbox="read-only"
)
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
)
Best Practices
- Always use
sandbox="read-only" for Codex prototyping to prevent accidental changes
- Track SESSION_ID for multi-round conversations
- Use absolute paths for the
cd parameter
- Enable
return_all_messages when debugging or tracing reasoning
- Set up Git repositories before running Codex (or use
skip_git_repo_check sparingly)
- Use descriptive PROMPTs that clearly state the task and context
- Leverage parallel sessions for independent tasks (different SESSION_IDs)
- Review Codex outputs critically — treat them as suggestions, not final solutions
Resources