Codex CLI MCP
MCP server that allows Claude Code to interact with OpenAI Codex CLI
What is Codex CLI MCP?
Codex CLI MCP is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to mcp server that allows claude code to interact with openai codex cli
MCP server that allows Claude Code to interact with OpenAI Codex CLI
This server falls under the Developer Tools category on MCPgee, the world's largest MCP server directory with 33,000+ servers.
Features
- MCP server that allows Claude Code to interact with OpenAI C
Use Cases
Maintainer
Works with
Installation
Manual Installation
npx codex-cli-mcp-toolConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
How to Set Up and Use Codex CLI MCP
The Codex CLI MCP tool is a bridge that allows Claude Code to invoke OpenAI's Codex CLI directly as MCP tools, giving Claude the ability to run Codex-powered code analysis, generation, and diff application workflows without leaving the Claude interface. It exposes four tools — ask-codex, exec-codex, apply-diff, and utility commands — that cover interactive code assistance, automated non-interactive pipelines, and applying generated diffs to a git repository. Developers use it to chain Claude's reasoning with Codex's code-execution capabilities for review, refactoring, and test-generation tasks.
Prerequisites
- Node.js and npm installed
- OpenAI Codex CLI installed globally (npm install -g @openai/codex)
- An OpenAI API key with access to Codex models (set as OPENAI_API_KEY)
- Claude Code CLI installed and configured
Install the OpenAI Codex CLI globally
The MCP tool wraps the Codex CLI, so the CLI must be available on your PATH before the MCP server can use it.
npm install -g @openai/codexSet your OpenAI API key
Export the OPENAI_API_KEY environment variable so the Codex CLI can authenticate. You can also set CODEX_MODEL to choose a specific model (defaults to gpt-5) and CODEX_SANDBOX_MODE to control file permissions (defaults to read-only).
export OPENAI_API_KEY=sk-your-openai-api-key
export CODEX_MODEL=gpt-4o # optional override
export CODEX_SANDBOX_MODE=read-only # read-only | workspace-write | danger-full-accessAdd the MCP tool to Claude Code
Register the codex-cli-mcp-tool with Claude Code using the mcp add command. This will run the server via npx each time Claude Code starts.
claude mcp add codex-cli-mcp-tool -- npx -y codex-cli-mcp-toolVerify the tools are available
Restart Claude Code and ask it to list available MCP tools, or ask a simple coding question to confirm ask-codex is reachable.
Optional: configure via Codex config file
For persistent settings, edit ~/.codex/config.toml to set your preferred model, sandbox mode, and approval policy without exporting environment variables each session.
# ~/.codex/config.toml
[model]
provider = "openai"
default = "gpt-4o"
[sandbox]
default_mode = "read-only"
[approval]
policy = "unless-allow-listed"Codex CLI MCP Examples
Client configuration
Claude Desktop configuration to run codex-cli-mcp-tool via npx with the OpenAI API key set in the environment.
{
"mcpServers": {
"codex-cli-mcp-tool": {
"command": "npx",
"args": ["-y", "codex-cli-mcp-tool"],
"env": {
"OPENAI_API_KEY": "sk-your-openai-api-key",
"CODEX_MODEL": "gpt-4o",
"CODEX_SANDBOX_MODE": "read-only"
}
}
}
}Prompts to try
Example prompts that use the ask-codex and exec-codex tools through Claude Code.
- "Use ask-codex to review auth.py for security vulnerabilities"
- "Run exec-codex to generate unit tests for my UserService class non-interactively"
- "Ask Codex to refactor this function for readability and then apply the generated diff to the repo"
- "Use ask-codex with workspace-write sandbox to add type hints to all functions in utils.py"Troubleshooting Codex CLI MCP
ask-codex returns 'command not found' or fails to start
Ensure the Codex CLI is installed globally with 'npm install -g @openai/codex' and that the global npm bin directory is in your PATH. Run 'codex --version' in a terminal to verify.
OPENAI_API_KEY not found or authentication errors
Make sure OPENAI_API_KEY is set in the env block of your MCP config (not just in your shell), since Claude Desktop does not inherit shell environment variables.
apply-diff fails to apply changes to the repository
Confirm CODEX_SANDBOX_MODE is set to workspace-write or danger-full-access — the default read-only mode prevents file modifications. Also ensure the working directory pointed to by the tool contains a valid git repository.
Frequently Asked Questions about Codex CLI MCP
What is Codex CLI MCP?
Codex CLI MCP is a Model Context Protocol (MCP) server that mcp server that allows claude code to interact with openai codex cli It connects AI assistants to external tools and data sources through a standardized interface.
How do I install Codex CLI MCP?
Follow the installation instructions on the Codex CLI MCP GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.
Which AI clients work with Codex CLI MCP?
Codex CLI MCP works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.
Is Codex CLI MCP free to use?
Yes, Codex CLI MCP is open source and available under the MIT license. You can use it freely in both personal and commercial projects.
Codex CLI MCP Alternatives — Similar Developer Tools Servers
Looking for alternatives to Codex CLI MCP? Here are other popular developer tools servers you can use with Claude, Cursor, and VS Code.
Ecc
★ 188.2kThe agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
Javaguide
★ 155.8kJava 面试 & 后端通用面试指南,覆盖计算机基础、数据库、分布式、高并发、系统设计与 AI 应用开发
Gemini CLI
★ 104.5kA secure MCP server that wraps the Google Gemini CLI, allowing clients to query Gemini models using local OAuth sessions without requiring an API key. It provides tools for model interaction and diagnostics with built-in protection against command in
Awesome MCP Servers
★ 87.3k⭐ Curated list of Model Context Protocol (MCP) servers - tools that extend Claude Desktop, Cursor, Windsurf, and other MCP clients with custom capabilities.
MCP Servers
★ 86.0kModel Context Protocol Servers
CC Switch
★ 77.5kA cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Gemini CLI & Hermes Agent. Only official website: ccswitch.io
Browse More Developer Tools MCP Servers
Explore all developer tools servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.
Set Up Codex CLI MCP in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
Ready to use Codex CLI MCP?
Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.