codex-mcp-bridge

codex-mcp-bridge

MCP server that lets Claude Code drive the local Codex CLI as a sub-agent for concurrent queries and optional file/shell actions, using the CLI's existing login and sessions.

Category
访问服务器

README

codex-mcp-bridge

MCP server that lets an MCP client (Claude Code) drive OpenAI Codex as a sub-agent: many independent or threaded queries, plus actions (shell commands, file edits) when explicitly opted into.

Important: this project does not call the OpenAI HTTP API. It drives the Codex CLI (the codex executable) locally and/or reads local Codex session files. Authentication and session state come from the locally-installed codex CLI (for example, codex login), and the bridge operates against that local CLI and its session files rather than an external API key or billing endpoint.

Auth

Uses whatever codex login has already set up on this machine — a ChatGPT subscription login, not API-key billing. The bridge launches the codex executable as a child process so it inherits the current environment and the CLI's local auth state. Do not try to configure apiKey/baseUrl/env settings here: they are not used and env would replace the child's environment rather than merging it, which breaks codex PATH resolution and auth lookup.

Check status any time with:

codex login status

Tool: codex_ask

One tool, parameterized:

  • prompt (required), working_directory (required, absolute path — no implicit default, so Codex never silently operates on the wrong repo).
  • thread_id — pass back the id returned by a previous call to continue that conversation; omit to start a new one. Threads are persisted by the Codex CLI itself (~/.codex/sessions), so ids remain valid across restarts of this server.
  • sandbox_mode (read-only default / workspace-write / danger-full-access) and approval_policy (never default / on-request / on-failure / untrusted) — the "actions" knob. Default is read-only with no auto-approval: Codex can inspect the repo and answer, but cannot write files or run arbitrary commands unless a call explicitly asks for workspace-write. Since this runs non-interactively (codex exec under the hood), there's no one to answer an approval prompt either way — anything outside sandbox_mode is simply denied.
  • require_git_repo, additional_directories, network_access, web_search, model, reasoning_effort, output_schema (JSON Schema for structured output), timeout_ms.

Independent calls (different or omitted thread_id) run concurrently as separate Codex conversations — that's what covers "many queries" alongside a single ongoing thread.

Tool: codex_cloud_tasks

Lists Codex Cloud background tasks, or (with task_id) shows one task's status. Wraps codex cloud list --json / codex cloud status <id> directly (not part of the CLI's documented surface) — these are undocumented/ experimental, so the JSON field names in the list output aren't guaranteed stable across CLI versions. status has no --json form; its output is passed through as-is.

Tool: codex_local_sessions

Lists recent local Codex CLI sessions — the ones codex resume picks from — most recently touched first. codex resume itself is an interactive-only picker with no scriptable output, so this reads ~/.codex/session_index.jsonl directly instead (also undocumented). That index only carries session id, current thread name, and last-updated time — no live/idle status or working directory; a session can be renamed multiple times, so entries are deduped by id, keeping the most recent name.

Note this index only records interactively created sessions. Threads started programmatically (including by codex_ask) are real and resumable but do not appear here.

Tool: codex_read_thread

Reads the message history of any thread, interactive or programmatic, by locating its rollout JSONL under ~/.codex/sessions and parsing it. No API call, no quota — it works even when the account is rate-limited.

  • thread_id (required), limit (default 50, counts back from newest), include_reasoning (default false), max_chars (per-message truncation).

Returns the thread's cwd and source from its session_meta header along with the messages.

Notes on driving a thread you want to watch

A thread created programmatically never enters the interactive session index, so it won't show up in codex resume's default picker or the desktop app. If you want to watch the conversation in the normal Codex UI, start the thread there first, then pass its id to codex_ask.

Two behaviours worth knowing:

  • The desktop UI does not live-tail a thread, and navigating to it in an existing window serves a cached copy. Open the thread in a new window to see externally injected messages.
  • A turn that fails (e.g. rate limit) has already appended your message to the rollout. Rollouts are append-only, so a failed call is not a no-op.

Build

npm install
npm run build

Register with Claude Code (user scope)

claude mcp add codex-bridge --scope user -- node /absolute/path/to/codex-mcp-bridge/dist/index.js

Probe scripts

probe-*.mjs are small standalone experiments used to work out the behaviours above (app-server wire framing, what codex mcp-server exposes, why codex-reply can't reach persisted threads, SDK-only resume). They are not part of the server; each prints its usage when run without arguments.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选