codex-mcp-server
This MCP server connects MCP clients to the OpenAI Codex CLI for non-interactive code analysis, editing, review, brainstorming, and batch automation.
Ask Codex questions or analyze code using
@file references, images, model/reasoning choices, web search, config profiles, and timeouts.Edit/refactor code in workspace-write sandbox mode with approval controls, or return structured OLD/NEW edits via change mode.
Review git changes (uncommitted work, branch vs base, or a commit) with prioritized
file:linefindings.Run multiple Codex tasks in batch, optionally in parallel or stopping on error.
Brainstorm ideas with structured frameworks such as SCAMPER, design-thinking, lateral, and divergent/convergent methods.
List supported models/reasoning levels, fetch cached change chunks, ping the server, show help/version, and test timeouts.
Configure defaults via environment variables and run cross-platform on Windows, macOS, and Linux.
Connects to OpenAI's Codex CLI to enable code analysis, editing, and automation within your IDE or AI assistant.
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., "@codex-mcp-server explain the architecture of @src/"
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.
Codex MCP Tool
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.4.0): Works with current Codex CLI (tested on 0.153): fixes
sandbox/fullAutocalls broken by the removed--full-autoflag, adds areviewtool for git changes and alist-modelstool, and no longer pins a frozen model list. See changelog
Ask Codex questions from your MCP client, or brainstorm ideas programmatically.
TLDR:
+ Codex CLI
Goal: Use Codex directly from your MCP-enabled editor to analyze and edit code efficiently.
Related MCP server: codex-mcp-tool
Prerequisites
Before using this tool, ensure you have:
✅ Cross-Platform Support: Fully tested and working on Windows, macOS, and Linux (v1.2.4+)
Check the CLI works on its own first: codex --version and codex exec "say hi".
Claude Code: plugin (recommended)
This repository is its own Claude Code plugin marketplace (self-hosted; it is not listed in Anthropic's official marketplace). In Claude Code, run:
/plugin marketplace add etheaven/codex-mcp-server
/plugin install codex-mcp-server@codex-mcp-serverClaude Code: plain MCP server
claude mcp add codex-cli -- npx -y https://github.com/etheaven/codex-mcp-server/releases/download/v1.4.0/etheaven-codex-mcp-server-1.4.0.tgzThe commands here install from the GitHub release. The npm package @etheaven/codex-mcp-server can lag behind (npm still serves 1.3.9, which breaks on Codex CLI 0.153 and newer); use the release URL until npm shows the same version.
Cursor
Add to ~/.cursor/mcp.json (global) or .cursor/mcp.json (per project):
{
"mcpServers": {
"codex-cli": {
"command": "npx",
"args": ["-y", "https://github.com/etheaven/codex-mcp-server/releases/download/v1.4.0/etheaven-codex-mcp-server-1.4.0.tgz"]
}
}
}Other MCP clients
Any client that launches stdio MCP servers works: the command is npx -y https://github.com/etheaven/codex-mcp-server/releases/download/v1.4.0/etheaven-codex-mcp-server-1.4.0.tgz (or codex-mcp after a global install).
Verify Installation
Type /mcp inside Claude Code (or open Cursor's MCP settings) and check the server is connected. Then ask: "use codex list-models".
Environment Variables
Variable | Default | Purpose |
| client working dir | Directory Codex runs in when a call does not pass |
|
| Default per-call timeout; a call's |
|
| Responses longer than this are truncated so they do not flood the client's context |
| client-specific | Claude Code's own MCP tool timeout; raise it together with |
Example: claude mcp add codex-cli -e CODEX_MCP_TIMEOUT_MS=1800000 -- npx -y https://github.com/etheaven/codex-mcp-server/releases/download/v1.4.0/etheaven-codex-mcp-server-1.4.0.tgz
Configuration
Claude Desktop
Add to your Claude Desktop config file:
{
"mcpServers": {
"codex-cli": {
"command": "npx",
"args": ["-y", "https://github.com/etheaven/codex-mcp-server/releases/download/v1.4.0/etheaven-codex-mcp-server-1.4.0.tgz"]
}
}
}Config file locations:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.jsonLinux:
~/.config/claude/claude_desktop_config.json
Global Installation
npm install -g https://github.com/etheaven/codex-mcp-server/releases/download/v1.4.0/etheaven-codex-mcp-server-1.4.0.tgzThen use "command": "codex-mcp" instead of the npx approach.
After updating 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"
"use codex to review my uncommitted changes", "have codex review this branch against main"
Claude Code: the server's prompts also appear in the
/slash-command menu.
Usage Examples
Model Selection
By default Codex uses the model and model_reasoning_effort from your ~/.codex/config.toml, which is usually what you want. OpenAI changes the model lineup often, so this server does not hard-code model names: any model string is passed to Codex as-is. To see what your Codex install supports, call the list-models tool (it wraps codex debug models):
// Use your configured default model
'explain the architecture of @src/';
// Ask which models and reasoning levels are available
'use codex list-models';
// Pick one explicitly, with a reasoning level that model supports
'use codex with model <id from list-models> and reasoning high to analyze @algorithm.py';With File References (using @ syntax)
ask codex to analyze @src/main.ts and explain what it doesuse codex to summarize @. the current directoryanalyze @package.json and list dependencies
General Questions (without files)
ask codex to explain div centeringask 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 methoduse codex to brainstorm 10 innovative features for our app with feasibility analysisask 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→ same asfullAuto: true: runs Codex with--sandbox workspace-writeso it can edit files in the working directorysandbox: false(default) → Codex uses the sandbox from your config, which isread-onlyunless you changed itCodex CLI removed its
--full-autoflag; since v1.4.0 this server mapsfullAutoto--sandbox workspace-writeinstead
Granular Control Parameters:
sandboxMode: Controls file system access levelapprovalPolicy: Controls when user approval is required (codex execis non-interactive, so in practice commands either run or fail)fullAuto: Shorthand forsandboxMode: "workspace-write"yolo: ⚠️ Bypasses all safety checks (dangerous, not recommended)
Sandbox Modes
Mode | Description | Use Case |
| Analysis only, no file modifications | Code review, exploration, documentation reading |
| Can modify files in workspace | Most development tasks, refactoring, bug fixes |
| Full system access including network | Advanced automation, CI/CD pipelines |
Approval Policies
Policy | Description | When to Use |
| No approvals required | Fully trusted automation |
| The model decides when to ask | Default in recent Codex CLI |
| Legacy; still accepted by Codex | Older configs |
| Legacy; still accepted by Codex | Older configs |
Configuration Examples
Example 1: Balanced Automation (Recommended)
{
"approvalPolicy": "never",
"sandboxMode": "workspace-write", // Auto-set if omitted in v1.2+
"prompt": "refactor @src/utils for better performance"
}Example 2: Quick Automation (Convenience Mode)
{
"sandbox": true, // Equivalent to fullAuto: true (workspace-write)
"prompt": "fix type errors in @src/"
}Example 3: Read-Only Analysis
{
"sandboxMode": "read-only",
"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
approvalPolicyis set butsandboxModeis not → auto-setssandboxMode: "workspace-write"✅
search: trueuses Codex's--searchflag (live web search) and no longer changes the sandbox (v1.4.0)✅ All commands include
--skip-git-repo-checkto prevent errors in non-git environments✅ Prompts are sent on stdin, so very large prompts no longer hit OS command-line limits (v1.4.0)
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": "never"
}Check 2: Use convenience flags
# Let the server handle defaults
{
"sandbox": true, // Simple automation
"prompt": "your task"
}Check 3: Update to latest version
# install the newest GitHub release (see https://github.com/etheaven/codex-mcp-server/releases)
npm install -g https://github.com/etheaven/codex-mcp-server/releases/download/v1.4.0/etheaven-codex-mcp-server-1.4.0.tgzCommon Issues
Issue 1: MCP Tool Timeout Error
If you encounter timeout errors when using Codex MCP tools:
# Claude Code's MCP tool timeout (in milliseconds)
export MCP_TOOL_TIMEOUT=1800000 # 30 minutes
# This server's own per-call timeout (default 10 minutes)
export CODEX_MCP_TIMEOUT_MS=1800000
# For Windows (PowerShell):
$env:MCP_TOOL_TIMEOUT=1800000
# For Windows (CMD):
set MCP_TOOL_TIMEOUT=1800000Add 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:
approval_policy = "never"
sandbox_mode = "workspace-write"
[sandbox_workspace_write]
network_access = true # only if Codex must reach the network from its shellOnly switch to sandbox_mode = "danger-full-access" if Codex must write outside the workspace.
⚠️ 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.tomlWindows:
%USERPROFILE%\.codex\config.toml
After updating the configuration, restart your MCP client (Claude Desktop, Claude Code, etc.).
Basic Examples
use codex to create and run a Python script that processes dataask codex to safely test @script.py and explain what it does
Default Behavior:
All
codex execcommands automatically include--skip-git-repo-checkto avoid unnecessary git repository checks, as not all execution environments are git repositories.This prevents permission errors when running Codex in non-git directories or when git checks would interfere with automation.
Advanced Examples
// Using ask-codex with specific model and reasoning effort
'ask codex using gpt-5.3-codex with reasoning high to refactor @utils/database.js for better performance';
// Brainstorming with constraints
"brainstorm solutions for reducing API latency with constraints: 'must use existing infrastructure, budget under $5k'";
// Change mode for structured edits
'use codex in change mode to update all console.log to use winston logger in @src/';Tools (for the AI)
These tools are designed to be used by the AI assistant.
Core Tools
ask-codex: Sends a prompt to Codex viacodex exec.Supports
@file references for including file contentOptional
model: any ID your Codex CLI accepts; omit it to use your config default (seelist-models)Optional
reasoningEffort: e.g.low,medium,high,xhigh,max(per-model support, seelist-models)sandbox=truelets Codex edit files (--sandbox workspace-write)changeMode=truereturns structured OLD/NEW editsSupports approval policies and sandbox modes
Automatically includes
--skip-git-repo-checkto prevent permission errors in non-git environments
review: Runscodex reviewon git changes and returns prioritized findings withfile:linereferences.One target:
uncommitted: true,base: "main"orcommit: "<sha>"Or free-form
promptinstructions with no target (Codex CLI does not accept both)workingDirpicks the repository; read-only
list-models: Lists the models and reasoning levels the installed Codex CLI supports (codex debug models).brainstorm: Generate novel ideas with structured methodologies.Multiple frameworks: divergent, convergent, SCAMPER, design-thinking, lateral
Domain-specific context (software, business, creative, research, product, marketing)
Supports same models and
reasoningEffortasask-codexConfigurable idea count and analysis depth
Includes feasibility, impact, and innovation scoring
Example:
brainstorm prompt:"ways to improve code review process" domain:"software" methodology:"scamper"
ping: A simple test tool that echoes back a message.Use to verify MCP connection is working
Example:
/codex-cli:ping (MCP) "Hello from Codex MCP!"
help: Shows the Codex CLI help text and available commands.
Advanced Tools
fetch-chunk: Retrieves cached chunks from changeMode responses.Used for paginating large structured edit responses
Requires
cacheKeyandchunkIndexparameters
timeout-test: Test tool for timeout prevention.Runs for a specified duration in milliseconds
Useful for testing long-running operations
Slash Commands (for the User)
You can use these commands directly in Claude Code's interface (compatibility with other clients has not been tested).
/analyze: Analyzes files or directories using Codex, or asks general questions.
prompt(required): The analysis prompt. Use@syntax to include files (e.g.,/analyze prompt:@src/ summarize this directory) or ask general questions (e.g.,/analyze prompt:Please use a web search to find the latest news stories).
/sandbox: Safely tests code or scripts with Codex approval modes.
prompt(required): Code testing request (e.g.,/sandbox prompt:Create and run a Python script that processes CSV dataor/sandbox prompt:@script.py Test this script safely).
/help: Displays the Codex CLI help information.
/ping: Tests the connection to the server.
message(optional): A message to echo back.
Recent Updates
v1.4.0 (2026-11-08)
🐛 Fixes for current Codex CLI (tested on 0.153.4):
sandbox: true/fullAuto: truefailed withunexpected argument '--full-auto'; now mapped to--sandbox workspace-writesearch: truenow uses Codex's--searchflag instead of the deprecatedweb_search_requestfeature, and no longer forces a writable sandboxPrompts are sent on stdin;
brainstormprompts over 100 KB were previously passed to Codex as a literal< /tmp/filestringimageattachments: Codex's greedy-iswallowed theexecsubcommand, so image calls did not runcodex execconfigobjects become one-c key=valueper entry (they were joined into a single invalid-c)Timeouts are reported only for real timeouts (an output-size kill was misreported as a timeout)
✨ New:
reviewtool forcodex review(uncommitted changes, branch vs base, single commit), based on the idea in upstream PR cexll/codex-mcp-server#6list-modelstool;modelandreasoningEffortare free-form, so new models and levels such asmaxwork without a server releaseCODEX_MCP_TIMEOUT_MSandCODEX_MCP_MAX_RESPONSE_CHARSenvironment variablesClearer errors: unsupported model/effort, CLI flag mismatches, and timeouts say what to change
Server and
versiontool report the real package version (theversiontool said v1.2.5)First real test suite (
npm test, 23 tests), now required in CI and release
v1.3.9 (2026-04-01)
Truncate responses above 16k characters so oversized results do not break Claude Code
Concise-response instruction added to every
ask-codexcall
v1.3.8 (2026-03-30)
📦 Release Fix:
Added
search-insightsto devDependencies sonpm cipasses in the GitHub release workflowThis is the first publishable release that includes the empty
ask-codexresponse fix
v1.3.7 (2026-03-30)
📦 Release Fix:
Synced
package-lock.jsonwithpackage.jsonso the GitHub release workflow can completenpm ciand publish successfullyCarries forward the empty
ask-codexresponse fix from the failedv1.3.6release attempt
v1.3.6 (2026-03-30)
🐛 Bug Fixes:
Fixed empty
ask-codexresponses when Codex CLI emitted the usable transcript onstderrReworked output parsing to handle role-based transcript sections like
user,codex, andassistantPrevented the formatter from returning a bare
**Response:**header when no response content was parsed
📦 Release Metadata:
Synced npm, lockfile, and Claude marketplace/plugin metadata to version
1.3.6
v1.3.0 (2026-03-15)
Model Support Overhaul:
Updated model list to March 2026: added gpt-5.4, gpt-5.4-pro, gpt-5.3-codex, gpt-5.3-codex-spark, gpt-5.2-codex, gpt-5.2, gpt-5.1-codex-max, gpt-5.1-codex, gpt-5.1, gpt-5-pro, gpt-5-mini, gpt-5-nano, o3-pro, gpt-4.1-mini, gpt-4.1-nano
Removed deprecated models:
codex-1andcodex-mini-latest(never existed in OpenAI API)New
reasoningEffortparameter for ask-codex, brainstorm, and batch-codex tools — supportsnone,minimal,low,medium,high,xhighImproved tool schema descriptions with exact valid model IDs to prevent AI clients from inventing model names
Updated default model recommendation from
gpt-5-codextogpt-5.4Comprehensive model documentation rewrite with per-model reasoning effort support tables
v1.2.4 (2025-10-27)
🔧 Major Improvement:
Windows Compatibility Enhancement: Replaced Node.js native
spawn()with industry-standardcross-spawnpackageRoot cause: Previous
shell: truefix still failed on some Windows configurationsSolution: Use
cross-spawn(50M+ weekly downloads, used by Webpack/Jest) for automatic Windows.cmdhandlingBenefits:
Zero configuration required for Windows users
Automatic handling of
.cmd,.ps1, and.exeextensionsCompatible with both CMD and PowerShell environments
<5ms performance overhead
Dependencies: Added
cross-spawn@^7.0.6and@types/cross-spawn
🐛 Bug Fixes:
Enhanced ENOENT error diagnostics with Windows-specific 4-step troubleshooting guide
Added optional chaining for
stdout/stderrto handle null values in TypeScript strict mode
📝 Documentation:
Added comprehensive Windows troubleshooting section in docs
Documented
spawn codex ENOENTerror resolution steps
v1.2.3 (2025-10-27)
🐛 Bug Fixes:
Windows Compatibility: Fixed Codex CLI detection failing on Windows despite proper installation
Root cause:
spawn()withshell: falsecouldn't resolve.cmdextensions on WindowsSolution: Enabled shell mode for cross-platform command execution
Impact: Zero performance impact (~10ms overhead), maintains security with array-form arguments
Platforms verified: Windows, macOS, Linux via GitHub Actions CI
📝 Documentation:
Updated all package references from
@trishchuk/codex-mcp-toolto@etheaven/codex-mcp-server(now hosted at etheaven/codex-mcp-server)Enhanced cross-platform setup instructions
🔍 Testing:
CI/CD now validates on Ubuntu, macOS, and Windows across Node.js 18.x, 20.x, and 22.x
v1.2.2 & Earlier
Smart sandbox mode defaults to prevent permission errors
Enhanced debug information for troubleshooting
Automatic
--skip-git-repo-checkflag for non-git environmentsWeb search integration with feature flags
Structured change mode with pagination support
Platform Support
Platform | Status | Notes |
Windows | ✅ Fully Supported | Enhanced in v1.2.4 with cross-spawn |
macOS | ✅ Fully Supported | Tested on Darwin 23.5.0+ |
Linux | ✅ Fully Supported | Tested on Ubuntu Latest |
Minimum Requirements:
Node.js v18.0.0 or higher
Codex CLI installed and authenticated (
npm install -g @openai/codex); v1.4.0 is tested against Codex CLI 0.153
Acknowledgments
This project was inspired by the excellent work from jamubc/gemini-mcp-tool. Special thanks to @jamubc for the original MCP server architecture and implementation patterns.
Contributing
Contributions are welcome! Please submit pull requests or report issues through GitHub.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Disclaimer: This is an unofficial, third-party tool and is not affiliated with, endorsed, or sponsored by OpenAI.
Available Tools
10 toolsask-codexA
Use OpenAI Codex to analyze, review, edit, or generate code. Call this tool whenever the user mentions "codex", "use codex", or wants a second opinion from OpenAI models on code. Supports file references with @ syntax (e.g. @src/), model selection (see list-models), reasoning effort, and structured edits via changeMode. Read-only by default; set sandbox: true to let Codex edit files. For reviewing git changes prefer the review tool.
Inputs: prompt (required), cd, oss, yolo, +20 more.
batch-codexA
Run multiple tasks through OpenAI Codex in batch. Use when the user wants Codex to handle several tasks sequentially — mass refactoring, bulk code changes, or automated transformations.
Inputs: tasks (required), oss, model, search, +8 more.
brainstormB
Brainstorm ideas using OpenAI Codex with structured frameworks (SCAMPER, design-thinking, lateral, etc.). Use when the user wants creative ideation, brainstorming, or idea generation via Codex.
Inputs: prompt (required), cd, oss, yolo, +15 more.
fetch-chunkA
Retrieves cached chunks from a changeMode response. Use this to get subsequent chunks after receiving a partial changeMode response.
Inputs: cacheKey (required), chunkIndex (required).
HelpC
receive help information
Inputs: no named parameters.
list-modelsA
List the model IDs and reasoning effort levels the installed Codex CLI supports. Call this before passing a model or reasoningEffort to other Codex tools.
Inputs: includeHidden.
pingC
Echo
Inputs: prompt.
reviewA
Run a Codex code review (codex review) on git changes: uncommitted work, a branch against a base, or a single commit. Returns prioritized findings with file:line references. Read-only.
Inputs: base, model, title, commit, +5 more.
timeout-testA
Test timeout prevention by running for a specified duration
Inputs: duration (required).
versionA
Display version and system information
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 10 tools
Core Codex tools are mostly distinct: ask-codex handles general requests, batch-codex handles multiple sequential tasks, review targets git changes, and brainstorm targets ideation. There is some overlap because ask-codex is broad enough to cover review, editing, and idea generation, but the descriptions provide clear routing guidance.
Most names use kebab-case, but the set mixes verb_noun names like ask-codex and list-models with single-word names like review, brainstorm, ping, and version, plus the capitalized Help. The convention is readable but not fully consistent.
Ten tools is a reasonable size for a Codex integration, with six domain tools and four generic utility tools. The count is well within range, though ping, timeout-test, and Help are boilerplate rather than core Codex capabilities.
The surface covers the main Codex workflows: general requests, batch processing, code review, brainstorming, model discovery, and chunk retrieval. Minor gaps exist around task status, cancellation, or conversation continuation, but core workflows are covered.
Maintenance
Related MCP Connectors
Shared memory MCP server for Claude Code, Codex, Gemini CLI and Cursor. Cited, editable.
An MCP server that gives your AI access to the source code and docs of all public github repos
MCP server that lets your AI assistant build and deploy apps, hosting each one at a live URL.
A paid remote MCP for OpenAI Codex agent coordination MCP, built to return verdicts, receipts, usage
Related MCP Servers
- AlicenseAqualityDmaintenanceAn MCP server that provides technical consultation, code review, and code explanation by integrating with OpenAI's Codex CLI, enabling AI-powered coding assistance in a sandboxed, read-only environment.340 npm1MIT
- AlicenseBqualityCmaintenanceMCP server connecting Claude/Cursor to Codex CLI, enabling code analysis via @ file references, multi-turn conversations, sandboxed edits, and structured change mode.13100 npm24MIT
- AlicenseNot gradedqualityDmaintenanceLocal MCP server enabling Codex and ChatGPT to read/write files, execute commands, manage processes, use Git, and inspect images on the user's machine with full privileges.Apache 2.0
- AlicenseNot gradedqualityDmaintenanceA self-hosted MCP server that brings a Codex-style coding workflow to ChatGPT, allowing it to read, edit, search, and run code in your local projects.MIT