Codex Bridge

Codex Bridge

A self-hosted MCP server that lets claude.ai delegate tasks to OpenAI Codex CLI, billed through the ChatGPT subscription, with tools for job submission, status polling, and result retrieval.

Category
访问服务器

README

Codex Bridge

A self-hosted MCP server that lets claude.ai (and other MCP clients) delegate work to OpenAI Codex CLI — billed through the operator's existing ChatGPT subscription, not per-token API usage.

Why

Claude Code can already shell out to Codex CLI locally (via codex-plugin-cc) because it has a local shell. claude.ai has no shell — custom MCP connectors are reached from Anthropic's cloud over HTTPS, with no way to run a local CLI. Codex Bridge closes that gap: a small always-on server, designed to run on a personal VPS, that exposes Codex CLI as MCP tools over HTTPS using a ChatGPT-authenticated Codex CLI session running on the server itself.

Architecture

claude.ai ──HTTPS(OAuth 2.1)──▶ Codex Bridge MCP Server ──subprocess──▶ Codex CLI ──ChatGPT session──▶ OpenAI
(Anthropic's cloud)                   (your VPS)                        (codex exec)
  • MCP server: Python, MCP Python SDK (FastMCP) directly — no separate web framework. Streamable HTTP transport.
  • Job manager: wraps codex exec as a detached subprocess per job. State (queued/running/done/errored/cancelled) and captured stdout/stderr paths persist in SQLite, so a server restart doesn't orphan job tracking. Every job is confined to an explicit working-directory allowlist — the tools never accept an arbitrary filesystem path.
  • Auth: OAuth 2.1 (dynamic client registration + PKCE), the only thing claude.ai's Connectors feature actually speaks. One resource owner (username/password you set at install time), tokens persisted to SQLite.

MCP tools

Tool Purpose
codex_delegate(prompt, working_dir, model?) Submit a task, returns a job_id immediately
codex_status(job_id) Cheap poll — job state and timestamps
codex_result(job_id, max_chars?) Tailed stdout/stderr once the job is done or errored
codex_cancel(job_id) Cancel a running or queued job

codex_delegate never blocks on the Codex run — MCP tool calls must return quickly, and Codex jobs can run for minutes. Submit, then poll.

Install

Requires a Linux box you control (tested against Ubuntu). You'll need root.

git clone https://github.com/jonwadsworth/codex-bridge.git /opt/codex-bridge
cd /opt/codex-bridge
sudo ./setup/install.sh

The installer is idempotent — checks for/installs uv, Node, and Codex CLI; runs codex login (you complete the ChatGPT sign-in yourself, in your own browser — the installer never touches your credentials); prompts for your domain, a working-directory allowlist, and a login credential; generates /etc/codex-bridge/env; installs and starts the systemd service on 127.0.0.1:8427.

You still need to do two things it can't do for you:

  1. Point a reverse proxy or tunnel (Cloudflare Tunnel, nginx+certbot, etc.) at http://localhost:8427 for your domain — Codex Bridge only binds loopback.
  2. Add https://<your-domain>/mcp as a custom connector in claude.ai (Settings → Connectors → Add custom connector), and sign in with the credential the installer printed.

Push-to-deploy (optional)

.github/workflows/deploy.yml SSHes into your server and runs deploy/deploy.sh (git pull && uv sync && systemctl restart) on every push to main. To enable it:

  1. Generate a dedicated SSH keypair — don't reuse an existing admin key.
  2. Add the public half to /root/.ssh/authorized_keys on your server, prefixed with a forced command so this key can only ever run that one script:
    command="/opt/codex-bridge/deploy/deploy.sh",no-port-forwarding,no-X11-forwarding,no-agent-forwarding ssh-ed25519 AAAA...
    
  3. Add the private half as the ATLAS_CODEXBRIDGE_DEPLOY_KEY secret on the GitHub repo, and the server's hostname/IP as ATLAS_HOST.

Security model

  • Every request to the MCP server is OAuth-authenticated — no anonymous access.
  • codex_delegate's working_dir is checked against a fixed allowlist (CODEXBRIDGE_WORKDIR_ALLOWLIST) set at install time — never an arbitrary path.
  • Job submission is rate-limited (CODEXBRIDGE_MAX_CONCURRENT_JOBS, CODEXBRIDGE_RATE_LIMIT_PER_HOUR) to bound both cost and blast radius.
  • Every job also runs under Codex CLI's own command-execution sandbox (--sandbox, CODEXBRIDGE_SANDBOX_MODE, default workspace-write) — Codex Bridge never passes --dangerously-bypass-approvals-and-sandbox.
  • ~/.codex/auth.json and the server's own OAuth credential are secrets — never logged, never committed. .gitignore excludes .env/*.db by default.
  • The optional CI deploy key is scoped with a forced SSH command, so even a leaked key can only re-run the fixed deploy script, not arbitrary commands.
  • This is a personal-use bridge, not a resale or multi-tenant proxy — OpenAI's ToS govern what you do with a ChatGPT-authenticated Codex session accessed this way. Don't share your instance's credential with anyone whose usage you wouldn't want counted against your own plan.

Known limitations (v1)

  • Single operator, single Codex identity, one server — no multi-tenancy.
  • No codex_review tool yet (mirroring /review from the official plugin) — tracked as a stretch goal.
  • No session resume support (codex exec resume) yet — codex_status/ codex_result report the session_id Codex CLI assigns each run (parsed from its exec banner), but nothing in Codex Bridge uses it to resume.
  • Headless login (codex login) needs either --device-auth (requires Device Code Authorization enabled in your ChatGPT account's Security Settings) or an SSH-tunneled browser flow — the installer won't attempt it for you, see its printed instructions.
  • If the service restarts while a job is running, the job survives (KillMode=process in the systemd unit), but the exit code is unavailable — it's reported as done with a note, since the reparented process can no longer be waited on for a real exit status.
  • Job history/log storage on disk has no retention/cleanup policy yet — will grow unbounded under heavy use.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选