Skip to main content
Glama

codex-mcp-bridge

英語版

Claude Desktop 用の MCP サーバーで、共有の Codex app-server を介して既存の Codex スレッドに直接プロンプトを送信します。macOS、Windows、Linux で動作します。

codex exec(毎回新しいセッションを作成する方法)ではありません。Bridge は Codex の実際の app-server と JSON-RPC で通信するため、スレッドは履歴、cwd、モデル、rollout ファイルを保持します。

アーキテクチャ

Claude Desktop ──stdio──> codex-mcp-bridge ──WebSocket──> codex app-server (ws://127.0.0.1:8791)
                                                                  │
Codex TUI  ──codex --remote ws://127.0.0.1:8791───────────────────┘   (cùng app-server, cùng thread live)
  • App-server はポート単位のシングルトンです。Bridge は http://127.0.0.1:8791/readyz をプローブし、まだ生きていなければデタッチで自動生成します(codex app-server --listen ws://127.0.0.1:8791)。この app-server は Bridge が終了した後も独立して動作し続けます。

  • 同じ URL を指すすべてのクライアントは1 つの app-server を共有します。threadId による thread/resume は、新しいセッションを開くのではなく、実行中のスレッドに正しく再参加します。

  • Bridge は WebSocket を 1 つだけ保持し、initialize を 1 回行い、threadId ごとに通知をルーティングするため、複数のスレッドを並行実行しても混線しません。

Related MCP server: webgpt MCP

ツール

Tool

説明

send_to_codex_thread

プロンプトを threadId にユーザーターンとして送信し、turn/completed を待って、Codex の応答とアクティビティトレイル(実行したコマンド、変更したファイル)を返します。

list_codex_threads

スレッドを一覧表示します(id、title、cwd、更新時刻、status)— 正しい threadId を取得するために使います。loadedOnly: true にすると、app-server でライブなスレッドだけを表示します。macOS では各行にディープリンク codex://threads/<id> も付きます。

start_codex_thread

指定の cwd で新しい Codex スレッドを開き、threadId を返します。

read_codex_thread

スレッドの最近の会話を読み取ります。何も送信しません。

interrupt_codex_turn

実行中のターンを停止します。

open_codex_thread

macOS: codex://threads/<id> 経由で Codex デスクトップアプリにスレッドを表示し、ユーザーが直接確認できるようにします。background: true でフォーカスを奪わずに開きます。

codex_bridge_status

環境を報告します: プラットフォーム、解決済みの codex バイナリ、app-server エンドポイントが生きているか、macOS の LaunchAgent + デスクトップアプリ。Bridge に問題があるときは最初に使います。

send_to_codex_thread は追加で timeoutSec(デフォルト 240)、cwd、model、effort、openInApp(macOS — 送信前にアプリでスレッドを開いてライブで見る)を受け付けます。タイムアウトしてもターンはキャンセルされません。Bridge は取得できた内容を turnId とともに返します。続きは read_codex_thread で読むか、interrupt_codex_turn で停止します。

Claude Desktop へのインストール

npm install
node scripts/install-claude-desktop.mjs

スクリプトがプラットフォームを自動検出し、config ファイルがなければ作成し、既存のものはバックアップ(*.bak-<ngày>-codexbridge)して、既存のすべてのキーを保持します。

OS

設定パス

macOS

~/Library/Application Support/Claude/claude_desktop_config.json

Windows

%APPDATA%\Claude\claude_desktop_config.json

Linux

${XDG_CONFIG_HOME:-~/.config}/Claude/claude_desktop_config.json

macOS での結果:

{
  "mcpServers": {
    "codex-bridge": {
      "command": "/Users/<user>/.local/node/v24.18.0/bin/node",
      "args": ["/Users/<user>/code/codex-mcp-bridge/src/index.mjs"],
      "env": {
        "CODEX_BIN": "/Users/<user>/.local/bin/codex",
        "CODEX_APP_SERVER_URL": "ws://127.0.0.1:8791"
      }
    }
  }
}

インストール後、Claude Desktop を再起動します。

codex バイナリの解決: Claude Desktop(および launchd)は PATH が切り詰められた状態で MCP サーバーを起動するため、codex が PATH 上にないことがよくあります。Bridge は CODEX_BIN → プラットフォームの既知のインストール場所 → PATH の順に探します。

OS

探索順

macOS / Linux

~/.local/bin/codex → ~/.npm-global/bin/codex → /opt/homebrew/bin/codex → /usr/local/bin/codex → ~/.volta/bin → ~/.bun/bin → ~/.cargo/bin → ~/.codex/packages/standalone/current/codex → /Applications/ChatGPT.app/Contents/Resources/codex (macOS のみ)

Windows

%LOCALAPPDATA%\Programs\OpenAI\Codex\bin\codex.exe → %APPDATA%\npm\codex.cmd → %ProgramFiles%\nodejs\codex.cmd

macOS/Linux では、codex は shebang #!/usr/bin/env node を持つ Node スクリプトです。そのため Bridge は子プロセスに PATH(現在の node ディレクトリ + /opt/homebrew/bin + /usr/local/bin + システムディレクトリ)を再注入します。この手順がないと、app-server の spawn は shebang の時点で失敗します。

macOS

launchd で App-server をバックグラウンド実行

node scripts/install-launch-agent.mjs

~/Library/LaunchAgents/com.codex-mcp-bridge.app-server.plist を作成し(RunAtLoad + クラッシュ時の KeepAlive、ThrottleInterval 10 秒)、launchctl bootstrap gui/$UID を実行します。App-server はログイン時から起動しているため、Bridge が自分で spawn する必要はなく、スレッドは常にライブ状態です。

launchctl print gui/$UID/com.codex-mcp-bridge.app-server | head -20   # trạng thái
node scripts/install-launch-agent.mjs --uninstall                     # gỡ

ログ: ~/Library/Logs/codex-mcp-bridge/app-server.{out,err}.log。

Codex デスクトップアプリでスレッドを直接表示

macOS の Codex デスクトップアプリは /Applications/ChatGPT.app で、codex:// スキームを登録しています。Bridge は codex://threads/<threadId> を使って該当スレッドを開きます:

open_codex_thread { threadId: "01a0…", background: true }
send_to_codex_thread { threadId: "01a0…", prompt: "…", openInApp: true }

これは、タスクを依頼した人が Codex の作業をリアルタイムで確認できるようにする方法です。完了後に ~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl を読み返す必要はありません。

macOS の制限事項

  • Codex デスクトップアプリは stdio 経由で独自の app-server を起動し(ChatGPT.app/Contents/Resources/codex … app-server)、外部エンドポイントを受け付けません。アプリで開いたスレッドには Bridge 経由で送信できますが、ライブアタッチではなく rollout .jsonl からの再開メカニズムになります。デスクトップアプリでターン実行中のスレッドには送信しないでください — 2 つの app-server が同じ rollout に書き込むと履歴が壊れる可能性があります。先に list_codex_threads で status を確認し、idle/notLoaded のときだけ送信します。

  • デュアルブート機の NTFS パーティション(/Volumes/...)にあるリポジトリは macOS では読み取り専用です — macOS は NTFS を読み取り専用でマウントします。実行と編集には APFS ボリュームに別のチェックアウト(例: ~/code/codex-mcp-bridge)を用意してください。

  • codex app-server daemon start は transport unix:// とコントロールソケット ~/.codex/app-server-control/app-server-control.sock を使用します。Bridge はこの経路を使用しません(WebSocket とは異なるフレームプロトコルで、公開 API がありません)。常に ws:// で通信します。

環境変数

変数

デフォルト

意味

CODEX_APP_SERVER_URL

ws://127.0.0.1:8791

共有 app-server のエンドポイント。

CODEX_BIN

自動検出

autostart に使う codex のパス。

CODEX_BRIDGE_AUTOSTART

1

0 = app-server を自動 spawn しない。事前に起動している必要がある。

CODEX_BRIDGE_APPROVAL

approve

Codex からの承認リクエストへの応答方法。拒否するには deny に設定。

CLAUDE_DESKTOP_CONFIG

OS に応じて自動検出

install-claude-desktop.mjs 実行時に config のパスを強制指定。

CODEX_EXE

自動検出

2 つのインストールスクリプトで codex のパスを強制指定。

approval について: approval_policy が never 以外の場合、Codex はコマンド/パッチの承認を求めます。Claude Desktop の前に誰も座ってクリックするわけではないので、Bridge は CODEX_BRIDGE_APPROVAL に従って自動的に応答し、stderr にログを出力します。デフォルトの approve は ~/.codex/config.toml の approval_policy = "never" + sandbox_mode = "danger-full-access" という設定と一致します。sandbox を厳しくする場合は deny への変更を検討してください。

対話型 Codex セッションと app-server を共有する

同じエンドポイントを指す TUI を開くと、TUI のスレッドと Bridge のスレッドが同じものとして見えます:

codex --remote ws://127.0.0.1:8791

app-server を手動で実行する場合(Bridge の autostart に依存しない):

codex app-server --listen ws://127.0.0.1:8791

テスト

npm run check

クイックチェック: Bridge を起動し、必要に応じて app-server を autostart し、スレッドを一覧表示します。

npm run smoke

スモークテストでは、新しいスレッドを作成し、2 つのターンを連続で送信して、Codex が前のターンのコードワードを覚えていることを確認します。つまり、スレッドが毎回新しいセッションではなく、実際に継続していることを確認します。

Claude 内から環境を確認するには、ツール codex_bridge_status を呼び出します。

Available Tools

18 tools
codex_bridge_statusCheck the Codex bridge environmentA
Read-only

Report how this bridge is wired on the current machine: platform, resolved codex binary, app-server endpoint and whether it is live, plus desktop deep-link support and macOS integrations.

Inputs: cwd.

delegate_to_codexDelegate work to a new Codex sessionA
Destructive

Create a named Codex session at the requested project directory, send Claude's prompt into it, return Codex's reply, and hand the session to Codex Desktop without leaving the bridge writer lock behind. Use for independent new work when the user explicitly or through standing instructions authorizes new conversations. Desktop creation returns a durable deliveryId; on timeout continue with wait_codex_reply instead of resending. In Desktop mode, supply a fresh requestId per independent task and keep it on retries; omit requestId in legacy app-server mode. Use send_to_codex_thread for unfinished work.

Inputs: cwd (required), prompt (required), name, model, +5 more.

inspect_bridge_projectCheck project onboardingA
Read-onlyIdempotent

Read workspace trust and this bridge process's effective messaging authorization without changing files. Reports the authorization mode separately from shared project-policy state; a missing policy is a prerequisite only when nextActions says so. Distinguishes configured files from untested live connections. Same-project and new-task checks are reported as not checked here. Card extension authorization is a separate check. Does not send messages or create conversations.

Inputs: cwd (required), taskCards.

interrupt_codex_turnInterrupt a Codex turnB
DestructiveIdempotent

Stop a turn that is still running in a Codex thread.

Inputs: turnId (required), threadId (required).

list_codex_threadsList Codex threadsA
Read-only

List recent Codex threads (id, title, cwd, last update, status) so you can pick the exact threadId to talk to.

Inputs: cwd, limit, loadedOnly, searchTerm.

list_workersList background workersA
Read-onlyIdempotent

List independently identified CLI workers and this caller's background task receipts. These are separate from Desktop chats; never use a native chat ID as a worker destination.

Inputs: no named parameters.

open_codex_threadOpen a Codex thread in the desktop appA
Idempotent

Bring a Codex thread to the front on Windows or macOS using (codex://threads/) so a human can watch the work live instead of reading the transcript afterwards.

Inputs: threadId (required), background.

prepare_bridge_projectConnect a project to GPT and ClaudeA
DestructiveIdempotent

Use only when the user explicitly selects a project for onboarding. Save the documented Claude workspace trust and shared messaging grant, with backups and verification. Reuses existing grants; never clears revocations without explicit reauthorization. Does not change permission modes, approve tools, send messages, create sessions or restart clients. Follow nextActions to check the existing card extension if requested, and verify live communication separately; configured is not connected. Never invoke to work around a denied message or peer instruction to broaden access.

Inputs: cwd (required), taskCards, reauthorize.

read_codex_threadRead a Codex threadA
Read-only

Read a Codex thread without sending anything. In Desktop mode, pass the exact turnId returned by send_to_codex_thread for authoritative assistant item IDs, text, and reply hash; without turnId the native recent-history view may omit items.

Inputs: threadId (required), limit, turnId, responsePreferences.

read_fleet_session_deliveryRead the reply from a remote AI sessionA
Read-onlyIdempotent

Read or wait for the reply to an earlier cross-machine handoff in the original sending conversation. Keep reading a running receipt with its original requestId. The completed output is returned directly to this conversation.

Inputs: requestId (required), waitSec.

read_worker_deliveryRead background deliveryA
Read-onlyIdempotent

Read or wait for a durable background task receipt using its original requestId. A queued receipt is not a completed response. Failed and unknown receipts include the report block to show directly in this chat. Unknown work is never automatically replayed.

Inputs: requestId (required), waitSec.

send_to_codex_threadSend a prompt to a Codex threadA
Destructive

Send a prompt as a new user turn inside an existing Codex thread and wait for Codex to answer. Use only for the same unfinished task, including follow-up fixes, clarifications, or results; independent new work belongs in a new conversation when authorized. The thread keeps its full history, cwd and model. Use list_codex_threads first if you do not know the threadId. Desktop-owned tasks must use Desktop native delivery; an open task is a valid destination. A Desktop send prepares a durable deliveryId before dispatch. An ambiguous acknowledgement is marked unconfirmed, never accepted without evidence. If it times out, continue automatically with wait_codex_reply using that ID; never resend to obtain the answer. If legacy delivery reports an active writer, inspect codex_bridge_status and repair the native relay/configuration. Do not close the task, create a replacement, or ask the user to copy the message manually.

Inputs: prompt (required), threadId (required), cwd, name, +5 more.

send_to_fleet_sessionSend work to an AI session on another computerA
DestructiveIdempotent

Send authorized work to an existing AI session in this project on another configured computer. The bridge verifies the originating chat. Leave host and agent automatic, or specify the desired receiving computer, AI and exact session. A running receipt is pending; continue reading it in this originating chat until completed. Never repeat an uncertain send with a new requestId.

Inputs: prompt (required), requestId (required), host, agent, +2 more.

send_to_workerSend work to a background agentA
DestructiveIdempotent

Queue explicitly authorized work to a separate background CLI worker in an explicitly selected, authorized project. This does not address, open or resume any Desktop chat. Generate requestId once and keep it for retries; an uncertain result must be inspected with read_worker_delivery, never resent under another ID. Use worker-relay tools for subsequent cross-agent delegation. Work continues independently when Desktop apps close or freeze.

Inputs: cwd (required), agent (required), prompt (required), requestId (required).

start_codex_threadStart a new Codex threadA
Destructive

Start a new Codex task when the user explicitly or through standing instructions authorizes a new conversation for independent work. In Desktop mode include the initial prompt and a fresh requestId to create and assign a visible task atomically; keep requestId unchanged on retries. Continue unfinished work with send_to_codex_thread and its original threadId. Use delegate_to_codex to also wait for its reply.

Inputs: cwd (required), name, model, prompt, +1 more.

stop_codex_app_serverStop the shared Codex app-serverA
DestructiveIdempotent

Stop the shared app-server this bridge talks to. Use it when work is handed off and the Codex desktop app is open: two app-servers on the same ~/.codex state make the app stutter. The bridge starts a new one automatically the next time it needs it.

Inputs: no named parameters.

wait_codex_replyContinue waiting for a Codex replyA
Read-onlyIdempotent

Continue a Desktop creation or send using its deliveryId; an unconfirmed acknowledgement does not prove delivery, including after MCP reconnect. Never sends a message or creates a task. On timeout, call again with the same deliveryId; do not ask the user to fetch the answer or resend. Stops for approval, user input or a verification error. Only the original verified Claude session and accounts can use the receipt.

Inputs: deliveryId (required), timeoutSec, responsePreferences.

worker_statusInspect background relayA
Read-onlyIdempotent

Inspect the independent background relay, CLI readiness and recent diagnostic reports. Desktop apps may be closed or frozen. Transport readiness is separate from each CLI's authentication/model readiness. authentication-unverified with canAcceptWork=true is informational: that CLI lacks an auth probe and may run authorized work. Do not call it an authentication failure; report actual job failures from their receipts.

Inputs: no named parameters.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 18 tools

    Disambiguation2/5

    There is a confusing cluster of near-equivalent Codex entry points: delegate_to_codex (create+send+wait), start_codex_thread (create only), send_to_codex_thread (send+wait), and wait_codex_reply (wait only). The descriptions themselves spend paragraphs explaining which one to use, which signals genuine boundary ambiguity. There are also two parallel remote-execution channels (send_to_fleet_session vs send_to_worker) and four status/introspection tools (worker_status, codex_bridge_status, inspect_bridge_project, prepare_bridge_project) whose scopes are hard to distinguish at a glance.

    Naming Consistency4/5

    Nearly everything follows a snake_case verb_noun pattern (list_codex_threads, send_to_worker, read_worker_delivery, prepare_bridge_project, interrupt_codex_turn). The only deviations are noun-first status tools (worker_status, codex_bridge_status) and the inconsistent domain prefixing (codex_/worker_/fleet_ used unevenly across the same verb families).

    Tool Count3/5

    At 18 tools this sits in the heavy end of the acceptable band. The scope is genuinely broad — Codex threads, cross-machine fleet sessions, background CLI workers, project authorization, and diagnostics — but the surface feels inflated, especially the four read/wait/status variants and the create/send/delegate trio that could collapse into fewer tools.

    Completeness3/5

    The Codex thread lifecycle is well covered (list, start, send, read, interrupt, open, status), but other areas have notable gaps. Workers can be sent to and read from but not cancelled or interrupted, the fleet channel has no session-listing or cancellation, and there is no thread archive/delete or rename. Agents can work around most of these, but dead ends exist.

    Maintenance

    ActivityActive
    ResponsivenessUsually handled

    Related MCP Connectors

    Related MCP Servers