antigravity-codex-mcp
Orchestrates OpenAI Codex CLI sessions, providing tools to start, resume, fork, review, poll, cancel, and retrieve results for asynchronous Codex jobs.
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., "@antigravity-codex-mcp start a Codex session to fix the failing tests in this repo"
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.
antigravity-codex-mcp
English | 简体中文
Cross-platform Model Context Protocol (MCP) server for orchestrating OpenAI Codex CLI sessions (codex exec --json, resume, fork, review) from Antigravity and MCP clients across Windows and Linux.
Features
Dual Transport (
stdio& Streamable HTTP/mcp):Zero-config local
stdiotransport for desktop IDE / CLI clients.Standard MCP Streamable HTTP (
/mcp) with stateful sessions by default (idle TTL &DELETE /mcpcleanup) plus--statelessmode for intermittent connections and reverse proxies.
Secure-by-Default HTTP Guardrails:
All HTTP launches — including
127.0.0.1(to protect reverse-proxy deployments) — require both Bearer Token authentication (crypto.timingSafeEqual) and--allowed-rootsworkspace allowlisting by default, and cap sandbox atworkspace-write.Built-in
HostandOriginvalidation against DNS rebinding, 4 MiB JSON body cap,realpathsymlink-escape protection, and strictresume/forkorigin validation (disablingallow_unindexedunder--allowed-roots).Automatic child-process environment sanitization stripping
CODEX_MCP_AUTH_TOKEN,CODEX_MCP_AUTH_TOKEN_FILE, and allCODEX_MCP_*variables before spawning Codex CLI.
Async Job Orchestration & Cross-Process Safety:
Bounded long-polling (
wait_seconds <= 55) with replayable event cursors (seq > cursor) and truncation metadata.Cross-process atomic
session_idlocks (O_CREAT | O_EXCL) paired with uniqueinstance_idheartbeat leases (preventing concurrent writes across windows/processes and avoiding bare PID-reuse false positives).Atomic per-job directory persistence with terminal job retention pruning and graceful
SIGINT/SIGTERMprocess-tree shutdown (Windowstaskkill /T /F& POSIX process groupsSIGTERM -> SIGKILL).
JSON Schema Output Validation: Validates structured final output with Ajv and returns field-level errors while preserving raw output.
Bundled Antigravity Plugin: Includes a ready-to-install plugin (
antigravity-plugin/) with manifest, icon, prefixed MCP config, and orchestrationSKILL.md.
Related MCP server: muster
Requirements
Node.js
>= 20.0.0Codex CLI (
codex) installed and authenticated on the host machine
Quick Start
Build from Source
npm install
npm run typecheck
npm run build
npm testMode 1: Local stdio (Desktop Antigravity / MCP Clients)
{
"mcpServers": {
"antigravity-codex": {
"command": "node",
"args": ["/absolute/path/to/antigravity-codex-mcp/dist/index.js"],
"env": {
"CODEX_CLI_COMMAND": "codex"
}
}
}
}Or install the bundled Antigravity plugin from antigravity-plugin/.
Mode 2: Streamable HTTP (Remote / Multi-Client over HTTPS)
Store a strong random token outside your workspaces (e.g. chmod 600 /etc/codex-mcp/token or C:\ProgramData\codex-mcp\token), then start the HTTP server behind an HTTPS reverse proxy:
node dist/index.js \
--transport http \
--host 127.0.0.1 \
--port 8765 \
--auth-token-file /etc/codex-mcp/token \
--allowed-roots /path/to/projects \
--allowed-hosts mcp.example.comFor clients behind reverse proxies or intermittent networks, add --stateless so requests do not depend on in-memory HTTP sessions (jobs and Codex sessions remain persisted on the server).
See docs/deployment.md for Caddy/Nginx HTTPS reverse-proxy templates, Linux systemd units, OS/container isolation guidance, and remote HTTP client setup.
Exposed Tools (12)
Tool | Description |
| Start a new async Codex session ( |
| Resume an existing session by |
| Fork an existing session ( |
| Run non-interactive code review ( |
| Bounded long-poll (default |
| Fetch final structured result (returns |
| Cancel an active job process tree (atomic against completion, retryable on kill failure). |
| List active and recent MCP jobs (newest first) for cross-window / reconnect |
| List allowed workspace roots/subdirectories (or recent dirs in unrestricted |
| List merged local ( |
| Inspect session metadata and recent user/assistant turns. |
| One-shot preflight & health check: verifies Codex CLI, active |
Security Threat Model & Boundaries
Trusted Single-Owner Positioning: HTTP mode is designed for trusted multi-client access by the same machine owner (e.g., your own Windows and Linux workstations over HTTPS + Bearer token).
What
--allowed-rootsProtects:--allowed-rootsand--max-sandboxare MCP control-plane guardrails. They strictly constraincwd,images,codex_list_workspacescandidates (pre-Gitrealpathcheck), session/job visibility, andresume/forksource + target directories (withallow_unindexeddisabled).What
--allowed-rootsDoes NOT Guarantee: Even underworkspace-write, Codex CLI's OS sandbox may still permit reading files outsidecwddepending on the host OS and Codex configuration. If you require strict filesystem read isolation for remote callers, run the MCP server under a dedicated OS user account with restrictive filesystem ACLs or inside a container mounting only the permitted project directories, and verify using a sentinel file outside the mounted directory (seedocs/deployment.md).Token Hygiene:
CODEX_MCP_*environment variables are stripped from all Codex child processes, and startup fails if--auth-token-fileresides inside--allowed-roots. Always keep token files outside workspaces with OS-level read restrictions.
CLI Flags & Environment Variables
Precedence: CLI flags > Environment variables > Transport-aware defaults.
CLI Flag | Env Variable | Default ( |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| unused / required |
|
| unused / required (alt) |
|
|
|
|
|
|
|
| loopback + bind host |
|
| loopback origins |
|
| unrestricted / required |
|
|
|
|
| unrestricted / |
|
|
|
|
|
|
|
|
|
|
|
|
|
| unset (no |
|
| unset (official Codex CLI default) |
|
| unset (official Codex CLI default) |
|
|
|
License
Available Tools
12 toolscodex_cancelA
Cancel an active Codex job by terminating its process tree. Atomic against completion and retryable on kill failure.
Inputs: job_id (required).
codex_forkB
Fork an existing Codex session by exact session_id or previous MCP job_id into a brand-new session.
Inputs: prompt (required), cwd, model, images, +10 more.
codex_get_sessionA
Inspect metadata and recent user/assistant conversation turns for a specific Codex session_id.
Inputs: session_id (required), max_turns.
codex_healthA
One-shot preflight and health check: verifies Codex CLI availability, MCP concurrency/policy limits, default model/reasoning config, cached models, and optional cwd/model/reasoning_effort readiness.
Inputs: cwd, model, reasoning_effort.
codex_list_jobsA
List active and recent asynchronous Codex MCP jobs (newest first). Useful for reconnecting or recovering job_id across windows/devices.
Inputs: cwd, kind, limit, status, +1 more.
codex_list_sessionsA
List Codex sessions by merging local $CODEX_HOME/sessions rollout files and MCP job records. Sessions in both appear as source='both' and match both local and mcp filters.
Inputs: cwd, limit, query, source.
codex_list_workspacesA
List available workspace directories (allowed roots + child directories in restricted mode, or recently used directories in unrestricted mode) with Git branch and dirty status.
Inputs: limit, query, include_children.
codex_pollA
Safely long-poll an asynchronous Codex job (wait_seconds <= 55). Supports replayable cursor (returns seq > cursor), truncation reporting, terminal/events wakeup modes, and optional intermediate event omission.
Inputs: job_id (required), cursor, wait_mode, wait_seconds, +1 more.
codex_resultA
Retrieve the final structured result of a completed/failed/cancelled/timed_out job. Returns ready=false without blocking if still active.
Inputs: job_id (required), include_events.
codex_resumeB
Resume an existing Codex session by exact session_id, previous MCP job_id, or use_last=true (mutually exclusive). Locks session identity strictly.
Inputs: prompt (required), cwd, model, images, +11 more.
codex_reviewA
Run a non-interactive Codex code review (codex exec review --json). Choose exactly one target: uncommitted=true, base branch, commit SHA (+optional title), or custom prompt.
Inputs: cwd (required), base, model, title, +10 more.
codex_runA
Start a new asynchronous Codex CLI session (codex exec --json). Returns a job_id immediately (or waits up to wait_seconds <= 55s).
Inputs: cwd (required), prompt (required), model, images, +7 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 12 tools
Most tools target clearly distinct operations: run (new session), resume, fork, review, poll, result, cancel all have specific roles clarified by descriptions. Minor overlap exists between codex_list_sessions and codex_list_jobs (both enumerate session/job records, with sessions merging both sources) and between codex_resume and codex_fork (both accept session_id or job_id), but the descriptions draw the lines adequately.
All tools share a consistent `codex_` prefix with a predictable verb_noun convention (codex_run, codex_resume, codex_poll, codex_list_sessions, codex_get_session). A couple of names are noun-only (codex_health, codex_result) rather than verb-led, a minor deviation from the otherwise uniform pattern.
Twelve tools is well within the ideal range and each maps to a distinct facet of the async job/session lifecycle. The set is cleanly organized into job control (run/poll/result/cancel), session management (resume/fork/list/get), plus review, health, and workspace listing, so no tool feels redundant.
The surface covers the full async lifecycle (start, poll, result, cancel), session continuation (resume, fork, list, get), review, and environment introspection (health, workspaces). Minor gaps remain: no session/job cleanup or deletion, no way to change default config (only read it via health), and no content-based session search.
Maintenance
Related MCP Connectors
A paid remote MCP for OpenAI Codex agent coordination MCP, built to return verdicts, receipts, usage
Shared memory MCP server for Claude Code, Codex, Gemini CLI and Cursor. Cited, editable.
Build, test, publish, and run Kovca workflows from AI agents over remote MCP.
Coordinate and verify OpenCode workers over MCP Streamable HTTP.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables MCP clients to spawn and control Codex CLI and Claude Code sessions on the host machine, with session management and filesystem access.4MIT
- AlicenseBqualityBmaintenanceEnables launching and supervising local Codex and Claude Code agent sessions and one-shot tasks, exposing run, list, stop, and output operations over MCP with session-scoped permissions and sandbox controls.2138 npm1MIT
- FlicenseNot gradedqualityCmaintenanceEnables MCP clients such as Codex to asynchronously launch, monitor, steer, and control persistent CodeBuddy CLI sessions, including permission responses, interruption, recovery, and shutdown. It also provides model and account queries plus optional WebUI monitoring.-
- AlicenseNot gradedqualityCmaintenanceEnables MCP clients to submit code review tasks to locally installed AI coding CLI agents, continue sessions, query progress, handle stop requests, and retrieve results and artifacts using the user's own authenticated accounts.1Apache 2.0