codex-fusion-mcp
MCP server enabling Claude to consult Codex (GPT-5.x) mid-task for second opinions, plan/diff review, brainstorming, and codebase exploration via structured debates and permission-controlled interactions.
README
codex-fusion-mcp
A small MCP server that lets Claude consult Codex (GPT-5.x) mid-task — for a second opinion, plan review, diff review, brainstorming, and codebase exploration. A lightweight take on model fusion: Claude proposes, Codex reviews, Claude reconciles. (See OpenRouter's Fusion beats Frontier — the synthesis step itself is where the gains come from.)
Internally it's an ACP client that spawns
codex-acp and
keeps one persistent Codex session per workspace.
Tools
| Tool | Use it to… |
|---|---|
consult |
get an independent second opinion on a specific question/decision |
review_plan |
have Codex critique a plan before you implement it |
review_diff |
have Codex review code changes (pass a diff, or let it read git diff) |
brainstorm |
get 2–4 alternative approaches with trade-offs + a recommendation |
explore |
map an unfamiliar codebase (structure, components, flow, conventions) |
reply |
continue the debate — push back on Codex's last answer on the same session |
permit |
allow/deny a permission Codex raised mid-turn, then resume it |
reset |
drop Codex's accumulated context and start a fresh session |
status |
report health: workspace, guardian flags, session liveness, pending permission |
All tools are advisory — Codex answers, you decide.
Debate, not one-shot
The deliberative tools (consult, review_plan, review_diff, brainstorm)
frame each exchange as a short debate: Codex pushes back, and ends every reply
with a VERDICT: CONSENSUS — … or VERDICT: OPEN — … line. When it's OPEN,
push back with reply (same persistent session, so Codex keeps the thread) and
drive toward consensus — keep it to ~3 turns.
Permissions: Claude is the guardian
When Codex wants to do something guardian doesn't auto-allow, the turn pauses
and hands the decision back to Claude — no static allowlist, no human prompt.
The tool returns 🔐 Codex paused … <what it wants>; Claude judges whether it's
reasonable and calls permit allow|deny, which resolves the held-open request
and resumes the same suspended turn. Only the cheap, safe cases are auto-allowed
without asking: reads and searches inside the workspace. Everything else —
commands, writes, network, out-of-workspace reads — comes back to Claude. The
ALLOW_* flags downgrade a whole category from "ask Claude" to "auto-allow".
Streaming & cancellation
Turns stream live: Codex's text, its reasoning (a 💭 … thinking view), and a
↳ … activity trail are sent as MCP progress notifications, so you can watch
(and steer between turns). The reasoning stream doubles as a heartbeat — the MCP
client resets its request timeout on progress, so forwarding Codex's thinking
keeps a long, silently-reasoning turn from being cancelled by the client. Cancel
a turn and Codex is told to stop (session/cancel); if it ignores the cancel, a
short grace later the turn is hard-stopped and the subprocess respawned, so it
can't wedge the queue. A turn that runs past CODEX_FUSION_TURN_TIMEOUT_MS of
active work is aborted the same way (the wait for a permit decision is not
timed). If your client caps tool calls more tightly, raise its timeout too — for
Claude Code, MCP_TOOL_TIMEOUT (e.g. 300000).
The tool result stays focused on Codex's answer plus a one-line footer (latency,
tokens); the full play-by-play goes to the debug log.
Sessions & reset
The server keeps one persistent Codex session per workspace so Codex
accumulates context across calls (a collaborator, not a stateless oracle). That
context outlives a Claude /clear — the MCP server isn't restarted then — so
without help the next conversation would land on a Codex that still remembers the
last one. Two ways to clear it:
- Automatic, on
/clear— install theSessionStarthook below. It writes the new Claude session id to a per-workspace nonce file; the server notices the change on its next turn and drops Codex's session, so Codex starts fresh alongside Claude. (compact/resume/startupare intentionally left alone.) - Manual — call the
resettool any time: switching to an unrelated task, when Codex's context has grown stale over a long session, or to clear a wedged turn. It's also the fallback if the hook isn't installed.
Note the asymmetry: Codex's context lives only as long as the server process, but
Claude's is persisted. After a Claude resume, a crash-respawn, or a reboot,
Codex starts empty while Claude remembers — so a reply may land on a Codex that
no longer has the thread. Re-establish context (or reset and start clean) if so.
Requirements
- Bun
- A working Codex login (
codex login, or setOPENAI_API_KEY).codex-acpis fetched on demand viabunx; install it for speed if you prefer.
bun install
Register with Claude Code
claude mcp add codex-fusion -- bun run /ABS/PATH/codex-fusion-mcp/src/index.ts
Or in .mcp.json:
{
"mcpServers": {
"codex-fusion": {
"command": "bun",
"args": ["run", "/ABS/PATH/codex-fusion-mcp/src/index.ts"],
"env": { "CODEX_FUSION_WORKSPACE": "/ABS/PATH/your-project" }
}
}
}
Reset Codex on /clear (recommended)
Add a SessionStart hook so clearing the Claude conversation also clears Codex's
context (see Sessions & reset). In .claude/settings.json:
{
"hooks": {
"SessionStart": [
{
"hooks": [
{ "type": "command", "command": "bun run /ABS/PATH/codex-fusion-mcp/hooks/session-reset.ts" }
]
}
]
}
}
The hook runs on every session start but only acts on source == "clear"; for
other sources it's a no-op. It keys the nonce file on the hook's cwd, which must
match the server's workspace (the default — CODEX_FUSION_WORKSPACE unset). Two
Claude windows in the same workspace share the nonce, so a /clear in one
resets Codex for both; that only discards advisory context, never corrupts it.
Configuration (env)
| Variable | Default | Meaning |
|---|---|---|
CODEX_FUSION_WORKSPACE |
cwd | Absolute path Codex is scoped to; the base for every guardian check. |
CODEX_FUSION_ACP_COMMAND |
bunx @agentclientprotocol/codex-acp |
How to launch codex-acp. |
CODEX_FUSION_ALLOW_EXTERNAL_READS |
off | Let Codex read outside the workspace + use network fetch. |
CODEX_FUSION_ALLOW_WRITES |
off | Let Codex edit/delete/move files inside the workspace. |
CODEX_FUSION_ALLOW_COMMANDS |
off | Let Codex run shell commands. |
CODEX_FUSION_TURN_TIMEOUT_MS |
300000 |
Abort a single Codex turn after this long of active work. |
CODEX_FUSION_LOG |
off | Append a full per-turn JSONL debug log to this path. |
Guardian mode
By default the server runs in guardian mode: Codex may only read and search
inside the workspace without asking. Everything else — writes, network fetches,
command execution, and reads that escape the workspace root — isn't auto-refused;
the turn pauses and hands the request to Claude to allow or deny (see
Permissions: Claude is the guardian), and
every decision is logged. So review_diff can run git diff the moment you
allow it — there's no static command allowlist to outwit (see ADR 0003). The
ALLOW_* flags downgrade a whole category (external reads + fetch, writes, or
commands) from "ask Claude" to auto-allow; the policy is a single pure function
in src/permissions.ts.
Layout
src/config.ts env → Config (guardian flags, turn timeout, debug log)
src/permissions.ts guardianDecision — the pure permission policy
src/prompts.ts block-structured prompt per tool (+ debate frame)
src/codex.ts ACP client: spawn codex-acp, persistent session, streaming ask()
src/reset.ts per-workspace reset-nonce path (shared by server + hook)
src/log.ts per-turn debug log (stderr summary + optional JSONL file)
src/index.ts MCP server: the tools, streaming + cancellation wiring
hooks/session-reset.ts SessionStart hook: reset Codex on Claude /clear
docs/adr/0001-*.md design decisions
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。