codex-subagent
Delegates coding, review, and analysis tasks to an independent OpenAI Codex subagent over the Codex app-server JSON-RPC protocol, with persistent threads, sandbox/permission control, image inputs, structured output schemas, compaction/fork, and background job telemetry.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Antigravity Codex Subagent (v0.4.0)
English | 简体中文
Standalone Node.js stdio MCP server plugin for Antigravity that delegates tasks to an independent OpenAI Codex subagent over the official @openai/codex app-server --stdio JSON-RPC v2 protocol.
Supports persistent multi-turn threads (sessionKey / threadId), protocol-level sandbox switching (read-only / workspace-write / danger-full-access), multimodal local image inputs, JSON Schema outputSchema, live progress & streaming telemetry, MCP notifications/progress, mid-turn steering (steer), in-place context compaction (compact), thread branching (fork), crash/restart recovery, and an opt-in warm worker pool.
Prerequisites
Node.js
>= 20.0.0Codex CLI (
@openai/codex) installed globally or locally inside this plugin directory:npm install -g @openai/codexCodex Authentication: run
codex login(or configureOPENAI_API_KEY/~/.codex/config.toml).
Related MCP server: antigravity-workers
Installation (Antigravity)
Clone this repository into Antigravity's plugins directory as
codex-subagent:macOS / Linux:
git clone https://github.com/Kiraliang954321/antigravity-codex-subagent.git ~/.gemini/config/plugins/codex-subagentWindows (PowerShell):
git clone https://github.com/Kiraliang954321/antigravity-codex-subagent.git "$env:USERPROFILE\.gemini\config\plugins\codex-subagent"
(Optional) Customize
mcp_config.jsonif you want to overrideCODEX_MODEL,CODEX_WARM_IDLE_MS,CODEX_WRAPPER_PATH, or forward proxy variables (HTTP_PROXY,HTTPS_PROXY,ALL_PROXY,NO_PROXY).Reload plugins in Antigravity so the
codex-subagentMCP server and its bundledskills/codex-subagent/SKILL.mdare registered.
Provided MCP Tools
subagent_codex: Delegate a coding, review, or analysis task to an independent Codex subagent via@openai/codex app-server --stdio. Supports:Ephemeral or persistent multi-turn threads (
sessionKey/threadId) withexcludeTurns: trueresume optimization.Protocol-level sandbox & permission switching via
sandbox("read-only","workspace-write","danger-full-access") andpermissionMode("never","read-only","approve-for-me","dangerously-bypass-approvals-and-sandbox"), with fail-closedread-onlyenforcement.Multimodal local image inputs via
images(localImageblocks validated upfront up to 10 images / 20MB each before acquiring a lease).Structured output constraints via JSON Schema
outputSchema(action: "run").Context window usage footer (
[codex-thread threadId=... resumed=... tokens=<used>/<window> (<pct>%)]) with automatic[CONTEXT_WARNING]at>= 80%utilization.Thread lifecycle operations: in-place compaction (
action: "compact"), thread branching (action: "fork"withtargetSessionKeyand optionallastTurnId), and archiving (action: "close").
subagent_codex_wait: Continue waiting for, steer (steer+ optionalimages), or cancel a background Codex job whensubagent_codexreturnsstatus: "running"with ajobIdand livetelemetry(turnId,phase,lastActivityAt, monotonicidleMs,currentActivity,activeCount, 5-itemrecentActivitiesring buffer,plan,diffSummary,tokenUsage). Unclaimed settled job receipts are atomically persisted to an isolated per-store directory (data/jobs/<store>-<hash>/<jobId>.json, 30-minute TTL) so results survive MCP server restarts. Also emits throttled MCPnotifications/progresswhen_meta.progressTokenis supplied.subagent_codex_list_sessions: Inspect persistent Codex threads (sessions, includingusedandcontextWindow) and active or unclaimed background jobs (activeJobs, including live telemetry and disk-persisted unclaimed receipts).
Configuration (mcp_config.json env)
Variable | Default | Description |
| unset (inherits | Optional default Codex model for new sessions (resumed turns preserve their prior session model unless overridden per call). |
| unset (inherits | Optional default reasoning effort ( |
|
| Default synchronous wait window in ms before returning |
|
| Default approval/sandbox preset ( |
| unset | Optional default sandbox override ( |
|
| Opt-in warm |
|
| Grace period waiting for clean child exit after closing stdin. |
|
| Bounded grace period waiting after subprocess termination. |
|
| Per-RPC request timeout in ms (inside |
| unset | Optional per-turn timeout in ms. |
|
| Idle persistent session expiration TTL. |
|
| Maximum tracked persistent sessions before LRU archiving. |
|
| Isolated session registry path ( |
| auto-resolved | Optional explicit path to |
| unset | Optional directory anchor searched when resolving |
| unset | Optional Codex home directory override. |
| unset (inherits environment) | Optional proxy settings forwarded to the spawned |
Architecture
mcp/server.mjs: MCP stdio JSON-RPC server, tool schemas, job lifecycle, telemetry aggregation, and warm worker coordination.mcp/codex-wire.mjs:@openai/codex app-server --stdioJSON-RPC v2 framing, activity/delta heartbeats, plan/diff coalescing, and turn/thread RPC methods.mcp/codex-client.mjs: Subprocess lifecycle,@openai/codexbinary resolution, thread config assertions, rollout JSONL validation, warm worker pool,compact, andfork.mcp/session-store.mjs: Persistent session registry with exclusive.lockfencing, uncertain reconciliation coordination, and atomic fork/lease transactions.mcp/disk-job-store.mjs: Per-store isolated disk job receipts and atomic single-claim recovery across MCP restarts.mcp/local-path-guard.mjs: Path/reparse/UNC/device/network-drive guards and multimodallocalImagevalidation.mcp/subprocess-adapter.mjs: Cross-platform subprocess spawn/drain/tree-termination adapter (taskkill /T /Fon Windows).
Testing
Run offline unit, protocol, concurrency, and mock-MCP tests (no network or Codex login required):
npm run test:unitRun the full automated suite (includes live @openai/codex E2E tests — requires an authenticated @openai/codex installation and network access):
npm testResilience & Safety
Registry Isolation: Keeps its own registry at
data/codex-subagent-sessions.json(and unclaimed job receipts underdata/jobs/) with an exclusive.lockfile so concurrent harnesses never collide.Uncertain Thread Reconciliation: Interrupted threads left in
state: "uncertain"after a crash or restart are probed read-only viathread/read+ rollout JSONL validation (non-blocking background startup sweep with a 15-second budget, plus on-demand recovery inacquire()/acquireFork()), restoring intact threads toready, cleaning archived/missing entries, and preservinguncertainon corrupt rollouts,systemError, or transient timeouts.Windows Process-Tree Teardown & Local-Path Guard: Subprocess termination executes
taskkill /pid <pid> /T /Fand waits for process-tree exit before allowing archive or worker replacement. Windows drive-type checks usefsutil fsinfo drivetypewith PowerShell[System.IO.DriveInfo]fallback, rejecting UNC, device namespaces (\\?\,\\.\), mapped network drives, and remote reparse points before touching target paths.
Acknowledgements
Portions of the @openai/codex app-server protocol client lifecycle and subprocess drain design were inspired by @deepseek-ai/dsh-subagent-codex (MIT License).
License
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Multiplayer for the coding agents your team already uses: shared tasks, decisions, skills and tools.
Coordination hub for AI coding agents: message teammates, ask humans, audit every event.
Scoped agent execution. Server-side credentials, policy, budgets and verifiable receipts.
Your AI apps as one team: hand work to Codex or Claude Code on your Mac, with a shared logbook.
Related MCP Servers
- AlicenseAqualityBmaintenanceEnables Claude Code and Claude Desktop to delegate token-heavy tasks to Antigravity headless subagents, offloading file edits, test runs, and exploration while preserving Claude's context window.121MIT
- AlicenseAqualityCmaintenanceEnables Codex to delegate bounded code analysis, review, isolated edits, multimodal research, and native image generation to supervised Antigravity workers, with queued execution, retries, and inspectable patches.232MIT
- AlicenseAqualityBmaintenanceEnables Claude Code or any MCP client to delegate hands-on coding work to OpenAI Codex over a persistent app-server process, keeping long-lived threads with follow-ups, async polling, approvals, steering, and interrupts. Supports native code review, resuming existing sessions, structured output, and parallel worktree-isolated tasks.1024 npm1MIT
- AlicenseNot gradedqualityBmaintenanceEnables Antigravity to delegate concrete local coding tasks to Codex CLI with durable sessions, background execution, native chat links, and event-driven receipts.MIT