codex-bridge

io.github.xallindrome-labs由 GitHub 帳號 xallindrome-labs 發布v0.1.0更新於 Oct 29, 2026

Lets Claude Code consult the Codex CLI for plans and images, as durable background jobs.

概覽

AI 產生的概覽

把 Claude Code 接到 Codex CLI,讓助理以可持久化的背景工作取得實作計畫、設計審查與生成的圖片。

可以做什麼
  • 請 Codex 提出實作計畫、設計審查或第二意見,它在唯讀沙箱中檢視專案
  • 用 Codex 生成或編輯點陣圖,並把圖片存到指定的輸出資料夾
  • 查詢工作狀態或結果、列出最近的工作,並可短暫等待工作完成
  • 從中斷處續跑被中斷、逾時或失敗的工作,或取消正在執行的工作
  • 設定寫入根目錄後,可選擇讓 Codex 在一個指定資料夾內修改檔案
適用情境
適合希望由 Codex 出計畫或提供第二意見、而由 Claude Code 負責實作的情況,也適合需要圖片生成且工作能在當機、關閉視窗或重新開機後繼續的場合。長時間的請求可放到背景執行,之後再取結果。
執行需求
透過 npx 以 stdio 在本機執行,需要 Node.js 20 或更新版本,並已安裝且登入 Codex CLI。不需要另外的 API 金鑰,使用 Codex 本身的登入與額度。選用的環境變數可指定 Codex 執行檔路徑、工作儲存資料夾、閒置逾時、模型與推理強度,以及 Codex 可編輯的單一資料夾。
安裝前請注意
提示詞會傳送給 OpenAI,請勿在其中放入機密資訊。工作會消耗你的 Codex 額度,Claude 關閉後仍在執行的工作也會繼續消耗。選用的寫程式工具會修改所設定資料夾中的檔案,執行失敗或被取消時可能留下部分變更;不提交的規則只是提示詞,測試中系統暫存資料夾仍可寫入。macOS 與 Linux 上的真實 Codex 工作尚未測試。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 codex-bridge,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

codex-bridge

Codex jobs for Claude Code that survive crashes, closed windows and reboots, with Codex image generation built in. A dependency-free MCP server built Windows-first: every call is a job saved on disk, so you can close Claude, lose power, or kill a process, and pick the work up again with codex_resume.

Roles: Claude Code implements. Codex plans and builds images. Optionally (opt-in, one folder), Codex can also write code while Claude reviews: see Let Codex write code. And an optional pane beside the chat lists your jobs live and shows your Codex usage and when it resets: see Codex jobs pane.

[Recorded session: Claude Code starts codex-bridge and asks Codex for a plan]

The server calls in this recording are real (Codex at effort: low, idle time trimmed); the claude mcp add line is scripted. The raw recording is docs/demo.cast; play it with asciinema play docs/demo.cast.

Quickstart

You need Node.js 20 or newer and the Codex CLI installed and logged in.

bash
claude mcp add codex-bridge -- npx -y @xallindrome-labs/codex-bridge

Restart Claude Code, then ask it something like "Get a plan from Codex for adding rate limiting, in the background, and keep going". Claude will call codex_plan with background: true and collect the answer later.

Other MCP clients: run npx -y @xallindrome-labs/codex-bridge as a stdio server.

Platform note: developed and tested on Windows 11, where real Codex jobs have been run. CI checks on Linux, macOS and Windows (Node 20 and 22) that the server starts, speaks MCP and works when installed from the npm tarball, and on Linux and macOS that jobs run, finish and survive the server being killed, using a fake codex. CI has no real Codex CLI, so real Codex jobs on macOS and Linux are untested. Reports and fixes are welcome.

ToolWhat it doesSandboxDefault model / effort
codex_planCodex writes implementation plans, design reviews and second opinions. It inspects the project in cwd.read-only (always)Your Codex config defaults
codex_imageCodex generates or edits images. The bridge copies each one into output_dir as soon as it's made.read-only (always)gpt-6-luna / high
codex_codeOff by default. Codex implements a change by editing files in one folder you choose. See below.workspace-write, that folder only, no networkYour Codex config defaults
codex_resultGets a job's result or progress (wait_seconds up to 240), or lists recent jobs.
codex_resumeContinues an interrupted, timed-out or failed job from where it stopped.
codex_cancelStops a running job.

codex_plan, codex_image and codex_code accept:

  • effort: low, medium, high, xhigh, max or ultra (Luna supports up to max).
  • model: overrides the default model for that call.
  • background: true: returns a job_id immediately so Claude can keep working.
  • session_id: continues an earlier Codex thread, for example "make the icon darker".

codex_image also takes count, the number of images wanted. Set it for batches: it enables k/count progress and resumes that ask for exactly the missing images.

Let Codex write code (opt-in)

By default Codex can only read. If you want it to implement things while Claude reviews, name the one folder it may edit:

bash
claude mcp add codex-bridge -e CODEX_BRIDGE_WRITE_ROOT=/path/to/your/project -- npx -y @xallindrome-labs/codex-bridge

Restart Claude Code and a fourth tool, codex_code, appears. Ask for it in plain words: "Have Codex implement the plan in the background, then review its diff."

  • One folder. cwd must be CODEX_BRIDGE_WRITE_ROOT or inside it. Anything else is refused, checked on real paths so .. and symlinks don't escape. A drive root or your home folder is refused as too broad.
  • No network, no commits. Codex runs with network access off and is told to leave changes uncommitted so you can see them in git diff. The no-commit rule is a prompt, not a sandbox rule.
  • Claude reviews. Every codex_code result ends with a reminder to read the diff before accepting it. A failed or cancelled run says Codex may have left partial edits.
  • Same job machinery. It survives restarts, background: true and codex_resume work the same way, and a resume re-checks the folder rule.
  • Temp files. In our test on Windows 11, writes outside the folder and network access were blocked, but the system temp folder stayed writable. Treat temp as writable. CODEX_BRIDGE_WRITE_ALLOW_TMP=1 stops asking Codex to block it.
  • Don't edit the same files yourself while a codex_code job runs.

Unset the variable and restart, and the tool is gone; codex_plan and codex_image are always read-only.

Codex jobs pane

An optional add-on that opens a pane beside the Claude Code chat listing your Codex jobs live: running, done, interrupted, with age, request and images k/n for batches. It also shows your Codex usage: the 5-hour and weekly windows, percent used, when each resets, and how many images were generated in each (Codex has one shared meter, so images use the same limits). It only reads the job files on disk, so it shows jobs from any session, including ones that kept running after you closed Claude. It also puts codex: N running in the status line and shows a toast when a job you watched finishes.

At the prompt of a terminal Claude Code session:

/plugin install codex-jobs --marketplace xallindrome-labs/codex-bridge

In the desktop app, where /plugin does not run: click + next to the prompt box, then Plugins, Add marketplace with xallindrome-labs/codex-bridge, then Add plugin. Without a marketplace, for one session: claude --plugin-dir "$(npx -y @xallindrome-labs/codex-bridge --pane-path)".

Then type /codex-jobs. It also opens by itself the first time a job is running in a session. Details and how it works are in plugins/codex-jobs. It needs a Claude Code build that supports mods; it is tested against the engine's own test kit, not every surface's paint.

How it compares

OpenAI's codex-plugin-cc is the official way to use Codex from Claude Code, and it's good at what it does: slash commands for review and rescue. codex-bridge is an MCP server instead, with a different focus: jobs that don't get lost, and images.

Several open issues in the plugin's tracker are about jobs getting lost, and codex-bridge is designed to avoid each of them. These come from reading the designs, not from a head-to-head test:

Reported in codex-plugin-ccHow codex-bridge handles it
Background job shows "running" forever after its worker dies (#704, #699)Status is worked out from files on disk plus a heartbeat and a process check. A dead runner shows as interrupted, never "running", and codex_resume continues it.
Windows cancel silently fails (#708)Cancel writes a marker file; the runner that owns the Codex process sees it within about 2 seconds and stops the process tree by calling taskkill.exe directly, with no shell in between.
Windows broker processes leak (#718, #782)There is no shared broker. Each attempt is one runner process that exits when Codex does.
One session ending kills other sessions' jobs (#671)Runners are started outside Claude's process tree (via WMI on Windows), so closing a session can't take them down.

What the plugin does that this doesn't: slash commands, and its review-gate and rescue workflows. And this one is newer, with far fewer users. If the plugin works for you, keep using it. If you've lost jobs, or want Codex to generate images that survive a crash, try this.

Jobs survive restarts

Every call is a job saved under ~/.codex-bridge/jobs/<job_id>/, including calls that aren't run in the background.

  • Claude closes or crashes: the job keeps running. server.mjs starts runner.mjs through WMI (Win32_Process.Create), so the job isn't part of Claude Code's process tree. Closing Claude can't kill it, and any later Claude session can collect it with codex_result.
  • The job itself dies (reboot, power loss, Codex crash, or killed process): the job is marked interrupted. The next Claude session is told about it when it starts. codex_resume continues it:
    1. It copies out any images generated just before the interruption.
    2. It resumes the same Codex thread: "N are already done, generate only the remaining ones."
    3. If no Codex thread had started yet, it reruns the original request.

How images are collected

Codex never writes image files. Its image tool stores every generated image in ~/.codex/generated_images/<thread>/. The runner checks that folder every 2 seconds and copies new images into output_dir as <filename>.png, <filename>-2.png, and so on, in the order they were made. copied.json in the job folder records what has been copied, so an image is never copied twice across attempts.

This gives three benefits:

  • Image jobs run in a read-only sandbox.
  • A crash loses at most the one image being generated.
  • Resume counts exactly what's done.

It also avoids a real problem: when Luna was allowed to save files itself, it re-typed each image as base64 through dozens of shell commands. That was slow, and the saved file no longer matched the original.

  • Codex stalls: the runner stops a run after 10 minutes with no output. The job is marked timed_out, and it can be resumed.

Each attempt keeps its own prompt.txt, events.jsonl (the Codex event stream), stderr.txt, heartbeat and result.json. Finished jobs are deleted after 14 days.

How it works

Each attempt runs codex exec --json (or codex exec resume <thread>) with the prompt on stdin. No shell is involved.

Every call runs read-only, except codex_code when you have opted in (it runs workspace-write in your one folder, with network off). New sessions pass -s read-only plus -c sandbox_mode="read-only"; resumed sessions pass -c sandbox_mode="read-only" (codex exec resume takes no -s). Your Codex config may default to danger-full-access, but that default never applies to bridge calls. The plan smoke test checks that a write attempted from a resumed session fails.

FileRole
server.mjsThe MCP server. It creates jobs, launches runners, works out job status from the files on disk, and handles resume and cancel.
runner.mjsRuns one attempt: starts Codex, records the heartbeat, watches for a stall or cancellation, collects images and writes result.json.
lib.mjsShared helpers: finding the Codex binary, building arguments, parsing events, handling images.

Install options

bash
# for all your projectsclaude mcp add -s user codex-bridge -- npx -y @xallindrome-labs/codex-bridge
# or from a local checkoutclaude mcp add codex-bridge -- node /path/to/codex-bridge/server.mjs

Remove it with claude mcp remove codex-bridge (add -s user if you installed it that way).

Configuration (env vars)

VarDefault
CODEX_BINAuto-detected. It prefers a codex.exe next to codex-code-mode-host.exe, which is currently ~/.codex/plugins/.plugin-appserver/codex.exe.
CODEX_BRIDGE_HOME~/.codex-bridge
CODEX_BRIDGE_IDLE_TIMEOUT_MS600000 (stops a run after 10 minutes with no Codex output)
CODEX_BRIDGE_PLAN_MODEL / CODEX_BRIDGE_PLAN_EFFORTYour Codex config defaults
CODEX_BRIDGE_IMAGE_MODEL / CODEX_BRIDGE_IMAGE_EFFORTgpt-6-luna / high
CODEX_BRIDGE_WRITE_ROOTUnset: codex_code is off. Set to one folder to let codex_code edit files there.
CODEX_BRIDGE_WRITE_ALLOW_TMPUnset. 1 stops asking Codex to block temp-folder writes (not enforced on Windows anyway).
CODEX_BRIDGE_CODE_MODEL / CODEX_BRIDGE_CODE_EFFORTYour Codex config defaults

Test

bash
node smoke-test.mjs <scratch-dir> [plan|image|jobs|durable|all]

The smoke test drives the server over stdio like an MCP client and needs a logged-in Codex CLI; it uses a little of your Codex quota. The durable part uses taskkill, so it is Windows-only for now.

  • plan: runs a plan, then tries a write from a resumed session, which must fail.
  • image: generates one image.
  • jobs: tests background jobs, cancellation and the effort check.
  • durable:
    1. Kills the server while a job is running, then checks that a new server collects the result.
    2. Hard-kills an image batch partway through, then checks that a new server reports it as interrupted and that codex_resume finishes it.

Speed

Each call has a fixed cost of about 4–5 seconds, and changing settings barely moves it. The rest of the time is Codex thinking and generating, which takes seconds to minutes. To spend less time waiting, use background: true, a lower effort for quick questions, and include relevant code in context so Codex reads less of the project.

Notes

  • This uses Codex's own login and quota, with no separate API key. A job left running after Claude closes keeps using that quota until it finishes.
  • Bridge calls run headlessly, so they don't show up as conversations in the Codex Desktop sidebar.
  • Don't send secrets in prompts. Prompts go to OpenAI.

Issues and contributing

Bug reports and ideas are welcome on the issue tracker. Pull requests are welcome too, but reviewed slowly; see CONTRIBUTING.md. Please report security problems privately, as described in SECURITY.md.

License

MIT


Built by Xallindrome: we build automation and AI workflows for small businesses. If you'd like something like this for your business, book a diagnostic.

來源:README.md,提交 8735d9a

工具

5

codex_plan

Ask Codex (OpenAI) to act as the planner: produce an implementation plan, review a design, or give a second opinion. Codex runs in a READ-ONLY sandbox in `cwd` and can inspect the project but not change it. Claude remains the implementer. Calls can take several minutes; use background=true to keep working meanwhile. Including relevant code/diffs in `context` makes it faster. Returns Codex's answer, a job_id and a session_id; pass session_id back to ask follow-ups in the same Codex thread.

輸入參數cwd必填modeleffortcontextrequest必填backgroundsession_id

codex_image

Ask Codex to generate (or edit) raster images with its image generation tool. Images are saved into `output_dir` as they are made, and their paths returned. Pass reference_images to edit or riff on existing images, and session_id to iterate on a previous result. Set `count` for batches so progress and resumes are tracked. Runs on gpt-6-luna at high effort by default; leave model/effort unset unless the user asks. Calls take ~1 min per image; use background=true for batches.

輸入參數countmodeleffortprompt必填filenamebackgroundoutput_dir必填session_idreference_images

codex_result

Get the status or result of a Codex job (jobs persist across Claude sessions and restarts). With job_id: the result if finished, otherwise progress. wait_seconds (max 240) blocks until the job finishes or the wait expires. Without job_id: lists recent jobs.

輸入參數job_idwait_seconds

codex_resume

Continue a job that was interrupted (reboot/crash), timed out or failed, from where it stopped: it continues the same Codex thread, and for image jobs first rescues images Codex already generated, then asks only for the missing ones. Returns immediately; collect with codex_result.

輸入參數job_id必填

codex_cancel

Stop a running Codex job.

輸入參數job_id必填

版本歷史

1
  1. v0.1.0最新Oct 22, 2026

評分

已滿足適用檢查項的 90%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分
  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分