codex-mcp-bridge
codex-mcp-bridge
Servidor MCP para Claude Desktop que envía prompts directamente a un hilo de Codex existente, a través de un app-server de Codex compartido. Se ejecuta en macOS, Windows y Linux.
No es codex exec (que crea una sesión nueva cada vez). El bridge habla JSON-RPC con el app-server real de Codex, por lo que el hilo conserva el historial, el cwd, el modelo y el archivo de rollout.
Arquitectura
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)El app-server es un singleton por puerto. El bridge comprueba
http://127.0.0.1:8791/readyz; si no está vivo, lo lanza como proceso independiente (codex app-server --listen ws://127.0.0.1:8791) y ese app-server sigue ejecutándose de forma independiente después de que el bridge salga.Todos los clientes que apuntan a la misma URL usan el mismo app-server →
thread/resumecon elthreadIdse reincorporará al hilo correcto en ejecución en lugar de abrir una sesión nueva.El bridge mantiene un único WebSocket, hace
initializeuna sola vez y enruta las notificaciones según elthreadId, de modo que varios hilos ejecutándose en paralelo no se mezclan.
Related MCP server: webgpt MCP
Herramientas
Herramienta | Descripción |
| Envía un prompt como un turno de usuario al |
| Enumera los hilos (id, título, cwd, momento de actualización, estado); se usa para obtener el |
| Abre un hilo nuevo de Codex en un |
| Lee la conversación reciente del hilo sin enviar nada. |
| Detiene un turno en ejecución. |
| macOS: abre el hilo en la aplicación de escritorio de Codex mediante |
| Informa del entorno: plataforma, binario |
send_to_codex_thread acepta además timeoutSec (por defecto 240), cwd, model, effort y openInApp (macOS: abre el hilo en la aplicación antes de enviar para verlo en vivo). Cuando se agota el tiempo de espera no se cancela el turno; el bridge devuelve lo que haya recopilado junto con el turnId; puedes seguir leyendo con read_codex_thread o detenerlo con interrupt_codex_turn.
Instalación en Claude Desktop
npm install
node scripts/install-claude-desktop.mjsEl script detecta automáticamente la plataforma, crea el archivo de configuración si no existe, respalda el anterior (*.bak-<ngày>-codexbridge) y conserva todas las claves existentes:
SO | Ruta de configuración |
macOS |
|
Windows |
|
Linux |
|
Resultado en 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"
}
}
}
}Reinicia Claude Desktop después de la instalación.
Resolución del binario codex: Claude Desktop (y launchd) inician el servidor MCP con un PATH reducido, por lo que codex normalmente no está en el PATH. El bridge busca en este orden — CODEX_BIN → ubicaciones de instalación habituales de la plataforma → PATH:
SO | Orden de búsqueda |
macOS / Linux |
|
Windows |
|
En macOS/Linux, codex es un script de Node con shebang #!/usr/bin/env node, así que el bridge también inyecta de nuevo el PATH (directorio actual de node + /opt/homebrew/bin + /usr/local/bin + directorios del sistema) a los procesos hijo; sin este paso, el app-server generado muere justo en el shebang.
macOS
App-server en segundo plano con launchd
node scripts/install-launch-agent.mjsCrea ~/Library/LaunchAgents/com.codex-mcp-bridge.app-server.plist (RunAtLoad + KeepAlive al fallar, ThrottleInterval 10s) y luego launchctl bootstrap gui/$UID. El app-server ya está vivo desde el inicio de sesión, por lo que el bridge no tiene que generarlo, y el hilo siempre está en estado en vivo.
launchctl print gui/$UID/com.codex-mcp-bridge.app-server | head -20 # trạng thái
node scripts/install-launch-agent.mjs --uninstall # gỡRegistro: ~/Library/Logs/codex-mcp-bridge/app-server.{out,err}.log.
Ver el hilo directamente en la aplicación de escritorio de Codex
La aplicación de escritorio de Codex en macOS es /Applications/ChatGPT.app y registra el esquema codex://. El bridge usa codex://threads/<threadId> para abrir el hilo correcto:
open_codex_thread { threadId: "01a0…", background: true }
send_to_codex_thread { threadId: "01a0…", prompt: "…", openInApp: true }Así es como quien asigna la tarea puede ver lo que Codex está haciendo en lugar de tener que releer el rollout ~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl al terminar.
Limitaciones en macOS
La aplicación de escritorio de Codex ejecuta su propio app-server a través de stdio (
ChatGPT.app/Contents/Resources/codex … app-server) y no acepta endpoints externos. Los hilos abiertos en la aplicación sí se pueden enviar a través del bridge, pero mediante el mecanismo de reanudación desde el rollout.jsonl, no como adjunto en vivo. No envíes a un hilo que esté ejecutando un turno en la aplicación de escritorio: dos app-server escribiendo en el mismo rollout pueden dañar el historial. Comprueba elstatusconlist_codex_threadsantes y envía solo cuando estéidle/notLoaded.Un repositorio en una partición NTFS de un equipo de doble arranque (
/Volumes/...) es solo de lectura en macOS: macOS monta NTFS en modo de solo lectura. Mantén un checkout propio en un disco APFS (p. ej.~/code/codex-mcp-bridge) para ejecutarlo y modificarlo.codex app-server daemon startusa el transporteunix://con un socket de control~/.codex/app-server-control/app-server-control.sock. El bridge no usa esta vía (protocolo de trama distinto al de WebSocket, sin API pública todavía): siempre se comunica a través dews://.
Variables de entorno
Variable | Por defecto | Descripción |
|
| Endpoint del app-server compartido. |
| detección automática | Ruta de |
|
|
|
|
| Cómo responder a las solicitudes de aprobación de Codex. Establece |
| detección automática según el SO | Fuerza la ruta de configuración al ejecutar |
| detección automática | Fuerza la ruta de |
Sobre la aprobación: Codex pedirá aprobación para comandos/parches si approval_policy no es never. Como no hay nadie delante de Claude Desktop para hacer clic, el bridge responde automáticamente según CODEX_BRIDGE_APPROVAL y lo registra en stderr. El valor por defecto approve coincide con la configuración approval_policy = "never" + sandbox_mode = "danger-full-access" en ~/.codex/config.toml; si restringes el sandbox, considera cambiarlo a deny.
Compartir el app-server con una sesión interactiva de Codex
Abre la TUI apuntando al mismo endpoint para que el hilo de la TUI y el hilo del bridge se vean como uno solo:
codex --remote ws://127.0.0.1:8791Ejecuta el app-server manualmente (sin depender del autostart del bridge):
codex app-server --listen ws://127.0.0.1:8791Pruebas
npm run checkComprobación rápida: el bridge arranca, inicia el app-server automáticamente si es necesario y lista los hilos.
npm run smokeSmoke test: crea un hilo nuevo, envía 2 turnos consecutivos y comprueba que Codex recuerda la palabra clave del turno anterior; es decir, el hilo es realmente continuo y no una sesión nueva cada vez.
Para comprobar el entorno desde Claude: llama a la herramienta codex_bridge_status.
Available Tools
18 toolscodex_bridge_statusCheck the Codex bridge environmentARead-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 sessionADestructive
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 onboardingARead-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 turnBDestructiveIdempotent
Stop a turn that is still running in a Codex thread.
Inputs: turnId (required), threadId (required).
list_codex_threadsList Codex threadsARead-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 workersARead-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 appAIdempotent
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 ClaudeADestructiveIdempotent
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 threadARead-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 sessionARead-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 deliveryARead-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 threadADestructive
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 computerADestructiveIdempotent
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 agentADestructiveIdempotent
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 threadADestructive
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-serverADestructiveIdempotent
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 replyARead-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 relayARead-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
Scored across 18 tools
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.
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).
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.
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
Related MCP Connectors
Shared memory MCP server for Claude Code, Codex, Gemini CLI and Cursor. Cited, editable.
Connect ChatGPT and Claude to your Mac, Windows or Linux with secure MCP remote access.
Talk to your public-facing AI from any MCP client — Claude, ChatGPT, Cursor, Cline, Windsurf.
Remote MCP server for supportsheep: run AI interviews and manage support content for your blog.
Related MCP Servers
- AlicenseBqualityDmaintenanceMCP server for managing Claude Code conversation sessions12MIT
- FlicenseNot gradedqualityDmaintenanceLocal MCP server for Codex to send prompts to ChatGPT Web Pro extension and manage repository tasks safely.1-
- AlicenseAqualityCmaintenanceAn MCP server that bridges Claude Desktop with Claude Code, allowing users to delegate tasks to Claude Code directly from Claude Desktop conversations, supporting both synchronous and background execution with session reuse.6MIT
- AlicenseAqualityDmaintenanceMCP 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.41MIT