CODEX CASTORMS. MMXXVI · ZERO-DEP MCP

Folio I · Asynchronous Orchestration

The Architect
drafts. The Artisan
builds.

Gemini (Antigravity) writes the brief. Local Codex CLI builds, using isolated Git worktrees for parallel runs. Castor’s zero-dependency MCP stdio server returns results without polling. It records dispatch history and real user feedback so you can refine model and reasoning settings and keep improving the workflow.

0 TOKEN IDLE · REACTIVE WAKEUP

Codex Castor manuscript illustration of an architect’s lectern with an armillary sphere and mechanical reins guiding two clockwork steeds beside parallel workshops
Fig. I — Command lectern & reins for two clockwork steeds
Zero DependenciesPython 3.9+ stdlib
Zero Pollingbackground: always
Parallel IsolationManaged Git worktrees
Strict Contractreport.schema.json

Folio II · Tabula I

The dual-mind architecture

The patron and architect agree on the work. Castor sends the brief to local Codex and returns a compact result for independent review. Dispatch metrics and the user’s response help the architect refine model and reasoning choices and adapt the way they work together.

The architect, MCP server, and parallel Codex workshops The patron briefs Gemini in Antigravity. Gemini sends the spec to the MCP server. Each tool call gets a worker thread. Codex CLI artisans run in separate worktrees. The server saves the event stream and returns a report and Git summary. Antigravity wakes Gemini, which can resume a session with review feedback. Patron · User Gemini / Antigravity Architect · read repo, review diff spec.md Reactivewakeup codex_resume Codex Castor MCP Server mcp/server.py · JSON-RPC 2.0 stdio · timeoutSeconds: -1 One thread per tool call Codex CLI · Artisan A codex/task-a Isolated Git worktree Codex CLI · Artisan B codex/task-b Isolated Git worktree Event ledger · report · Git summary events-r1.jsonl · report-r1.json · git diff --stat
The server runs codex exec or codex exec resume with --json, --output-schema report.schema.json, and --dangerously-bypass-approvals-and-sandbox. Events stream to disk. The tool returns the report, Git summary, and artifact paths, triggering Antigravity’s wakeup.

The Architect · Gemini

Read the repository, clarify the design, write spec.md, review the real git diff, and run the acceptance checks independently.

The Artisan · local Codex CLI

Implement the brief, verify the change in the assigned checkout, and deliver the six-field JSON report. Resume the same session when review calls for rework.

Folio III · Tabula II

The zero-polling cycle

Antigravity runs dispatch and resume in the background. End the turn or work on something unrelated until the result arrives. Each run and user reply add to the record that informs the next dispatch.

The five stages of a background task Draft a spec, dispatch, yield at zero idle tokens, wake on completion, and review independently. Accept and clean up or send feedback to resume the same session. The old folly Polling every 15s burns context & tokens IIIIII IVV Draft the spec Dispatch in background Yield at zero tokens Wake on completion Review independently Rework · codex_resume Accept · merge · clean up
Zero polling. Let completion ring the bell.
  1. Draft the spec

    Gemini reads the repository and writes a six-part Markdown brief covering objective, context, detailed requirements, constraints, verification, and acceptance.

  2. Dispatch in background

    Before the session’s first dispatch, check ~/.codex/models_cache.json for available models and reasoning levels, with ~/.codex/config.toml as fallback. Use outcomes and feedback from similar tasks to choose model and reasoning_effort and pass them explicitly to codex_dispatch (background: "always"). Start each dispatch or resume toolSummary with [<model>·<effort>]. Set use_worktree: true for parallel workers in one repository. Share the task ID and branch when enabled.

  3. Yield at zero tokens

    Gemini yields while Codex works autonomously. Skip polling loops, polling timers, and sleeps.

  4. Wake on completion

    Antigravity wakes Gemini on tool return with the JSON report and git.diff_stat.

  5. Review independently

    Inspect the diff and run the checks. Merge accepted changes before codex_cleanup_worktree, or send specific feedback through codex_resume to preserve session memory.

    Report model·effort, rounds and reworks, total duration, and total tokens in the acceptance summary. After presenting any round, Gemini records the first user reply verbatim using codex_feedback with that task_id and round, including any rating, verdict, tags, or notes the user gives. Users can also rate or leave notes in Codex Monitor. Use this record to refine Step II’s settings and address what users found difficult in the workflow.

Folio IV · Tabula III

Seven MCP instruments

All seven tools load eagerly (eager: true), with async background mode configured in Antigravity. Select a tool to inspect its parameters, call payload, and returned result.

codex_dispatch

background: always

Start a new implementation from a self-contained Markdown spec. By default Codex edits the active checkout.

ParameterUse
workdirRequired absolute path to the target directory.
spec / spec_fileProvide Markdown text or the absolute path to a spec file.
titleOptional concise, human-readable task title.
task_idOptional unique ID. The server generates one when omitted.
use_worktree / base_refCreate a managed worktree and select its base. Defaults: false and HEAD.
model / reasoning_effortOptional overrides at the tool level. The orchestrator skill selects both explicitly from the live ~/.codex/models_cache.json.
extra_writable_dirsOptional paths passed through via --add-dir.
Example call
{
  "name": "codex_dispatch",
  "arguments": {
    "workdir": "/home/dev/project",
    "spec_file": "/home/dev/specs/task-a.md",
    "title": "Document the CLI",
    "task_id": "task-a",
    "model": "gpt-6.2-sol",
    "reasoning_effort": "high",
    "use_worktree": true
  }
}
Return excerpt
{
  "task_id": "task-a",
  "round": 1,
  "status": "completed",
  "duration_seconds": 38.5,
  "effective_model": "gpt-6.2-sol",
  "effective_reasoning_effort": "high",
  "rework_count": 0,
  "total_duration_seconds": 38.5,
  "total_usage": {"input_tokens": 3600, "output_tokens": 900, "total_tokens": 4500},
  "report": {
    "status": "completed",
    "summary": "Documented the CLI.",
    "files_changed": [
      "README.md"
    ],
    "commands_run": [
      "git diff --check (passed)"
    ],
    "tests_summary": "Diff whitespace check passed.",
    "open_issues": []
  },
  "git": {
    "branch": "codex/task-a",
    "diff_stat": "README.md | 2 ++"
  }
}

Set use_worktree: true whenever two or more artisans edit the same repository.

codex_resume

background: always

Continue a previous Codex session with concrete review feedback in its work directory.

ParameterUse
task_idReuse the session and working directory from an earlier task.
session_id / workdirSupply both when resuming without a task ID.
feedback / feedback_fileProvide actionable feedback or the path to a Markdown feedback file.
model / reasoning_effortOptional Codex model and reasoning overrides.
Example call
{
  "name": "codex_resume",
  "arguments": {
    "task_id": "task-a",
    "feedback": "README.md: document the config path."
  }
}
Return excerpt
{
  "task_id": "task-a",
  "round": 2,
  "status": "completed",
  "duration_seconds": 20.2,
  "usage": {"input_tokens": 2400, "output_tokens": 600},
  "rework_count": 1,
  "total_duration_seconds": 58.7,
  "total_usage": {"input_tokens": 6000, "output_tokens": 1500, "total_tokens": 7500},
  "git": {
    "branch": "codex/task-a",
    "diff_stat": "README.md | 3 +++"
  }
}

Cite the file and line, include failing output, and say what should happen.

codex_feedback

background: off

Record or update a user or reviewer’s rating, verdict, tags, or notes, or save the user’s verbatim first reply after a round. These reactions stay with the task and help you refine model and effort settings and improve the day-to-day workflow. Available to the model and Codex Monitor. Updates meta.json and syncs telemetry.jsonl, telemetry.csv, and report.md.

ParameterUse
task_idRequired task ID.
ratingOptional integer from 1 to 5.
verdictOptional. Choose accepted, rework, partial, rejected, abandoned.
tagsOptional array of strings.
notesOptional freeform review notes.
user_first_promptOptional verbatim first user reply after a round finishes.
roundOptional positive integer. Defaults to the current round.
Example call
{
  "name": "codex_feedback",
  "arguments": {
    "task_id": "task-a",
    "round": 2,
    "rating": 5,
    "verdict": "accepted",
    "tags": [
      "docs"
    ],
    "notes": "The config path is clear now.",
    "user_first_prompt": "Looks good, 5/5. The config path is clear now."
  }
}
Return excerpt
{
  "task_id": "task-a",
  "feedback": {
    "rating": 5,
    "verdict": "accepted",
    "tags": [
      "docs"
    ],
    "notes": "The config path is clear now.",
    "updated_at": "2026-11-27T08:22:09Z",
    "user_first_prompts": [
      {
        "round": 2,
        "prompt": "Looks good, 5/5. The config path is clear now.",
        "recorded_at": "2026-11-27T08:22:09Z"
      }
    ]
  },
  "rework_count": 1,
  "total_duration_seconds": 58.7,
  "total_usage": {
    "input_tokens": 6000,
    "output_tokens": 1500,
    "total_tokens": 7500
  }
}

Gemini automatically saves the first reply after presenting a round. Rate or annotate the task in Codex Monitor to add context for future dispatches.

codex_status

background: off

Inspect a single task or list recent tasks. Use on explicit request or during post-mortem debugging.

ParameterUse
task_idInspect one task, including recent events and stderr tail.
limitLimit the recent task list when task_id is omitted. Default: 20.
Example call
{
  "name": "codex_status",
  "arguments": {
    "task_id": "task-a"
  }
}
Return excerpt
{
  "task_id": "task-a",
  "status": "running",
  "alive": true,
  "round": 1,
  "last_event": "turn.started"
}

Take one snapshot. The completion result arrives on its own.

codex_cancel

background: off

Stop Codex and its child processes using a Windows Job Object or a macOS/Linux process group.

ParameterUse
task_idRequired ID of the running task.
Example call
{
  "name": "codex_cancel",
  "arguments": {
    "task_id": "task-b"
  }
}
Return excerpt
{
  "task_id": "task-b",
  "cancelled": true,
  "message": "Terminated running Codex process."
}

The process stops. Any changes it made stay in the checkout.

codex_cleanup_worktree

background: off

Remove a managed worktree after reviewing and merging its changes or deciding to discard them.

ParameterUse
task_idRequired ID of the task that owns the managed worktree.
delete_branchAlso remove the task’s branch. Default: false.
forceForce worktree removal and branch deletion if requested. Can discard work. Default: false.
Example call
{
  "name": "codex_cleanup_worktree",
  "arguments": {
    "task_id": "task-a",
    "delete_branch": true
  }
}
Return excerpt
{
  "task_id": "task-a",
  "cleaned": true,
  "branch_deleted": true
}

Merge accepted changes before removing the worktree.

codex_monitor

background: off

Open Codex Monitor in the Antigravity App side panel or full-page view, or read the structured snapshot. Tasks has a live section and collapsible By Project groups for settled tasks, newest first by finish time. Cards show effective model and effort pills and show concise failure reasons when available. The server stores extracted reasons in error_summary and surfaces them in latest_activity. Open the session detail sheet for configuration, runtime, prompt history, and activity, with expanded prompt and stream views. Cancel live tasks or enter a rating, verdict, and notes inline.

Analytics shows overall KPIs and a Model × Reasoning Effort matrix. Use outcomes and ratings from past dispatches to compare settings for real work and choose a configuration for the next task. The KPIs and matrix exclude failed tasks.

For each setting, the server checks the current rollout’s turn_context, an explicit dispatch or resume override, the previous round, project .codex/config.toml, then user ~/.codex/config.toml (or $CODEX_HOME/config.toml).

ParameterUse
task_idOptional ID of the task to select.
limitOptional cap on the number of tasks listed. Use a non-negative integer. Default is 20.
include_detailOptional boolean, default false. With task_id, true returns task_detail with prompt history and the activity stream across rounds, trimmed to fit the response size budget.
Example call
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "codex_monitor",
    "arguments": {"task_id": "task-a", "limit": 5, "include_detail": true}
  }
}
Return excerpt
{
  "structuredContent": {
    "active_count": 0,
    "selected_task": {
      "task_id": "task-a",
      "status": "completed",
      "effective_model": "gpt-6.2-sol",
      "effective_reasoning_effort": "high",
      "elapsed_seconds": 20.2,
      "latest_activity": {
        "kind": "report",
        "text": "Documented the CLI and config path."
      }
    },
    "task_detail": {
      "task_id": "task-a"
    },
    "analytics": {
      "overall": {
        "task_count": 1,
        "total_tokens": 7500
      },
      "by_model_effort": [
        {
          "model": "gpt-6.2-sol",
          "reasoning_effort": "high",
          "task_count": 1
        }
      ]
    },
    "telemetry_dir": "~/.gemini/codex-castor"
  }
}

Codex Monitor refreshes via tools/call every 1s when any task is active or the selected task is live, and every 8s when idle, at zero LLM tokens.

Folio V · Tabula IV

Worktrees & the runtime ledger

Each managed task runs in a Git checkout on its own branch. The ledger saves specs, feedback, events, stderr, and reports by round. Castor syncs dispatch history and user feedback across telemetry.jsonl, telemetry.csv, and report.md to guide future model and reasoning settings and improve the workflow with use.

Task records and managed Git worktrees The Castor state directory contains telemetry.jsonl, telemetry.csv, and report.md directly at its root. Under tasks, each task keeps its specs, metadata, events, logs, reports, and feedback. Under worktrees, each checkout uses a codex slash task ID branch. Castor state directory ~/.gemini/codex-castor/ telemetry.jsonl telemetry.csv report.md Task ledger Managed worktrees tasks/<task_id>/ spec.md / meta.json events-r1.jsonl report-r1.json worktrees/<task_id>/ codex/<task_id> base_ref · default HEAD Separate Git checkout
The root exports preserve how configurations performed alongside what users asked to change. Failed tasks remain in the records and are excluded from analytics aggregates. The task ledger also keeps stderr-r1.log and, after rework starts, feedback-r2.md and the second round’s files. Set CODEX_CASTOR_STATE_DIR to move the runtime root and CODEX_BIN to select the local Codex executable.

MCP Server & Schema

The server reads live model and effort from rollouts, records activity in meta.json, sends opt-in MCP progress and log notifications, and extracts concise failure summaries. The telemetry module locks updates and syncs JSONL, CSV, and Markdown exports. Failed tasks are excluded from aggregated statistics. The schema defines the six-field report. The MCP App at ui://codex-castor/monitor.html offers Tasks and Analytics views with inline feedback on task cards.

Orchestrator Skill

The architect’s procedure covers self-contained specs and independent review. Look up current models in ~/.codex/models_cache.json and route explicitly with model and reasoning_effort. Report telemetry at acceptance and record the first user reply to each presented round automatically.

Global Protocol & Config

Role division, MCP registration, and background settings for seven tools. Prefix the dispatch or resume toolSummary with [<model>·<effort>] and record the first user reply with codex_feedback.

Installer, Doctor & Tests

The installer and Doctor cover the telemetry module and analytics CLI, and Doctor verifies the MCP handshake. Use python3 scripts/analytics.py summary with --model, --effort, --project, or --since to filter the totals and recent tasks. Use backfill to rebuild the ledger, feedback to record evaluations or first replies, and export to write Markdown or CSV. Run the tests, follow terminal events with --follow, or see active tasks in the Antigravity CLI status bar.

Folio VI · Tabula V

Quickstart inscription

Requires Python 3.9+, Git, a configured local Codex CLI, and Antigravity. Run these commands from your terminal.

  1. Install Codex Castor

    Clone the repository and run the installer for your operating system. Add --install-statusline to show active tasks below Antigravity CLI’s built-in status bar. Reload Antigravity afterward.

    macOS and Linux

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

    Windows 11 x64 · PowerShell

    git clone https://github.com/JAY201368/codex-castor.git
    Set-Location codex-castor
    py -3 scripts/install.py
  2. Verify the installation

    From the clone, check the installed configuration and run an MCP stdio handshake. On Windows run py -3 scripts/doctor.py.

    python3 scripts/doctor.py
  3. Uninstall when needed

    Remove the installer-managed integration. On Windows run py -3 scripts/install.py --uninstall. Add --purge-state if you also want to remove saved Castor state.

    python3 scripts/install.py --uninstall