codex-cli-mcp-tool

codex-cli-mcp-tool

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

Category
Visit Server

README

Codex CLI MCP Server

An MCP server that allows Claude Code to interact with the OpenAI Codex CLI. If you have a ChatGPT subscription and a claude code subscription, you can use this tool to get the benefits of both, as a $20 ChatGPT subscription gives you access to GPT-5 for free in Codex CLI.

Features

  • Complete Codex Integration: Access all Codex CLI capabilities through MCP
  • GPT-5 Model: Powered by OpenAI's most capable model
  • Sandbox Safety: Configurable execution modes (read-only, workspace-write, full-access)
  • Progress Tracking: Real-time updates for long-running operations
  • Git Integration: Apply Codex-generated diffs directly to repositories
  • Flexible Configuration: Environment variables and config file support

Installation

  1. Install Codex CLI (required):

    npm install -g @openai/codex
    
  2. Add to Claude Code using npx:

    claude mcp add codex-cli-mcp-tool -- npx -y codex-cli-mcp-tool
    

    Or install globally first:

    npm install -g codex-cli-mcp-tool
    
  3. Configure Authentication:

    # Option 1: Use API key
    export OPENAI_API_KEY=your-api-key
    
    # Option 2: Login with ChatGPT account
    codex login
    

Available Tools

ask-codex

Execute Codex with comprehensive parameter support for code analysis, generation, and assistance.

Parameters:

  • prompt (required): Your query or instruction
  • model (optional): gpt-5 (default and only supported model)
  • sandbox (optional): read-only, workspace-write, danger-full-access
  • approval (optional): untrusted, on-failure, on-request, never
  • image (optional): Image file path(s) to include
  • config (optional): Configuration overrides
  • timeout (optional): Maximum execution time

Example:

ask-codex "Explain this code: @main.py" sandbox="read-only"

exec-codex

Non-interactive Codex execution for automation workflows.

Parameters:

  • prompt (required): Command or instruction
  • model (optional): Always gpt-5
  • sandbox (optional): Sandbox mode
  • timeout (optional): Execution timeout

apply-diff

Apply the latest Codex-generated diff to your git repository.

Parameters:

  • dryRun (optional): Preview changes without applying
  • validate (optional): Validate before applying

Utility Tools

  • ping: Test MCP connection
  • help: Show detailed help information
  • version: Display version information

Configuration

Environment Variables

OPENAI_API_KEY=sk-...           # OpenAI API key
CODEX_MODEL=gpt-5               # Default model
CODEX_SANDBOX_MODE=read-only    # Default sandbox mode

Config File (~/.codex/config.toml)

[model]
provider = "openai"
default = "gpt-5"
reasoning_effort = "medium"

[sandbox]
default_mode = "read-only"
permissions = ["disk-read-access"]

[approval]
policy = "untrusted"
trusted_commands = ["ls", "cat", "grep"]

Sandbox Modes

  • read-only: Safe exploration, no file modifications
  • workspace-write: Limited modifications within project
  • danger-full-access: Full system access (requires confirmation)

Examples

Code Analysis

ask-codex "Review this function for security issues: @auth.py"

Code Generation

ask-codex "Generate unit tests for the User class" sandbox="workspace-write"

Debugging

ask-codex "Fix the bug in login function" approval="on-request"

File Operations

ask-codex "Create a new React component for user profile" sandbox="workspace-write"

Apply Changes

ask-codex "Refactor this code to use async/await"
apply-diff validate=true

Troubleshooting

Common Issues

  1. Codex CLI not found:

    npm install -g @openai/codex
    
  2. Authentication failed:

    # Set API key
    export OPENAI_API_KEY=your-key
    
    # Or login
    codex login
    
  3. Permission denied:

    • Use appropriate sandbox mode
    • Check approval policy settings
    • Verify file permissions
  4. Rate limits:

    • Wait before retrying
    • Check OpenAI account quota

Debug Mode

Enable debug logging:

DEBUG=true codex-cli-mcp-tool

Development

Setup

git clone <repository>
cd codex-cli-tool
npm install
npm run build
npm run dev

Testing

npm test
npm run lint

Acknowledgments

This project is based on the excellent Gemini MCP Tool by jamubc. We adapted their architecture and patterns to create this Codex CLI integration.

License

MIT License - see LICENSE file for details.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

Support

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured