Observable, resumable MCP bridge from Codex to Antigravity CLI
Project description
codex-agy-bridge
An observable, resumable MCP bridge that lets Codex delegate work to the
official Antigravity CLI (agy) using the user's existing Antigravity login.
agy --print is a blocking command. Agent work can outlive an MCP tool timeout,
and its useful progress normally exists only in local Antigravity trajectory
files. This bridge starts a detached worker, returns a durable run_id
immediately, and exposes status, transcript, result, cancellation, continuation,
and bounded parallel-goal tools over MCP.
Status
This project is experimental. It currently targets:
- Codex CLI/app with local stdio MCP servers;
- Antigravity CLI 1.0.8-compatible commands and trajectory files;
- Python 3.11 or newer;
- macOS plus
tmuxfor persistent Terminal.app sessions.
Every run executes in a persistent tmux session. Terminal.app can be attached
on demand without stopping the run when the window closes. Antigravity's local
storage format is not a stable public API, so compatibility may require updates
when the CLI changes.
Features
- Starts long-running Antigravity work asynchronously.
- Persists run state and logs across MCP server restarts.
- Returns bounded, sanitized transcript events without private model reasoning.
- Opens each run in a persistent
tmuxsession. - Continues an exact Antigravity
conversation_id. - Cancels active process groups.
- Groups named targets with bounded parallelism.
- Deduplicates identical active start requests.
- Keeps separate client-owned MCP server processes from terminating each other.
- Detects authentication, rate-limit, quota, and response-timeout conditions.
- Forwards CLI
--sandboxand up to 16--add-dirpolicy hints without claiming filesystem containment. - Discovers models, plugins, capabilities, changelog, and bridge diagnostics.
- Starts experimental persistent
--prompt-interactivesessions for occasional conversational input.
Install
Prerequisites
Install:
- Codex
- The official Antigravity CLI (
agy), authenticated locally - uv
tmuxfor persistent terminal sessions:
brew install tmux
Confirm the required commands:
codex --version
agy --version
uv --version
tmux -V
Install in Codex from PyPI
After the first PyPI release, install the bridge without cloning this repository:
codex mcp add codex-agy-bridge \
--env AGY_CMD="$(command -v agy)" \
-- "$(command -v uvx)" codex-agy-bridge@latest
Restart Codex, then verify:
codex mcp get codex-agy-bridge
codex mcp list
codex mcp add stores an stdio MCP server definition. When Codex starts the
server, it launches the absolute uvx executable recorded by the command.
uvx resolves codex-agy-bridge@latest from PyPI, creates an isolated cached
environment, installs the package and its dependencies, then runs the
codex-agy-bridge console script. AGY_CMD pins the bridge to the user's
already-installed and authenticated agy executable.
Ask a Codex agent to install it
Paste this prompt into Codex:
Install codex-agy-bridge as a user-level stdio MCP server on this Mac.
First verify that codex, agy, uvx, and tmux are installed, and that agy is
authenticated. Do not install missing prerequisites without asking me.
Then run:
codex mcp add codex-agy-bridge \
--env AGY_CMD="$(command -v agy)" \
-- "$(command -v uvx)" codex-agy-bridge@latest
Verify the saved configuration with `codex mcp get codex-agy-bridge` and
`codex mcp list`. Tell me to restart Codex so the new MCP tools are loaded.
The README is the best place for this prompt because it is visible before the
repository is cloned. AGENTS.md is intended for contributors working inside
the checkout and should not cause an agent to modify a user's machine merely
because it read the repository instructions.
Install from GitHub before a PyPI release
This works before a PyPI release:
codex mcp add codex-agy-bridge \
--env AGY_CMD="$(command -v agy)" \
-- uvx --from git+https://github.com/varadfromeast/codex-agy-bridge \
codex-agy-bridge
Restart Codex, then verify:
codex mcp get codex-agy-bridge
codex mcp list
Remove it with:
codex mcp remove codex-agy-bridge
Install from a local clone
Use this when developing the bridge:
git clone https://github.com/varadfromeast/codex-agy-bridge.git
cd codex-agy-bridge
uv sync --extra dev
codex mcp add codex-agy-bridge \
--env AGY_CMD="$(command -v agy)" \
-- uv --directory "$PWD" run codex-agy-bridge
Configuration
The local-clone codex mcp add command writes the equivalent of:
[mcp_servers.codex-agy-bridge]
command = "/absolute/path/to/uv"
args = [
"--directory",
"/absolute/path/to/codex-agy-bridge",
"run",
"codex-agy-bridge",
]
startup_timeout_sec = 30
tool_timeout_sec = 30
[mcp_servers.codex-agy-bridge.env]
AGY_CMD = "/absolute/path/to/agy"
Useful environment variables:
| Variable | Default | Purpose |
|---|---|---|
AGY_CMD |
agy on PATH |
Exact Antigravity executable |
AGY_BRIDGE_STATE_DIR |
~/.local/state/codex-agy-bridge |
Durable run and goal state |
AGY_BRIDGE_AGY_ROOT |
~/.gemini/antigravity-cli |
Antigravity conversations and trajectories |
AGY_BRIDGE_MAX_PARALLEL |
4 |
Global concurrent-run limit |
AGY_BRIDGE_COMPLETION_STABILITY_SECONDS |
150 |
Time a final marker must remain stable |
MCP Tools
| Tool | Purpose |
|---|---|
agy_start |
Start a new asynchronous conversation and return a run_id |
agy_interactive_start |
Start an experimental transcript-gated interactive session |
agy_continue |
Continue an exact conversation_id |
agy_status |
Read compact status or diagnostic paths |
agy_transcript |
Read bounded progress events |
agy_result |
Read the final semantic response |
agy_cancel |
Cancel an active run |
agy_models |
List models available to the installed CLI |
agy_doctor |
Report bounded bridge, CLI, tmux, storage, and run diagnostics |
agy_plugins |
List imported plugins without mutating configuration |
agy_plugin_validate |
Validate a plugin directory contained by a workspace |
agy_changelog |
Read the installed CLI changelog |
agy_goal_create |
Create a bridge-owned MCP scheduling container |
agy_goal_target_start |
Start one independent scheduler target |
agy_goal_status |
Aggregate bridge scheduler target status |
agy_target_open_terminal |
Reattach Terminal.app to an existing run |
agy_target_send_text |
Queue or send input to an interactive Run only |
Typical call flow:
agy_start
-> run_id
-> agy_status / agy_transcript
-> agy_result
Use agy_continue only with the exact conversation_id returned by a previous
run. Every start and continuation also requires an absolute workspace path.
How It Works
See docs/ARCHITECTURE.md for the detailed process topology, lifecycle diagrams, and module responsibilities.
Codex
|
| MCP over stdio
v
server.py
|
v
orchestration.py -- persists state --> core.py / state.py
|
| starts detached Python worker
v
runner.py --> supervision.py -- launches --> agy print/interactive
| |
| v
| Antigravity trajectory
| |
+------ reads progress ---+
|
+-- persistent session --> terminal.py --> tmux --> Terminal.app
server.pyexposes stable MCP tools and delegates behavior.orchestration.pyvalidates requests, enforces parallel limits, deduplicates active retries, persists initial state, and starts a detached runner.cli.pyowns executable discovery, capability probing, read-only commands, and run command construction.runner.pyprovides the detached worker entrypoint and process adapters.supervision.pylaunches print or interactive mode and discovers the conversation, streams sanitized progress, observes completion, and records terminal state.core.pyatomically persists JSON and reads Antigravity trajectory JSONL.terminal.pyowns persistenttmuxexecution and Terminal.app interaction.
Each prompt receives a unique completion marker. A response is considered complete only after that marker remains the latest response for a stability window. The marker is removed before results are returned.
Core Files
Read these in this order to understand the product:
src/codex_agy_bridge/server.py- The public MCP contract.
- Start here to see every tool and its arguments.
src/codex_agy_bridge/orchestration.py- The product's control plane.
- Owns goals, concurrency, cancellation, durable reservation, and detached-run startup.
src/codex_agy_bridge/run_request.py- The Run Request module.
- Owns request validation, workspace normalization, execution-policy capability checks, deduplication identity, and initial persisted state.
src/codex_agy_bridge/runner.py- The detached-worker entrypoint and process adapter.
- Owns command construction, tmux launch, and process shutdown.
src/codex_agy_bridge/supervision.py- The lifecycle supervision module for one run.
- Owns conversation discovery, incremental transcript polling, progress monitoring, completion detection, timeouts, and cancellation.
src/codex_agy_bridge/transcript.py- Provides one supervisor-owned
TranscriptHarvesterper conversation. - Retains only file identity, byte offset, a partial record, the latest step, and the latest completed response.
- Provides one supervisor-owned
src/codex_agy_bridge/core.py- The persistence and Antigravity compatibility layer.
- Owns state paths, atomic writes, stateless transcript reads, response extraction, and bounded per-run failure classification.
src/codex_agy_bridge/state.py- The persisted data contracts and run-state machine.
src/codex_agy_bridge/terminal.py- The macOS terminal adapter built on
tmuxand AppleScript.
- The macOS terminal adapter built on
src/codex_agy_bridge/lifecycle.py
- Registration and stale cleanup for client-owned MCP server processes.
Public transcript requests remain stateless full reads. Provider classification only inspects bounded logs after a run exits without a response; it is never a launch preflight or persisted health gate.
The most useful tests for learning behavior are:
tests/test_mcp_stdio.py: real MCP initialization and tool discovery.tests/test_detached_run.py: end-to-end detached run with a fakeagy.tests/test_orchestration.py: start deduplication and tmux session creation.tests/test_runner.py: command construction, completion, and progress output.tests/test_core.py: transcript parsing and provider-health behavior.tests/test_terminal.py:tmuxand Terminal.app command construction.
State and Observability
Run state survives MCP server restarts under:
~/.local/state/codex-agy-bridge/
runs/<run-id>/
state.json
bridge.log
agy.log
agy.stdout.log
agy.stderr.log
terminal-progress.log
goals/<goal-id>/
state.json
servers/
<pid>.json
agy_status(compact=false) returns these diagnostic paths.
agy_transcript returns bounded events by default; full event content is
opt-in and length-capped. Private model reasoning fields are never exposed.
Execution Risk
Antigravity is an agentic CLI. It can read and write files, execute commands, and access the network with the current user's privileges. This bridge is not a sandbox or security boundary.
dangerously_skip_permissions defaults to true for print-mode tools. Set it
to false when unattended execution is not appropriate. sandbox=true and
additional_directories are CLI policy hints forwarded as --sandbox and
--add-dir; live testing with Antigravity CLI 1.0.8 showed that they do not
enforce filesystem containment. A workspace scopes conversation context only.
Interactive Runs are experimental and should be used sparingly. The bridge
queues submitted prompts and releases one after observing a completed planner
response in Antigravity's transcript. If those private transcript event
semantics change, delivery may stall. agy_status exposes the queue depth and
delivery state.
Goals are an MCP scheduler implemented by this bridge. They are not an Antigravity feature, and separate targets do not share native conversation context.
The bridge does not read or copy Antigravity OAuth credentials. It invokes the
installed agy binary and reads ordinary local conversation metadata and
trajectory files.
Model-provider calls may cost money. MCP clients should ask for user approval before starting or continuing a run when cost consent has not already been given.
Development
git clone https://github.com/varadfromeast/codex-agy-bridge.git
cd codex-agy-bridge
uv sync --extra dev
uv run pytest
uv run ruff check .
uv build
Run the server directly:
uv run codex-agy-bridge
The server uses stdio transport. Do not print diagnostic text to stdout; it would corrupt MCP framing.
Publishing
The official MCP Registry stores metadata, not package artifacts. A pushed
version tag runs .github/workflows/publish.yml, which:
- Verifies that the tag, Python package, and Registry metadata versions match.
- Runs lint, tests, build, and distribution checks.
- Publishes the wheel and source distribution to PyPI through GitHub OIDC.
- Creates a GitHub release containing both distributions.
- Waits for the package to become visible on PyPI.
- Publishes
server.jsonto the MCP Registry through GitHub OIDC.
Before pushing the first tag, create a pending PyPI Trusted Publisher for:
- Repository:
varadfromeast/codex-agy-bridge - Workflow:
publish.yml - Environment:
pypi
No long-lived PyPI or MCP Registry publishing token is required.
The registry is currently in preview. See:
Compatibility
The compatibility boundary is isolated in core.py. The current reader expects
Antigravity trajectory JSONL under:
~/.gemini/antigravity-cli/brain/<conversation-id>/
.system_generated/logs/transcript.jsonl
If Antigravity completes its migration to SQLite or a local daemon API, a new adapter can replace this reader without changing the MCP tool contract.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file codex_agy_bridge-0.1.2.tar.gz.
File metadata
- Download URL: codex_agy_bridge-0.1.2.tar.gz
- Upload date:
- Size: 37.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8434b5d79c03c6f66466d9a83b62248be3ea3aa5d02a9bdc0696d5e1268ca65b
|
|
| MD5 |
4a9a24a3c8be5ba6ff20da9b4a002cd9
|
|
| BLAKE2b-256 |
e6fdfbaba5f1938b5d4f62a2833fc5a5388a57ea4c83d92bb38da806f177a1d5
|
Provenance
The following attestation bundles were made for codex_agy_bridge-0.1.2.tar.gz:
Publisher:
publish.yml on varadfromeast/codex-agy-bridge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codex_agy_bridge-0.1.2.tar.gz -
Subject digest:
8434b5d79c03c6f66466d9a83b62248be3ea3aa5d02a9bdc0696d5e1268ca65b - Sigstore transparency entry: 1826364190
- Sigstore integration time:
-
Permalink:
varadfromeast/codex-agy-bridge@f477a335c8dbffe80eaed30f51601b0e0ce10389 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/varadfromeast
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f477a335c8dbffe80eaed30f51601b0e0ce10389 -
Trigger Event:
push
-
Statement type:
File details
Details for the file codex_agy_bridge-0.1.2-py3-none-any.whl.
File metadata
- Download URL: codex_agy_bridge-0.1.2-py3-none-any.whl
- Upload date:
- Size: 49.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8c002ca2feb2a5acf72ab87b1ee2ef5e03c94ebe14154ce6cb09c21c7e11c59
|
|
| MD5 |
507c6ff07f7b39750342510d84d426af
|
|
| BLAKE2b-256 |
d4a07daced5834a78eb4a54aebe626e954832d138dfeb14130a90cd20aa49ce8
|
Provenance
The following attestation bundles were made for codex_agy_bridge-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on varadfromeast/codex-agy-bridge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codex_agy_bridge-0.1.2-py3-none-any.whl -
Subject digest:
a8c002ca2feb2a5acf72ab87b1ee2ef5e03c94ebe14154ce6cb09c21c7e11c59 - Sigstore transparency entry: 1826364249
- Sigstore integration time:
-
Permalink:
varadfromeast/codex-agy-bridge@f477a335c8dbffe80eaed30f51601b0e0ce10389 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/varadfromeast
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f477a335c8dbffe80eaed30f51601b0e0ce10389 -
Trigger Event:
push
-
Statement type: