Codex CLI MCP

v1.0.0Developer Toolsstable

MCP server that allows Claude Code to interact with OpenAI Codex CLI

codex-cli-mcp-toolmcpai-integration
Share:
22
Stars
0
Downloads
0
Weekly
0/5

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

Allow Claude Code to interact with OpenAI Codex CLI tools.
Mr-Tomahawk

Maintainer

LicenseMIT
Languagetypescript
Versionv1.0.0
UpdatedMay 14, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx codex-cli-mcp-tool

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

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
1

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/codex
2

Set 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-access
3

Add 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-tool
4

Verify 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.

5

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.

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.

Quick Config Preview

{ "mcpServers": { "codex-cli-mcp-tool": { "command": "npx", "args": ["-y", "codex-cli-mcp-tool"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

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.

33,000+ ServersFree & Open SourceStep-by-Step Guides