Skip to main content

Lightweight MCP server bridging Claude Code to OpenAI Codex via official CLI

Project description

Codex Bridge

CI Status PyPI Version MIT License Python 3.10+ MCP Compatible Codex CLI

A lightweight MCP (Model Context Protocol) server that enables AI coding assistants to interact with OpenAI's Codex AI through the official CLI. Works with Claude Code, Cursor, VS Code, and other MCP-compatible clients. Designed for simplicity, reliability, and seamless integration.

โœจ Features

  • Direct Codex CLI Integration: Zero API costs using official Codex CLI
  • Simple MCP Tools: Two core functions for basic queries and file analysis
  • Stateless Operation: No sessions, caching, or complex state management
  • Production Ready: Robust error handling with configurable timeouts (default: 90 seconds)
  • Minimal Dependencies: Only requires mcp>=1.0.0 and Codex CLI
  • Easy Deployment: Support for both uvx and traditional pip installation
  • Universal MCP Compatibility: Works with any MCP-compatible AI coding assistant

๐Ÿš€ Quick Start

Prerequisites

  1. Install Codex CLI:

    npm install -g @openai/codex-cli
    
  2. Authenticate with Codex:

    codex
    
  3. Verify installation:

    codex --version
    

Installation

๐ŸŽฏ Recommended: PyPI Installation

# Install from PyPI
pip install codex-bridge

# Add to Claude Code with uvx (recommended)
claude mcp add codex-bridge -s user -- uvx codex-bridge

Alternative: From Source

# Clone the repository
git clone https://github.com/shelakh/codex-bridge.git
cd codex-bridge

# Build and install locally
uvx --from build pyproject-build
pip install dist/*.whl

# Add to Claude Code
claude mcp add codex-bridge -s user -- uvx codex-bridge

Development Installation

# Clone and install in development mode
git clone https://github.com/shelakh/codex-bridge.git
cd codex-bridge
pip install -e .

# Add to Claude Code (development)
claude mcp add codex-bridge-dev -s user -- python -m src

๐ŸŒ Multi-Client Support

Codex Bridge works with any MCP-compatible AI coding assistant - the same server supports multiple clients through different configuration methods.

Supported MCP Clients

  • Claude Code โœ… (Default)
  • Cursor โœ…
  • VS Code โœ…
  • Windsurf โœ…
  • Cline โœ…
  • Void โœ…
  • Cherry Studio โœ…
  • Augment โœ…
  • Roo Code โœ…
  • Zencoder โœ…
  • Any MCP-compatible client โœ…

Configuration Examples

Claude Code (Default)
# Recommended installation
claude mcp add codex-bridge -s user -- uvx codex-bridge

# Development installation
claude mcp add codex-bridge-dev -s user -- python -m src
Cursor

Global Configuration (~/.cursor/mcp.json):

{
  "mcpServers": {
    "codex-bridge": {
      "command": "uvx",
      "args": ["codex-bridge"],
      "env": {}
    }
  }
}

Project-Specific (.cursor/mcp.json in your project):

{
  "mcpServers": {
    "codex-bridge": {
      "command": "uvx",
      "args": ["codex-bridge"],
      "env": {}
    }
  }
}

Go to: Settings โ†’ Cursor Settings โ†’ MCP โ†’ Add new global MCP server

VS Code

Configuration (.vscode/mcp.json in your workspace):

{
  "servers": {
    "codex-bridge": {
      "type": "stdio",
      "command": "uvx",
      "args": ["codex-bridge"]
    }
  }
}

Alternative: Through Extensions

  1. Open Extensions view (Ctrl+Shift+X)
  2. Search for MCP extensions
  3. Add custom server with command: uvx codex-bridge
Windsurf

Add to your Windsurf MCP configuration:

{
  "mcpServers": {
    "codex-bridge": {
      "command": "uvx",
      "args": ["codex-bridge"],
      "env": {}
    }
  }
}
Cline (VS Code Extension)
  1. Open Cline and click MCP Servers in the top navigation
  2. Select Installed tab โ†’ Advanced MCP Settings
  3. Add to cline_mcp_settings.json:
{
  "mcpServers": {
    "codex-bridge": {
      "command": "uvx",
      "args": ["codex-bridge"],
      "env": {}
    }
  }
}
Void

Go to: Settings โ†’ MCP โ†’ Add MCP Server

{
  "mcpServers": {
    "codex-bridge": {
      "command": "uvx",
      "args": ["codex-bridge"],
      "env": {}
    }
  }
}
Cherry Studio
  1. Navigate to Settings โ†’ MCP Servers โ†’ Add Server
  2. Fill in the server details:
    • Name: codex-bridge
    • Type: STDIO
    • Command: uvx
    • Arguments: ["codex-bridge"]
  3. Save the configuration
Augment

Using the UI:

  1. Click hamburger menu โ†’ Settings โ†’ Tools
  2. Click + Add MCP button
  3. Enter command: uvx codex-bridge
  4. Name: Codex Bridge

Manual Configuration:

"augment.advanced": { 
  "mcpServers": [ 
    { 
      "name": "codex-bridge", 
      "command": "uvx", 
      "args": ["codex-bridge"],
      "env": {}
    }
  ]
}
Roo Code
  1. Go to Settings โ†’ MCP Servers โ†’ Edit Global Config
  2. Add to mcp_settings.json:
{
  "mcpServers": {
    "codex-bridge": {
      "command": "uvx",
      "args": ["codex-bridge"],
      "env": {}
    }
  }
}
Zencoder
  1. Go to Zencoder menu (...) โ†’ Tools โ†’ Add Custom MCP
  2. Add configuration:
{
  "command": "uvx",
  "args": ["codex-bridge"],
  "env": {}
}
  1. Hit the Install button
Alternative Installation Methods

For pip-based installations:

{
  "command": "codex-bridge",
  "args": [],
  "env": {}
}

For development/local testing:

{
  "command": "python",
  "args": ["-m", "src"],
  "env": {},
  "cwd": "/path/to/codex-bridge"
}

For npm-style installation (if needed):

{
  "command": "npx",
  "args": ["codex-bridge"],
  "env": {}
}

Universal Usage

Once configured with any client, use the same two tools:

  1. Ask general questions: "What authentication patterns are used in this codebase?"
  2. Analyze specific files: "Review these auth files for security issues"

The server implementation is identical - only the client configuration differs!

โš™๏ธ Configuration

Timeout Configuration

By default, Codex Bridge uses a 90-second timeout for all CLI operations. For longer queries (large files, complex analysis), you can configure a custom timeout using the CODEX_TIMEOUT environment variable.

Git Repository Check

By default, Codex CLI requires being inside a Git repository or trusted directory. If you need to use Codex Bridge in directories that aren't Git repositories, you can set the CODEX_SKIP_GIT_CHECK environment variable.

โš ๏ธ Security Warning: Only enable this flag in trusted environments where you control the directory structure.

Example configurations:

Claude Code
# Add with custom timeout (120 seconds)
claude mcp add codex-bridge -s user --env CODEX_TIMEOUT=120 -- uvx codex-bridge

# Add with git repository check disabled (for non-git directories)
claude mcp add codex-bridge -s user --env CODEX_SKIP_GIT_CHECK=true -- uvx codex-bridge

# Add with both configurations
claude mcp add codex-bridge -s user --env CODEX_TIMEOUT=120 --env CODEX_SKIP_GIT_CHECK=true -- uvx codex-bridge
Manual Configuration (mcp_settings.json)
{
  "mcpServers": {
    "codex-bridge": {
      "command": "uvx",
      "args": ["codex-bridge"],
      "env": {
        "CODEX_TIMEOUT": "120",
        "CODEX_SKIP_GIT_CHECK": "true"
      }
    }
  }
}

Configuration Options:

CODEX_TIMEOUT:

  • Default: 90 seconds (if not configured)
  • Range: Any positive integer (seconds)
  • Recommended: 60-120 seconds for most queries, 120-300 for large file analysis
  • Invalid values: Fall back to 90 seconds with warning

CODEX_SKIP_GIT_CHECK:

  • Default: false (Git repository check enabled)
  • Valid values: "true", "1", "yes" (case-insensitive) to disable the check
  • Use case: Working in directories that are not Git repositories
  • Security: Only use in trusted directories you control

๐Ÿ› ๏ธ Available Tools

consult_codex

Direct CLI bridge for simple queries with structured JSON output by default.

Parameters:

  • query (string): The question or prompt to send to Codex
  • directory (string): Working directory for the query (default: current directory)
  • format (string): Output format - "text", "json", or "code" (default: "json")
  • timeout (int, optional): Timeout in seconds (recommended: 60-120, default: 90)

Example:

consult_codex(
    query="Find authentication patterns in this codebase",
    directory="/path/to/project",
    format="json",  # Default format
    timeout=90      # Default timeout
)

consult_codex_with_stdin

CLI bridge with stdin content for pipeline-friendly execution.

Parameters:

  • stdin_content (string): Content to pipe as stdin (file contents, diffs, logs)
  • prompt (string): The prompt to process the stdin content
  • directory (string): Working directory for the query
  • format (string): Output format - "text", "json", or "code" (default: "json")
  • timeout (int, optional): Timeout in seconds (recommended: 60-120, default: 90)

consult_codex_batch

Batch processing for multiple queries - perfect for CI/CD automation.

Parameters:

  • queries (list): List of query dictionaries with 'query' and optional 'timeout'
  • directory (string): Working directory for all queries
  • format (string): Output format - currently only "json" supported for batch

Example:

consult_codex_with_stdin(
    stdin_content=open("src/auth.py").read(),
    prompt="Analyze this auth file and suggest improvements",
    directory="/path/to/project",
    format="json",  # Default format
    timeout=120     # Custom timeout for complex analysis
)

๐Ÿ“‹ Usage Examples

Basic Code Analysis

# Simple research query
consult_codex(
    query="What authentication patterns are used in this project?",
    directory="/Users/dev/my-project"
)

Detailed File Review

# Analyze specific files
with open("/Users/dev/my-project/src/auth.py") as f:
    auth_content = f.read()
    
consult_codex_with_stdin(
    stdin_content=auth_content,
    prompt="Review this file and suggest security improvements",
    directory="/Users/dev/my-project",
    format="json",  # Structured output
    timeout=120     # Allow more time for detailed analysis
)

Batch Processing

# Process multiple queries at once
consult_codex_batch(
    queries=[
        {"query": "Analyze authentication patterns", "timeout": 60},
        {"query": "Review database implementations", "timeout": 90},
        {"query": "Check security vulnerabilities", "timeout": 120}
    ],
    directory="/Users/dev/my-project",
    format="json"  # Always JSON for batch processing
)

๐Ÿ—๏ธ Architecture

Core Design

  • CLI-First: Direct subprocess calls to codex command
  • Stateless: Each tool call is independent with no session state
  • Configurable Timeout: 90-second default execution time (configurable)
  • Structured Output: JSON format by default for better integration
  • Simple Error Handling: Clear error messages with fail-fast approach

Project Structure

codex-bridge/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ __init__.py              # Entry point
โ”‚   โ”œโ”€โ”€ __main__.py              # Module execution entry point
โ”‚   โ””โ”€โ”€ mcp_server.py            # Main MCP server implementation
โ”œโ”€โ”€ .github/                     # GitHub templates and workflows
โ”œโ”€โ”€ pyproject.toml              # Python package configuration
โ”œโ”€โ”€ README.md                   # This file
โ”œโ”€โ”€ CONTRIBUTING.md             # Contribution guidelines
โ”œโ”€โ”€ CODE_OF_CONDUCT.md          # Community standards
โ”œโ”€โ”€ SECURITY.md                 # Security policies
โ”œโ”€โ”€ CHANGELOG.md               # Version history
โ””โ”€โ”€ LICENSE                    # MIT license

๐Ÿ”ง Development

Local Testing

# Install in development mode
pip install -e .

# Run directly
python -m src

# Test CLI availability
codex --version

Integration with Claude Code

The server automatically integrates with Claude Code when properly configured through the MCP protocol.

๐Ÿ” Troubleshooting

CLI Not Available

# Install Codex CLI
npm install -g @openai/codex-cli

# Authenticate
codex auth login

# Test
codex --version

Connection Issues

  • Verify Codex CLI is properly authenticated
  • Check network connectivity
  • Ensure Claude Code MCP configuration is correct
  • Check that the codex command is in your PATH

Common Error Messages

  • "CLI not available": Codex CLI is not installed or not in PATH
  • "Authentication required": Run codex auth login
  • "Timeout after X seconds": Query took too long, try increasing timeout or breaking into smaller parts

๐Ÿค Contributing

We welcome contributions from the community! Please read our Contributing Guidelines for details on how to get started.

Quick Contributing Guide

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

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ”„ Version History

See CHANGELOG.md for detailed version history.

๐Ÿ†˜ Support

  • Issues: Report bugs or request features via GitHub Issues
  • Discussions: Join the community discussion
  • Documentation: Additional docs can be created in the docs/ directory

Focus: A simple, reliable bridge between Claude Code and Codex AI through the official CLI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codex_bridge-1.2.3.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codex_bridge-1.2.3-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file codex_bridge-1.2.3.tar.gz.

File metadata

  • Download URL: codex_bridge-1.2.3.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for codex_bridge-1.2.3.tar.gz
Algorithm Hash digest
SHA256 755758922fcb60dfd757682b5e6cf4f8a2039fab24201ac9321c144db5c7dc24
MD5 1522b17d88417eca938cec2f5a0206a4
BLAKE2b-256 7d4e86c168ab767cc27e8c1b879f1cf1a78d863e20750b9f29d6f67cc21f3824

See more details on using hashes here.

Provenance

The following attestation bundles were made for codex_bridge-1.2.3.tar.gz:

Publisher: release.yml on eLyiN/codex-bridge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file codex_bridge-1.2.3-py3-none-any.whl.

File metadata

  • Download URL: codex_bridge-1.2.3-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for codex_bridge-1.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a7a6f7a62cbdc58e46dcfea636aeb3e3129f59556ebf0bac08ce53c2cb8b702c
MD5 c404af80da347b1e5746e95c0948a4e3
BLAKE2b-256 88609270a6d13672c5acbcc1eb764819e8c7d0a1a3650fc9ffed9c7d90536092

See more details on using hashes here.

Provenance

The following attestation bundles were made for codex_bridge-1.2.3-py3-none-any.whl:

Publisher: release.yml on eLyiN/codex-bridge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page