Codex CLI

Codex CLI

cexll

Connects Claude/MCP clients to OpenAI's Codex CLI for direct code analysis and automated refactoring. Handles large-scale file processing with chunked responses and safety controls.

Bridges OpenAI's Codex CLI with structured command execution, brainstorming sessions, and chunked response delivery for code analysis, automated refactoring, and development workflow automation.

1515,421 views11Local (stdio)

What it does

  • Execute Codex CLI with file analysis using @ syntax
  • Run batch operations for mass code refactoring
  • Generate structured brainstorming sessions for development ideas
  • Retrieve chunked responses for large code transformations
  • Process multiple atomic tasks in parallel

Best for

Developers automating code reviews and refactoringTeams processing large codebases with AI analysisCI/CD pipelines requiring automated code transformations
Structured change mode with OLD/NEW patch outputCross-platform Windows/macOS/Linux supportSandboxed edits with approval controls

About Codex CLI

Codex CLI is a community-built MCP server published by cexll that provides AI assistants with tools and capabilities via the Model Context Protocol. Codex CLI is a code analysis tool for structured command execution, brainstorming, and workflow automation with static c It is categorized under developer tools. This server exposes 8 tools that AI clients can invoke during conversations and coding sessions.

How to install

You can install Codex CLI in your AI client of choice. Use the install panel on this page to get one-click setup for Cursor, Claude Desktop, VS Code, and other MCP-compatible clients. This server runs locally on your machine via the stdio transport.

License

Codex CLI is released under the MIT license. This is a permissive open-source license, meaning you can freely use, modify, and distribute the software.

Tools (8)

ask-codex

Execute Codex CLI with file analysis (@syntax), model selection, and safety controls. Supports changeMode.

batch-codex

Delegate multiple atomic tasks to Codex for batch processing. Ideal for repetitive operations, mass refactoring, and automated code transformations

ping

Echo

Help

receive help information

version

Display version and system information

Codex MCP Tool

GitHub Release npm version npm downloads License: MIT Open Source

Codex MCP Tool is an open‑source Model Context Protocol (MCP) server that connects your IDE or AI assistant (Claude, Cursor, etc.) to the Codex CLI. It enables non‑interactive automation with codex exec, safe sandboxed edits with approvals, and large‑scale code analysis via @ file references. Built for reliability and speed, it streams progress updates, supports structured change mode (OLD/NEW patch output), and integrates cleanly with standard MCP clients for code review, refactoring, documentation, and CI automation.

Latest Release (v1.2.4): Enhanced Windows compatibility - Now using cross-spawn for reliable npm global command execution across all platforms (Windows, macOS, Linux). See changelog

  • Ask Codex questions from your MCP client, or brainstorm ideas programmatically.
Codex Tool MCP server

TLDR: Claude + Codex CLI

Goal: Use Codex directly from your MCP-enabled editor to analyze and edit code efficiently.

Prerequisites

Before using this tool, ensure you have:

  1. Node.js (v18.0.0 or higher)
  2. Codex CLI installed and authenticated

✅ Cross-Platform Support: Fully tested and working on Windows, macOS, and Linux (v1.2.4+)

One-Line Setup

claude mcp add codex-cli -- npx -y @cexll/codex-mcp-server

Verify Installation

Type /mcp inside Claude Code to verify the Codex MCP is active.


Alternative: Import from Claude Desktop

If you already have it configured in Claude Desktop:

  1. Add to your Claude Desktop config:
"codex-cli": {
  "command": "npx",
  "args": ["-y", "@cexll/codex-mcp-server"]
}
  1. Import to Claude Code:
claude mcp add-from-claude-desktop

Configuration

Register the MCP server with your MCP client:

For NPX Usage (Recommended)

Add this configuration to your Claude Desktop config file:

{
  "mcpServers": {
    "codex-cli": {
      "command": "npx",
      "args": ["-y", "@cexll/codex-mcp-server"]
    }
  }
}

For Global Installation

If you installed globally, use this configuration instead:

{
  "mcpServers": {
    "codex-cli": {
      "command": "codex-mcp"
    }
  }
}

Configuration File Locations:

  • Claude Desktop:
    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
    • Linux: ~/.config/claude/claude_desktop_config.json

After updating the configuration, restart your terminal session.

Example Workflow

  • Natural language: "use codex to explain index.html", "understand this repo with @src", "look for vulnerabilities and suggest fixes"
  • Claude Code: Type /codex-cli to access the MCP server tools.

Usage Examples

Model Selection

// Use the default gpt-5-codex model
'explain the architecture of @src/';

// Use gpt-5 for fast general purpose reasoning
'use codex with model gpt-5 to analyze @config.json';

// Use o3 for deep reasoning tasks
'use codex with model o3 to analyze complex algorithm in @algorithm.py';

// Use o4-mini for quick tasks
'use codex with model o4-mini to add comments to @utils.js';

// Use codex-1 for software engineering
'use codex with model codex-1 to refactor @legacy-code.js';

With File References (using @ syntax)

  • ask codex to analyze @src/main.ts and explain what it does
  • use codex to summarize @. the current directory
  • analyze @package.json and list dependencies

General Questions (without files)

  • ask codex to explain div centering
  • ask codex about best practices for React development related to @src/components/Button.tsx

Brainstorming & Ideation

  • brainstorm ways to optimize our CI/CD pipeline using SCAMPER method
  • use codex to brainstorm 10 innovative features for our app with feasibility analysis
  • ask codex to generate product ideas for the healthcare domain with design-thinking approach

Codex Approvals & Sandbox

Codex CLI supports fine-grained control over permissions and approvals through sandbox modes and approval policies.

Understanding Parameters

The sandbox Parameter (Convenience Flag):

  • sandbox: true → Enables fullAuto mode (equivalent to fullAuto: true)
  • sandbox: false (default) → Does NOT disable sandboxing, just doesn't enable auto mode
  • Important: The sandbox parameter is a convenience flag, not a security control

Granular Control Parameters:

  • sandboxMode: Controls file system access level
  • approvalPolicy: Controls when user approval is required
  • fullAuto: Shorthand for sandboxMode: "workspace-write" + approvalPolicy: "on-failure"
  • yolo: ⚠️ Bypasses all safety checks (dangerous, not recommended)

Sandbox Modes

ModeDescriptionUse Case
read-onlyAnalysis only, no file modificationsCode review, exploration, documentation reading
workspace-writeCan modify files in workspaceMost development tasks, refactoring, bug fixes
danger-full-accessFull system access including networkAdvanced automation, CI/CD pipelines

Approval Policies

PolicyDescriptionWhen to Use
neverNo approvals requiredFully trusted automation
on-requestAsk before every actionMaximum control, manual review
on-failureOnly ask when operations failBalanced automation (recommended)
untrustedMaximum paranoia modeUntrusted code or high-risk changes

Configuration Examples

Example 1: Balanced Automation (Recommended)

{
  "approvalPolicy": "on-failure",
  "sandboxMode": "workspace-write",  // Auto-set if omitted in v1.2+
  "model": "gpt-5-codex",
  "prompt": "refactor @src/utils for better performance"
}

Example 2: Quick Automation (Convenience Mode)

{
  "sandbox": true,  // Equivalent to fullAuto: true
  "model": "gpt-5-codex",
  "prompt": "fix type errors in @src/"
}

Example 3: Read-Only Analysis

{
  "sandboxMode": "read-only",
  "model": "gpt-5-codex",
  "prompt": "analyze @src/ and explain the architecture"
}

Smart Defaults (v1.2+)

Starting from version 1.2.0, the server automatically applies intelligent defaults to prevent permission errors:

  • ✅ If approvalPolicy is set but sandboxMode is not → auto-sets sandboxMode: "workspace-write"
  • ✅ If search: true or oss: true → auto-sets sandboxMode: "workspace-write" (for network access)
  • ✅ All commands include --skip-git-repo-check to prevent errors in non-git environments

Troubleshooting Permission Errors

If you encounter ❌ Permission Error: Operation blocked by sandbox policy:

Check 1: Verify sandboxMode

# Ensure you're not using read-only mode for write operations
{
  "sandboxMode": "workspace-write",  // Not "read-only"
  "approvalPolicy": "on-failure"
}

Check 2: Use convenience flags

# Let the server handle defaults
{
  "sandbox": true,  // Simple automation
  "prompt": "your task"
}

Check 3: Update to latest version

# v1.2+ includes smart defaults to prevent permission errors
npm install -g @cexll/codex-mcp-server@latest

Common Issues

Issue 1: MCP Tool Timeout Error

If you encounter timeout errors when using Codex MCP tools:

# Set the MCP tool timeout environment variable (in milliseconds)
export MCP_TOOL_TIMEOUT=36000000  # 10 hours

# For Windows (PowerShell):
$env:MCP_TOOL_TIMEOUT=36000000

# For Windows (CMD):
set MCP_TOOL_TIMEOUT=36000000

Add this to your shell profile (~/.bashrc, ~/.zshrc, or PowerShell profile) to make it permanent.

Issue 2: Codex Cannot Write Files

If Codex responds with permission errors like "Operation blocked by sandbox policy" or "rejected by user approval settings", configure your Codex CLI settings:

Create or edit ~/.codex/config.toml:

# Dynamically generated Codex configuration
model = "gpt-5-codex"
model_reasoning_effort = "high"
model_reasoning_summary = "detailed"
approval_policy = "never"
sandbox_mode = "danger-full-access"
disable_response_storage = true
network_access = true

⚠️ Security Warning: The danger-full-access mode grants Codex full file system access. Only use this configuration in trusted environments and for tasks you fully understand.

Configuration File Locations:

  • macOS/Linux: ~/.codex/config.toml
  • Windows: %USERPROFILE%\.codex\config.toml

After updating the configuration, restart your MCP client (Claude Desktop, Claude Code, etc.).

Basic Ex


README truncated. View full README on GitHub.

Alternatives

Related Skills

Browse all skills
finance-skills

Production-ready financial analyst skill with ratio analysis, DCF valuation, budget variance analysis, and rolling forecast construction. 4 Python tools (all stdlib-only). Works with Claude Code, Codex CLI, and OpenClaw.

55
codex-cli-bridge

Bridge between Claude Code and OpenAI Codex CLI - generates AGENTS.md from CLAUDE.md, provides Codex CLI execution helpers, and enables seamless interoperability between both tools

7
engineering-skills

23 production-ready engineering skills covering architecture, frontend, backend, fullstack, QA, DevOps, security, AI/ML, data engineering, computer vision, and specialized tools like Playwright Pro, Stripe integration, AWS, and MS365. 30+ Python automation tools (all stdlib-only). Works with Claude Code, Codex CLI, and OpenClaw.

4
cli-builder

Guide for building TypeScript CLIs with Bun. Use when creating command-line tools, adding subcommands to existing CLIs, or building developer tooling. Covers argument parsing, subcommand patterns, output formatting, and distribution.

3
ra-qm-skills

12 production-ready regulatory affairs and quality management skills for HealthTech/MedTech: ISO 13485 QMS, MDR 2017/745, FDA 510(k)/PMA, ISO 27001 ISMS, GDPR/DSGVO compliance, risk management (ISO 14971), CAPA, document control, and internal auditing. Python tools included (all stdlib-only). Works with Claude Code, Codex CLI, and OpenClaw.

1
business-growth-skills

4 production-ready business and growth skills: customer success manager with health scoring and churn prediction, sales engineer with RFP analysis, revenue operations with pipeline and GTM metrics, and contract & proposal writer. Python tools included (all stdlib-only). Works with Claude Code, Codex CLI, and OpenClaw.

1