Skip to main content
Glama

English · 简体中文

Codex Castor

Gemini talks human. Codex shuts up and ships. Zero tokens spent waiting.

Release Python 3.9+ Zero Deps Platforms License: MIT

Why Codex Castor · Benchmark · Quickstart · Monitoring · Permissions · Developer Docs · Homepage

https://github.com/user-attachments/assets/5ef7cb4c-914b-4e5f-a55f-bbb533259cee


Why Codex Castor?

Local Codex CLI writes solid, low-hallucination code — yet working with it directly often feels exhausting: dense jargon, defensive disclaimers leaking into your UI and READMEs, dated frontend taste, and subagent polling loops that burn tokens while waiting. Meanwhile, Gemini in Antigravity speaks plainly, nails visual taste, and clarifies requirements quickly.

Codex Castor puts Gemini in the architect seat and keeps Codex quietly executing in the background. You stay in one conversation with Gemini — no window-switching, no manual spec copy-pasting, and no token-burning status loops.

Pain point when running Codex solo

How Codex Castor fixes it

Robotic jargon & defensive disclaimers leaking into UI/docs

Gemini owns requirements, UX copy, and final review. Codex executes headless specs and returns structured reports.

Polling loops / sleep burning quota while waiting

True zero-token idle wait. Antigravity runs codex_dispatch & codex_resume with background: "always", sleeps at 0 LLM tokens, and wakes Gemini automatically when Codex finishes.

Parallel tasks colliding in one working directory

Managed Git worktrees. Concurrent workers run on isolated codex/<task_id> branches; Gemini inspects diffs and merges cleanly.

Expensive full repo re-reads on rework

In-session codex_resume. Sends file-specific review feedback back to the same Codex session with memory intact — preserving prior model & effort automatically.

Blindly cranking reasoning effort to xhigh

Empirical routing loop. Logs duration, tokens, rework rate, inline 1–5 ratings, and verbatim first replies (PreInvocation hook) into a Model × Effort matrix so Gemini routes smarter over time.

Switching windows to check quota, Fast mode, or approvals

Antigravity Composer Widget + Codex Monitor. Toggle Codex Fast mode, switch permission policies (full_access, approve_for_me, workspace_write, read_only), and watch 5h/7d quota right from the chat bar.

Studying MCP or multi-agent design? Even if you aren't on Antigravity yet, Codex Castor is a clean, self-contained reference implementation of a zero-dependency Python 3.9+ stdio MCP server (mcp/server.py), a standalone ui:// MCP App (mcp/monitor.html), and a zero-polling async delegation protocol.


Related MCP server: AgentBraid

Same-prompt benchmark

What happens when you give the exact same prompt — build a local single-page Pour-Over Coffee Tasting Atlas & Brew Studio with editorial magazine aesthetics, 6 single-origin beans, live preference matching, interactive brew curve, and unit tests — to Solo Codex (xhigh) vs. Codex Castor (Gemini + Codex medium)?

Same-prompt benchmark: Solo Codex xhigh vs Codex Castor Gemini + Codex medium

Metric

Solo Codex (gpt-6.2-sol · xhigh)

Codex Castor (Gemini + Codex medium)

Delta

First-draft wall time

13m 33s

5m 33s (parallel)

2.4× faster

Reasoning tokens

8,764

4,102

−53%

Passing unit tests

6

17

+183%

UI & repository cleanliness

3-screen landing page; "model estimate" / "for reference only" disclaimers in UI & README

Single-viewport editorial UI, clean copy, zero disclaimers

Night-and-day

Note: Real side-by-side run (UI labels translated to English for readability). Exact numbers vary by task, but separating architecture &amp; visual review from headless implementation consistently beats throwing maximum reasoning effort at a single agent.


Quickstart

Prerequisites: Python 3.9+, Git, a configured local Codex CLI, and Antigravity. Zero third-party Python packages required.

macOS & Linux

git clone https://github.com/JAY201368/codex-castor.git && cd codex-castor && ./scripts/install.sh --install-statusline

Reload Antigravity to pick up the MCP server, composer widget, hook, and orchestrator skill, then verify the installation:

python3 scripts/doctor.py

Windows 11 x64 (native PowerShell — no WSL or Git Bash required)

Install Python for Windows (with the py launcher), Git for Windows, the native Codex CLI, and Antigravity, then run:

git clone https://github.com/JAY201368/codex-castor.git
Set-Location codex-castor
py -3 scripts/install.py --install-statusline

Restart Antigravity and verify with py -3 scripts/doctor.py. If codex.exe is outside PATH, pass --codex-bin 'C:\path\to\codex.exe'.

  • Upgrading: Pull the latest changes (or download a release archive) and re-run ./scripts/install.sh (or py -3 scripts/install.py on Windows). Include --install-statusline when upgrading the optional CLI status line, and add --force-statusline only when replacing an existing custom status line.

  • Common flags: --symlink (link installed files to your checkout; requires Developer Mode / symlink permission on Windows), --gemini-dir PATH, --python PATH, --codex-bin PATH, --skip-gemini-md, --dry-run. Pass the same --gemini-dir to doctor.py; add --json for machine-readable diagnostics.

  • Hook backup: The installer registers the PreInvocation hook in ~/.gemini/config/hooks.json and backs up any existing file to hooks.json.bak before modifying it.

  • Uninstalling: Run python3 scripts/install.py --uninstall (or py -3 scripts/install.py --uninstall on Windows). Add --purge-state only if you also want to delete saved Castor telemetry and task logs.

Manual setup on macOS or Linux: Merge the codex-castor entry from config/mcp_config.example.json into ~/.gemini/config/mcp_config.json. Point command to Python 3.9+ and pass the absolute path to mcp/server.py. Keep telemetry.py, castor_platform.py, windows_process.py, composer_bridge.py, composer_widget.js, report.schema.json, and monitor.html alongside server.py (plus analytics.py and executable hook.py for an installed copy). Set CODEX_BIN to your Codex executable, install skills/codex-orchestrator/SKILL.md to ~/.gemini/config/skills/codex-orchestrator/SKILL.md, and merge config/GEMINI.md into ~/.gemini/GEMINI.md.

Merge this entry into ~/.gemini/config/hooks.json with your absolute Python and hook paths:

{
  "codex-castor": {
    "PreInvocation": [
      {
        "type": "command",
        "command": "[ ! -f '/path/to/hook.py' ] || '/path/to/python3' '/path/to/hook.py'",
        "timeout": 5
      }
    ]
  }
}

Live monitoring & analytics

Codex Castor gives you full visibility at zero LLM tokens:

  • Antigravity Composer Widget (mcp/composer_widget.js, mcp/composer_bridge.py): Adds a native status entry beside the Antigravity model selector to check live 5h / 7d Codex quota, toggle Fast mode, and switch the default permission policy (full_access, approve_for_me, workspace_write, read_only) in one click.

  • Codex Monitor MCP App (ui://codex-castor/monitor.html): Open in the Antigravity side panel or full-page view via codex_monitor. Refreshes every 1 second while active and every 8 seconds when idle via tools/call.

    • Tasks groups live runs and collapsible By Project history with filter counts (All, Active, Rated, Unrated), model/effort/Fast badges, concise failure summaries, two-step Cancel confirmation, full-screen Prompt & categorized Activity Stream viewers (per round for multi-round rework), and inline 1–5 star ratings & notes.

    • Analytics displays overall KPIs and a Model × Reasoning Effort matrix (excluding failed runs from aggregates) so Gemini and you can pick the fastest, cleanest tier for each kind of task.

  • Zero-token Wakeup Hook (scripts/hook.py): An Antigravity PreInvocation hook that renders each finished round's model, effort, duration, and token count inline via metadata.user_markdown and silently captures your first reply verbatim.

  • Terminal & Antigravity CLI: Run python3 scripts/watch.py (or --follow [TASK_ID]) for a standalone live terminal dashboard, or enable --install-statusline to stack active tasks beneath Antigravity CLI's default status bar (stack_with_default: true; silent when idle).

  • Standard MCP notifications: Pass _meta.progressToken for notifications/progress, or set logging/setLevel to info/debug for notifications/message.

Run from the repository (use py -3 instead of python3 on Windows). Every subcommand accepts --state-dir PATH:

python3 scripts/analytics.py summary [--model MODEL] [--effort EFFORT] [--project PROJECT] [--since YYYY-MM-DD] [--limit N] [--json]
python3 scripts/analytics.py backfill [--json]
python3 scripts/analytics.py feedback TASK_ID [--rating 1-5] [--verdict VERDICT] [--tags TAG1,TAG2] [--notes TEXT] [--user-prompt TEXT] [--round N]
python3 scripts/analytics.py export [--md PATH] [--csv PATH]
  • summary prints overall KPIs, the Model × Effort matrix, and recent tasks (15 by default; --since filters inclusively by creation date).

  • backfill reconstructs the ledger and exports from saved task artifacts while preserving existing feedback.

  • feedback updates the same records as codex_feedback (defaults to the current round).

  • export regenerates report.md and telemetry.csv in the state directory, or writes to a specific path.

Effective model and reasoning effort are resolved in priority order from the current rollout's turn_context, explicit codex_dispatch/codex_resume overrides, the previous round, project .codex/config.toml, and user ~/.codex/config.toml (or $CODEX_HOME/config.toml).


Security & permissions

Codex Castor supports four configurable permission policies (default: full_access), configurable globally in ~/.gemini/codex-castor/settings.json or via the Antigravity composer widget, and overridable per round via permission_mode:

  • full_access (default): passes --dangerously-bypass-approvals-and-sandbox and --dangerously-bypass-hook-trust for unattended execution.

  • approve_for_me: uses Codex's auto-review approval flow (--approve-for-me on dispatch; workspace-write sandbox with on-request / auto_review on resume).

  • workspace_write: restricts writes to the workspace (workspace-write sandbox with approval_policy="never").

  • read_only: restricts Codex to read-only inspection (read-only sandbox with approval_policy="never").

When using full_access, run Codex Castor only in trusted local developer workspaces. Managed Git worktrees isolate files and branches, while Codex retains the local user's OS permissions — always inspect git diff and run verification checks before merging.


Architecture & lifecycle

flowchart LR
    U["User"] --> G["Gemini / Antigravity"]
    G -->|"spec or review feedback"| B["MCP stdio · mcp/server.py"]
    B -->|"codex exec / codex exec resume"| C["Local Codex CLI"]
    C --> W["Optional managed Git worktrees · codex/task-a, codex/task-b"]
    C -->|"JSON events and final report"| B
    B -->|"Tool result → Antigravity wakes Gemini"| G
    G -->|"Independent diff and tests"| W
  1. Write a self-contained spec. Gemini inspects the codebase and covers objective, key files, requirements, constraints/non-goals, verification commands, and acceptance criteria.

  2. Route, dispatch, and yield. Gemini checks ~/.codex/models_cache.json (falling back to ~/.codex/config.toml) and past telemetry, picks model and reasoning_effort, prefixes toolSummary with [<model>·<effort>], enables use_worktree: true for concurrent workers, and ends its turn cleanly — zero status loops, zero sleep, zero polling timers.

  3. Review independently. On automatic wakeup, Gemini receives a compact result containing the six-field structured report schema (status, summary, files_changed, commands_run, tests_summary, open_issues), git.diff_stat, git.status_short, and telemetry. Gemini inspects the actual diff, runs tests, and either sends file-specific rework via codex_resume or merges and cleans up the worktree.

  4. Close the feedback loop. The PreInvocation hook displays round telemetry inline and records your first reply verbatim; ratings and notes from Codex Monitor feed straight back into future routing.

See the Orchestrator Skill for the complete protocol, or read the Illustrated Engineering Manuscript.

MCP tools reference

All seven tools use eager: true in Antigravity (timeoutSeconds: -1). The stdio server speaks newline-delimited JSON-RPC 2.0 and runs each tool call in a worker thread.

Tool

Background

Key inputs

When to use

codex_dispatch

always

Absolute workdir, spec or spec_file. Optional title, task_id, use_worktree (false), base_ref (HEAD), model, reasoning_effort, permission_mode, fast_mode, extra_writable_dirs.

Start a new implementation from a self-contained Markdown spec.

codex_resume

always

task_id (or session_id + workdir), and feedback or feedback_file. Optional model, reasoning_effort, permission_mode, fast_mode (omitted model/effort inherit from the prior round).

Send concrete review feedback back to an existing Codex session.

codex_feedback

off

task_id. Optional rating (1–5), verdict (accepted, rework, partial, rejected, abandoned), tags, notes, user_first_prompt, round.

Record or update ratings/verdicts or store the user's first reply verbatim.

codex_status

off

task_id or limit (default 20).

One-off inspection on explicit request or post-mortem debugging.

codex_cancel

off

task_id.

Stop Codex and all child processes (Job Object on Windows; SIGTERM → SIGKILL on macOS/Linux).

codex_cleanup_worktree

off

task_id. Optional delete_branch (false), force (false).

Remove a managed Git worktree after merge or discard.

codex_monitor

off

Optional task_id, limit (20), include_detail (false), refresh_quota (false).

Open the Codex Monitor MCP App or fetch structured snapshots, quota, analytics, and per-round prompt/activity detail.

What's included

Path

Purpose

mcp/server.py

Zero-dependency stdio MCP server managing subprocesses, worktrees, rollout model/effort tracking, quota refresh, failure summaries, and Monitor snapshots.

mcp/monitor.html

Self-contained MCP App (ui://codex-castor/monitor.html) with Tasks, Analytics, per-round prompt/stream drill-down, and inline feedback.

mcp/composer_widget.js · mcp/composer_bridge.py

Antigravity chat composer widget and local bridge for live 5h/7d Codex quota, Fast mode toggle, and permission policy selector.

mcp/telemetry.py

Locked telemetry/feedback ledger, synced JSONL/CSV/Markdown exports, historical backfill, and analytics aggregation.

mcp/report.schema.json

Six-field JSON Schema enforced on Codex's final handoff report.

mcp/castor_platform.py · mcp/windows_process.py

Cross-platform path/process helpers and native Windows Job Object termination.

skills/codex-orchestrator/SKILL.md

Gemini's end-to-end procedure for specs, model routing, independent review, and telemetry reporting.

config/mcp_config.example.json · config/GEMINI.md

Antigravity MCP wiring (background: "always") and global role-division protocol.

scripts/install.py · scripts/install.sh · scripts/doctor.py

Cross-platform installer, hook merger, uninstaller, and stdio handshake health check.

scripts/hook.py · scripts/analytics.py

Zero-token PreInvocation wakeup/reply hook and CLI analytics tool.

scripts/statusline.py · scripts/watch.py

Antigravity CLI native status line and standalone live terminal watcher.

tests/

Automated Python unittest and Node.js UI fixture suite run across macOS, Linux, and Windows CI.

~/.gemini/codex-castor/
├── settings.json                # default fast_mode & permission_mode
├── telemetry.jsonl
├── telemetry.csv
├── report.md
├── hook_state/
│   └── <conversation_id>.json   # transcript cursor and pending rounds
├── tasks/
│   └── <task_id>/
│       ├── spec.md
│       ├── meta.json
│       ├── events-r1.jsonl
│       ├── stderr-r1.log
│       ├── report-r1.json
│       ├── feedback-r2.md
│       ├── events-r2.jsonl
│       ├── stderr-r2.log
│       └── report-r2.json
└── worktrees/
    └── <task_id>/               # managed checkout on codex/<task_id>

Override the state root with CODEX_CASTOR_STATE_DIR and the Codex binary with CODEX_BIN. Outer process status and the worker's report.status are tracked separately — inspect both before accepting or resuming.

Testing & development

python3 -m unittest discover -s tests -v
python3 scripts/doctor.py --repo-only

On Windows, run py -3 -X utf8 -m unittest discover -s tests -v and py -3 scripts/doctor.py --repo-only. See the Windows 11 x64 verification guide for CI matrix and live Antigravity App/CLI verification details.


If Codex Castor saves your quota, sanity, or gives you a useful reference for async MCP Apps, a ⭐️ helps others find it.

Illustrated Manuscript Homepage · Glama Registry · Releases · MIT License

Codex Castor MCP server – quality and maintenance score on Glama

Available Tools

7 tools
codex_cancelB

Terminate a currently running Codex task immediately.

Inputs: task_id (required).

codex_cleanup_worktreeA

Remove a managed Git worktree created with use_worktree=true after Gemini has verified and merged (or discarded) its branch.

Inputs: task_id (required), force, delete_branch.

codex_dispatchA

Dispatch a detailed implementation specification to local Codex CLI running non-interactively with the configured Codex Castor permission policy (full access by default). Configured as an async background tool: after calling it, do NOT poll codex_status; either work on something else or stop your turn and wait for automatic wakeup.

Inputs: workdir (required), spec, model, title, +8 more.

codex_feedbackB

Record or update user/reviewer effectiveness feedback (rating 1–5, verdict, tags, notes) and/or the user's first prompt after a Codex round finishes. Automatically updates meta.json, telemetry.jsonl, telemetry.csv, and report.md.

Inputs: task_id (required), tags, notes, round, +3 more.

codex_monitorCodex MonitorC

Open the live Codex Castor monitor panel (side pane or full page in Antigravity App) or return a structured live snapshot of running and recent Codex tasks including effective model, reasoning effort, and current activity.

Inputs: limit, task_id, refresh_quota, include_detail.

codex_resumeA

Resume an existing Codex task/session with concrete review feedback or rework instructions while preserving Codex's prior session memory. Model and reasoning effort inherit independently from the previous round when known, unless explicitly overridden. Applies the configured Codex Castor permission policy (full access by default). Runs asynchronously as a background tool; do NOT poll after calling.

Inputs: model, task_id, workdir, feedback, +5 more.

codex_statusA

Non-blocking inspection of one Codex task (or list of recent tasks). Use ONLY when the user explicitly asks for progress or for post-mortem debugging—never poll in a loop.

Inputs: limit, task_id.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 7 tools

    Disambiguation4/5

    Most tools have clearly distinct lifecycle roles: dispatch, resume, cancel, cleanup, feedback, monitor, and status. The main ambiguity is between codex_monitor and codex_status, since both can report on running/recent tasks, though the descriptions distinguish a live UI/snapshot from explicit non-blocking inspection.

    Naming Consistency4/5

    All tools consistently use the codex_ prefix with snake_case, making the set predictable. Most names are action-oriented, though a few are noun-like (feedback, status, monitor), causing minor deviation from a strict verb_noun pattern.

    Tool Count5/5

    Seven tools is well-scoped for a Codex task orchestration server. Each tool maps to a distinct lifecycle operation, and there are no obvious redundant or filler tools.

    Completeness4/5

    The surface covers the core task lifecycle: dispatch, monitor, status, resume with feedback, cancel, worktree cleanup, and effectiveness feedback. Minor gaps may exist around retrieving full task output or configuring policy dynamically, but core workflows are supported.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      A
      maintenance
      An MCP server that bridges Claude Code with Antigravity CLI using a Swarm Agent architecture to optimize local development workflows and minimize LLM token costs. Includes a web UI for monitoring agent workflows.
      33
      731 PyPI
      35
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      A local-first MCP orchestration server that uses Codex as lead planner and Antigravity as host to delegate and review bounded tasks with Git integration and persistent SQLite state.
      Apache 2.0
    • A
      license
      Not graded
      quality
      C
      maintenance
      MCP server that bridges Claude Code to Google Antigravity's CLI, enabling Claude to orchestrate Gemini workers in parallel for reading, writing, verifying, and autonomous tasks. It provides tools for single dispatch, parallel fan-out, background jobs, and handles permission, cwd, and shell pitfalls.
      2
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      An MCP server that lets OpenAI Codex and Google Antigravity delegate tasks to each other, review each other's code, continue multi-round discussions, leave notes, and synchronize MCP servers, skills, and rules across both apps.
      MIT