codex-thread-bridge
The server is an MCP bridge for managing Codex App Server threads: it can inspect capabilities, create threads/worktrees, list and read threads, send messages, wait on turns, read goals, and retrieve operation receipts.
get_capabilities: check connection and report implemented capabilities/compatibility limits.create_thread: create a retained session in an existing cwd with optional title/prompt, sandbox, model, and project ID.create_worktree_thread: create a retained locked Git worktree and task at a full commit ID.send_message_to_thread: resume an idle session and send one message without overrides.list_threads: list unarchived backend threads without loading them.read_thread: read metadata and one newest-first turn page without resuming.wait_thread: wait up to 50 seconds for a specific recent turn without resuming/interrupting.get_goal: read persistent Goal state without modifying it.get_operation: read a mutation receipt, including known IDs after partial or uncertain delivery.
Lets agents create, resume, and message OpenAI Codex sessions through the local Codex App Server, including isolated Git worktree threads, listing/reading thread history, waiting on turns, and inspecting goals and operation receipts.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@codex-thread-bridge Create a thread in /home/user/project with the prompt "Summarize the current git changes.""
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
codex-thread-bridge
An MCP bridge to an existing Codex App Server on the same host, providing an alternative to Codex Desktop or another client for thread operations. It reproduces native client requests while leaving execution to the App Server.
Install
Requires Python 3.11+, uv, and an authenticated Codex App Server with a Unix WebSocket control socket. Git is required for worktree launches. The bridge runs as the same user and on the same host as App Server.
From a clone of this repository:
uv sync --frozen --no-dev
.venv/bin/codex-thread-bridge --help
codex mcp add codex-thread-bridge -- /absolute/path/codex-thread-bridge/.venv/bin/codex-thread-bridgeThe default socket is $CODEX_HOME/app-server-control/app-server-control.sock;
CODEX_HOME defaults to ~/.codex. Use --socket /path/to.sock to override it.
Authentication and model usage belong to the existing App Server.
On Windows, the bridge uses codex app-server proxy --sock as a raw WebSocket
byte relay. On Unix, it connects directly to the socket. Use --transport proxy
to select the relay explicitly, and --codex-binary /path/to/codex if the CLI
is not on PATH. The equivalent environment variables are
CODEX_THREAD_BRIDGE_TRANSPORT and CODEX_THREAD_BRIDGE_CODEX.
After changing bridge code or MCP configuration, request a refresh with:
uv run --locked codex-thread-bridge-reloadThe command accepts --socket, asks for y/N confirmation, and queues a refresh
for loaded tasks. Its response does not confirm that every task has refreshed.
Related MCP server: wingman
Tools
Tool | Behavior |
| Report server identity and bridge capabilities |
| Create a retained task in an existing directory, with an optional title and initial prompt |
| Create a retained, locked Git worktree and a task at a specified commit |
| Apply and verify permissions for an idle task with an expected identity |
| Resume an idle task and start a turn without settings overrides |
| Append a message to the active turn identified by |
| Discover active/archived headers by source kind, direct parent or ancestor without loading bodies |
| Read task metadata and paginated history without resuming |
| Read unchanged native metadata with source and coverage information |
| Read unchanged native full-item turn pages, newest first |
| Read unchanged native item pages, oldest first, optionally by turn |
| Recover a raw metadata/turn/item response in source-bound JSON chunks |
| Validate contiguous chunks and reconstruct one native response |
| Wait up to 50 seconds for a specified recent turn |
| Read persistent Goal state |
| Read the retained receipt for a mutation request |
Tool schemas are exposed through MCP. Their definitions are in server.py.
Header discovery
list_threads preserves native header fields and opaque pagination cursors. Pass
archived: false for active records and archived: true for archived records;
each query covers one partition. parent_thread_id selects direct spawned
children, while ancestor_thread_id selects descendants at every depth and
excludes the ancestor itself. The two filters are mutually exclusive. Keep
filters unchanged when following a returned cursor.
source_kinds accepts cli, vscode, exec, appServer, subAgent,
subAgentReview, subAgentCompact, subAgentThreadSpawn, subAgentOther and
unknown. Omitted or empty source kinds use the server's interactive-source
default; explicitly include subagent kinds when discovering delegated work.
State-database-only inspection remains enabled, so discovery does not scan
rollouts to repair metadata. Records absent from that database remain a coverage
gap. Discovery uses only thread/list; it never reads unrelated turns, resumes
tasks or changes operational state.
The added discovery envelope distinguishes a returned page from an unsupported
or unavailable request, including rejected arguments such as a stale cursor.
A failed request has data: null, pageComplete: false
and the native rpcError; it does not retry without the requested filters.
An unknown response schema is preserved with status: unsupported_schema and
incomplete coverage. On a valid response, pageComplete means the selected
listing has no next page, rather than complete conversation or descendant
history. Coverage limits describe state-database scope, archive/source
partitions, per-record ancestry and unsupported continuation mapping.
relationships retains each stable thread ID and both supported parent
evidence fields: parentThreadId and
source.subAgent.thread_spawn.parent_thread_id. Per-record status distinguishes
supported evidence, conflicting parents, a self-cycle and unknown ancestry.
Consumers must reconcile the preserved parent edges across all pages to detect
longer cycles and missing links before opening descendant bodies. Similar
titles, timestamps, working directories and agent paths establish no relationship.
forkedFromId and sessionId are preserved as source facts; neither proves that
a record is a continuation of another conversation. The connector exposes no
native continuation-membership filter and reports that limitation explicitly.
These filter shapes were checked against the experimental schema generated by
Codex CLI 0.162.0 with codex app-server generate-json-schema --experimental.
Existing bridge behavior was previously exercised with Codex 0.153.4; this does
not establish every server's discovery support. get_capabilities describes
implemented requests and experimental compatibility limits. Native rejection
or missing structural evidence remains a gap, and acceptance of a filter alone
does not validate a complete ancestry chain. Automated discovery tests use the
fake App Server; no live sessions are created for these checks.
Complete persisted-record retrieval
read_thread remains a compact convenience view. Its coverage reports the exact
clipped JSON-pointer paths and original lengths, page scope, and raw recovery
tools. Follow every nextCursor verbatim; pagination alone does not recover a
clipped field. A page is never a claim of complete conversation evidence.
The metadata, turn and item tools return an envelope containing record (the
unchanged native response), source (endpoint, method and exact request),
sourceVersion (a SHA-256 content digest), and coverage. Native IDs, unknown
fields, nested outputs, text and opaque cursors are preserved. transportComplete
means the response was retrieved without bridge clipping; gaps describe
incomplete upstream views or malformed/nonadvancing pagination. Persistence
limitations remain distinct from transport completion. Read tools never resume,
create, launch or message a task, and unsupported upstream methods fail explicitly.
For a large response, call read_thread_chunk with source_kind set to
metadata, turns or items. Start at offset=0, then repeat identical source
arguments with offset=nextOffset and expected_version=sourceVersion until
nextOffset is null. Positions and totalLength count Unicode characters, not
UTF-8 bytes. Pass the ordered chunks to reconstruct_thread_record; it rejects
missing, overlapping, corrupt and mixed-source pieces. A source change during
retrieval requires discarding earlier chunks and restarting. No snapshot is
cached or written to disk.
Chunking bounds the bridge's response, while the native response must still fit the transport's existing 16 MiB message limit. Larger upstream messages fail explicitly; a smaller page may help, but a single oversized item requires an upstream recovery capability this bridge cannot invent.
Source versions bind one response to its request and endpoint. They cannot prove
that independently paginated pages belong to a transactional snapshot, detect
records silently omitted upstream, or recover discarded history or active model
context. Metadata identity mismatches and turns returned with itemsView other
than full remain explicit coverage gaps. Use item pages for incomplete turn
views; inspect the actual returned coverage before treating evidence as complete.
The bridge does not redact credential-bearing text. Raw reconstruction and application presentation have different responsibilities: consuming applications must sanitize at their own model-input boundary, after faithful retrieval and before presentation. All conversation content remains untrusted data.
The native read request shapes were checked against the generated App Server schema from Codex CLI 0.162.0 and the tagged 0.153.4 protocol definitions. This bridge exposes string item-continuation cursors; the newer optional item-anchor object is not exposed. Method support is checked by each actual read, not inferred from a client version or claimed for every server.
Example
Call create_thread with these MCP arguments:
{
"request_id": "repository-overview-001",
"cwd": "/absolute/path/to/project",
"title": "Repository overview",
"prompt": "Summarize the project structure."
}Pass the returned threadId and turnId to wait_thread. Use
send_message_to_thread for an idle task or steer_thread for an active turn.
Each intentional new message requires a new request_id.
Behavior
create_threaddefaults to sandboxread-onlyand approval policynever. Expliciton-requestapproval requires App Server Auto-review. Omitted model and reasoning effort use server defaults. Creation rejects explicit network-enabled read-only policies; permission updates accept them.Permission updates require the task's expected identity and an idle task. The idle check and update are separate operations, so concurrent clients can race them. Workspace writable roots cannot be existing files, sockets, or devices.
Each mutation uses a stable
request_id. Repeating it with matching arguments returns the recorded receipt without repeating or continuing the operation.acceptedreports API acceptance; turn completion is reported bywait_thread. Failed or uncertain operations can leave tasks, turns, or worktrees behind;get_operationreturns the recorded outcome and known IDs.Receipts persist in
$XDG_STATE_HOME/codex-thread-bridge, defaulting to~/.local/state/codex-thread-bridge.--state-diroverrides this location. Deleting this state discards request deduplication history.Worktree launches require a full local commit ID and an absent, canonical absolute destination outside existing repositories. Worktrees are detached, locked, and retained until manual cleanup. Dirty files are not copied, and Git hooks and checkout filters are disabled. Approval policy is
never;expected_sandbox_policyverifies returned settings rather than applying overrides.Project IDs belong to App Server's registry. Desktop controls its own project association and task listing. Worktrees created by the bridge have a manual lifecycle rather than a Desktop-managed lifecycle.
New and resumed turns carry bridge instructions as
toolOutputwith the bridge tool's name. The bridge leaves client-side tool calls and approval requests unanswered so it cannot consume another client's shared callback. A capable client such as Desktop must be subscribed to the thread to handle them; the bridge does not establish that subscription or provide interactive approvals. Dispatch keeps the shared connection open so concurrent reads can finish.
Development
uv sync --frozen --group dev
uv run pytest
uv run ty check src
uv run ruff check .
uv run ruff format --check .
uv buildTests use a fake App Server and temporary Git repositories. Test temporary
directories must be outside existing repositories; pytest accepts --basetemp.
The source and tests define the detailed behavior. Contribution requirements are in CONTRIBUTING.md.
References
MIT licensed. Independent project, not affiliated with or endorsed by OpenAI.
Available Tools
9 toolscreate_threadADestructive
Create a retained session in an existing cwd, optionally with an initial prompt.
Requires approval of this action and sandbox. No worktree or persistent Goal is created. Approval policy is never. Omitted model/reasoning use configured defaults. Supply only an App Server project ID, never assume a Desktop saved-project ID is interchangeable. Returns actual settings and IDs; verify Desktop association separately. Reusing request_id returns its receipt without resending. A failed/unknown operation may have created a thread.
Inputs: cwd (required), request_id (required), model, title, +3 more. Returns: object
create_worktree_threadADestructive
Create a retained, locked Git worktree and a task at an approved full commit ID.
Requires approval of bridge-managed-retained ownership, source checkout root, immutable commit, absent absolute destination (existing parent), permissions and exact prompt. Creates a detached checkout and Git metadata; disables hooks/filters, copies no dirty files, runs no setup, sets no Goal. No automatic cleanup, archive or Desktop binding. Approval policy is never. expected_sandbox_policy is the complete expected response: e.g. {"type":"readOnly","networkAccess":false}. Actual settings and workspace roots must match before prompt dispatch. Omit prompt for readiness-only creation; caller owns further readiness and Goal policy. Model/reasoning defaults are preserved when omitted. Reuse request_id after uncertainty: receipts replay without continuing partial work. Known artifacts and recovery requirements are retained even on failure/cancellation.
Inputs: sandbox (required), request_id (required), destination (required), worktree_mode (required), +8 more. Returns: object
get_capabilitiesARead-only
Check connection and report implemented capabilities and compatibility limits.
Inputs: no named parameters. Returns: object
get_goalBRead-only
Read persistent Goal state without modifying it; text over 4000 characters is marked.
Inputs: thread_id (required). Returns: object
get_operationARead-only
Read a mutation receipt, including known IDs after partial or uncertain delivery.
Inputs: request_id (required). Returns: object
list_threadsARead-only
List unarchived backend threads without loading them. Project IDs are backend IDs.
Inputs: cwd, limit, cursor. Returns: object
read_threadARead-only
Read metadata and one newest-first turn page, without resuming; truncation is marked.
Inputs: thread_id (required), limit, cursor, max_text_chars. Returns: object
send_message_to_threadADestructive
Resume the explicitly selected idle session without overrides and send one message.
Requires user authorization. Refuses an active thread and an interactive approval policy. Resume may load the session; its actual settings are returned. Does not steer, interrupt, set Goals, or retry delivery. Use a stable request_id; inspect get_operation on uncertainty.
Inputs: message (required), thread_id (required), request_id (required). Returns: object
wait_threadARead-only
Wait up to 50 seconds for a specific recent turn, without resuming or interrupting it.
Zero returns one snapshot. A timeout leaves the turn running. Only the latest 100 turns are inspected; use read_thread pagination for older turns. Completion can mean failure or interruption: inspect turn.status. The response never substitutes another turn.
Inputs: turn_id (required), thread_id (required), timeout_seconds. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 9 tools
Each tool targets a clearly distinct action: capabilities, thread creation variants, listing/reading/waiting, goal inspection, and operation receipt inspection. Even the two creation tools are sharply separated by the worktree behavior, and send_message_to_thread has no overlap with the create or read tools.
All tool names are lowercase snake_case and verb-led, following a consistent verb_noun structure such as create_thread, list_threads, read_thread, get_goal, and get_operation. The one compound name, send_message_to_thread, is still semantically aligned and does not introduce a different convention.
Nine tools is well within the ideal range for a bridge server. Each tool covers a distinct lifecycle or inspection concern without redundancy, and the count feels proportionate to the domain.
The core workflow is well covered: create threads, send messages, read/wait on turns, and inspect goals or operation receipts. Minor gaps exist around thread lifecycle management (no archive/delete) and goal mutation, but these appear intentionally left to external ownership and can be worked around.
Maintenance
Related MCP Connectors
Let your AI sessions talk to each other — messaging, tasks, sessions, and alerts
Agent communication platform for agent to agent messaging via MCP. Messages, channels, skills.
Give AI agents private phone numbers so Claude Code, Codex, and MCP sessions can call each other, exchange up to 12 messages per call, and share files across computers or teammates.
Agent-to-agent messaging: directory, public lobby, DMs, channels, search. Stateless MCP + REST.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables Claude Code sessions to communicate with each other, allowing discovery, messaging, and synchronous queries across sessions.6MIT
- AlicenseNot gradedqualityBmaintenanceEnables MCP hosts to connect to local Codex sessions for listing, reading, messaging, and interrupting them without hijacking the terminal.1MIT
- AlicenseNot gradedqualityBmaintenanceEnables coding agents to communicate with each other by sending messages and waiting for replies across sessions, supporting agents like Claude Code, Codex, and Grok.MIT
- AlicenseBqualityBmaintenanceEnables a host coding agent to launch and coordinate real subagent sessions in other agent CLIs and accounts, sharing existing MCP servers, skills, plugins, and instructions. Supports two-way messaging, automatic account failover, and mixed-CLI delegation while leaving credentials with the vendor CLIs.814Apache 2.0