Unified CLI and MCP server for controlling Google Anti-Gravity IDE via CDP
Project description
agm — Anti-Gravity MCP CLI
A unified CLI and MCP server for controlling Google Anti-Gravity IDE programmatically via Chrome DevTools Protocol (CDP). Built for AI coding agents (Claude Code, Gemini CLI, Cursor) and terminal power users.
What It Does
agm lets you remotely control Anti-Gravity from the terminal or any MCP-compatible AI tool:
- Send prompts to Anti-Gravity's AI agent and get responses back
- Delegate tasks with full orchestration (connect, configure model/mode, send, monitor, return)
- Switch models dynamically (Gemini, Claude, GPT — whatever AG offers)
- Handle approvals — approve, deny, or auto-accept file edits and terminal commands
- Monitor quota — per-model usage bars, refresh timers, and low-quota warnings
- Switch modes between Fast and Planning
- Take screenshots of the Anti-Gravity window
- Health checks — verify CDP connectivity, DOM selectors, and chat input reachability
All exposed as both CLI commands and MCP tools.
Installation
# With uv (recommended)
uv tool install antigravity-mcp-cli
# With pip
pip install antigravity-mcp-cli
# From source
git clone https://github.com/jacob-bd/antigravity-mcp-cli.git
cd antigravity-mcp-cli
uv venv && uv pip install -e ".[dev]"
Quick Start
# 1. Launch Anti-Gravity with CDP enabled and connect
agm connect
# 2. Verify everything is working
agm doctor
# 3. Send a prompt
agm send "explain the authentication flow in this codebase"
# 4. Full task delegation (connects, sends, monitors, returns)
agm delegate "fix the login bug in auth.py" --project ~/myapp
CLI Reference
agm — Anti-Gravity MCP CLI
Connection:
agm connect [-p PATH] [--port N] Connect to workspace (auto-launches AG with CDP)
agm disconnect Disconnect from CDP
agm status Show connection status
agm doctor Health check (8 checks: Python, config, process, CDP, targets, WebSocket, DOM)
Prompts:
agm send PROMPT [--timeout N] Send prompt, display response
agm delegate TASK [-p PATH] Full delegation (connect + model + mode + send + monitor)
[--model NAME] Model override (fuzzy match: "claude", "gemini 3.1")
[--mode fast|planning] Mode override
[--auto-approve] Auto-approve actions (blacklist enforced)
[--timeout N] Timeout in seconds
Models:
agm model Show current model
agm model list List all available models + quota warnings
agm model set NAME Switch model (fuzzy match supported)
agm model quota Per-model quota dashboard (usage bars, status, refresh timers)
Mode:
agm mode Show current mode (fast / planning)
agm mode [fast|planning] Switch execution mode
Approvals:
agm approve Approve pending action
agm deny Deny pending action
agm auto-accept [true|false] Toggle auto-accept (safety blacklist always enforced)
Other:
agm screenshot [-o FILE] Capture AG screen as PNG
agm serve [--slim|--monitor] Start MCP server
agm --version Show version
agm --json COMMAND JSON output for scripting
MCP Server Integration
Claude Code
Add to your Claude Code MCP settings:
{
"mcpServers": {
"agm": {
"command": "agm-mcp"
}
}
}
Gemini CLI
Add to your Gemini CLI settings:
{
"mcpServers": {
"agm": {
"command": "agm-mcp"
}
}
}
Server Modes
agm serve # Full mode — 17 tools
agm serve --slim # Slim mode — 4 tools (connect, delegate, status, auto-accept)
agm serve --monitor # Monitor mode — 8 tools (read + approve, no injection)
agm serve --transport sse --port 8765 # HTTP SSE transport
MCP Tools (17 total)
| Tool | Description |
|---|---|
agm_connect |
Connect to Anti-Gravity workspace via CDP |
agm_disconnect |
Disconnect from CDP |
agm_status |
Connection status, model, mode, pending approvals |
agm_send_prompt |
Send prompt, optionally wait for response |
agm_delegate_task |
Full delegation: connect + configure + send + monitor + return |
agm_stop |
Interrupt active generation |
agm_screenshot |
Capture screen as PNG |
agm_list_approvals |
Check for pending approval requests |
agm_approve |
Click Allow |
agm_deny |
Click Deny |
agm_always_allow |
Allow This Conversation |
agm_auto_accept |
Toggle auto-accept (safety blacklist enforced) |
agm_list_models |
List available models (dynamic discovery) |
agm_switch_model |
Switch model (fuzzy match) |
agm_get_mode |
Get current mode |
agm_set_mode |
Switch between fast/planning |
agm_server_info |
Server version and capabilities |
Architecture
4-layer async-first design:
┌──────────────────────────────────────────────┐
│ CLI Layer (agm) — Typer + Rich │
│ Terminal commands, Rich formatting │
├──────────────────────────────────────────────┤
│ MCP Layer (agm-mcp) — FastMCP │
│ 17 tools for AI agent integration │
├──────────────────────────────────────────────┤
│ Services Layer — Business logic │
│ Connection, Prompt, Delegation, Approval │
├──────────────────────────────────────────────┤
│ Core Layer — CDP engine │
│ WebSocket, DOM selectors, monitors │
└──────────────────────────────────────────────┘
│
▼
Anti-Gravity IDE (Electron/Chromium via CDP)
Key principle: CLI and MCP tools are thin wrappers that call Services, which call Core. Core has zero knowledge of presentation layers.
CDP Port Strategy
Anti-Gravity uses a dedicated port range (9500-9510) to avoid conflicts with other tools that use CDP for authentication (e.g., notebooklm-mcp-cli, gemini-web-mcp-cli use ports 9222-9231 for Chrome auth).
When agm connect launches Anti-Gravity, it automatically selects a free port from 9500-9510. When scanning for an already-running AG instance, it checks both the dedicated range and legacy ports (9222-9225, 9333).
Safety
- Auto-accept blacklist: Even with auto-accept enabled, dangerous commands are always blocked:
rm -rf,git push --force,npm publish,git reset --hard,git clean -f,DROP TABLE, etc. - Auto-accept resets on restart: Auto-accept mode is never persisted — it must be explicitly enabled each session.
- CDP binds to localhost only: The CDP port (9500) is only accessible from 127.0.0.1.
Development
# Install dev dependencies
uv venv && uv pip install -e ".[dev]"
# Run tests
uv run pytest tests/ -v
# Lint
uv run ruff check src/ tests/
# Type check
uv run mypy src/
# Reinstall after changes
uv cache clean && uv tool install --force .
Disclaimer
This project is an independent, community-built tool created for educational and personal productivity purposes. It is not affiliated with, endorsed by, or associated with Google LLC or any of its products or services. "Anti-Gravity" and "Google" are trademarks of Google LLC.
This tool interacts with Anti-Gravity IDE solely through the publicly available Chrome DevTools Protocol (CDP), which is a standard debugging interface built into all Chromium-based applications. No proprietary APIs are reverse-engineered, no authentication is bypassed, and no terms of service are violated.
Use at your own discretion. The author assumes no responsibility for how this tool is used.
Acknowledgments & References
This project was built by studying and drawing inspiration from several open-source projects. Credit and thanks to their authors:
CDP Engine & DOM Interaction
-
optimistengineer/remoat — Primary CDP reference. The response monitoring system (COMBINED_POLL pattern, stop-button-gone completion detection, scored selector fallback chains, activity log filtering, quota error detection) was ported from remoat's
responseMonitor.ts. The message injection sequence (focus → clear → insertText → enter), approval detection script, and cross-platform keyboard modifier handling also draw from remoat's implementation. A well-engineered project that proved CDP-based AG control is production-viable. -
tokyoweb3/LazyGravity — Multi-workspace connection pool architecture,
callWithRetryreconnection pattern, and workspace discovery probing (title match → CDP probe → folder path → URL param match) were informed by LazyGravity's approach. Shares a common ancestor with remoat.
Approval & Auto-Accept
- yazanbaker94/AntiGravity-AutoAccept — The MutationObserver approach to approval detection (instant reaction vs polling), session heartbeat for observer health validation, and the configurable command blacklist concept for safe auto-accept were all informed by this project.
MCP Architecture
-
jbendavi/notebooklm-mcp-cli — The architectural template for this project. The 4-layer design (Core → Services → MCP → CLI), FastMCP server setup with tool registry pattern, Typer CLI with Rich formatting, Pydantic data types,
pyproject.tomlwith Hatchling,uvpackage management, and thedoctorhealth check command pattern were all mirrored from notebooklm-mcp-cli. -
ChromeDevTools/chrome-devtools-mcp — Google's official CDP-over-MCP server informed the MCP tool design patterns: tool categorization, parameter validation, unified error/response format, and the "slim mode" concept for exposing a minimal tool subset.
Other References
-
su-kaka/gcli2api — Credential rotation and model mapping patterns studied for potential future API gateway features. Note: anti-commercial license — no code was copied.
-
AvenalJ/AntigravityMobile — Model quota monitoring via DOM scraping patterns were studied for the quota dashboard implementation.
License
MIT — see LICENSE
Author
Jacob Ben-David
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 antigravity_mcp_cli-0.2.0.tar.gz.
File metadata
- Download URL: antigravity_mcp_cli-0.2.0.tar.gz
- Upload date:
- Size: 206.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e334d479e0ab9b718517a4cec26f71cd5d1bff29d771874c9cbe94f3bbf8448
|
|
| MD5 |
956c7b2fbcbab182f3931f1e472da61a
|
|
| BLAKE2b-256 |
0585bdabb5c40dc5fac67acaddf6dc4f9136a1fb588e1336a226e9b775b24fd7
|
Provenance
The following attestation bundles were made for antigravity_mcp_cli-0.2.0.tar.gz:
Publisher:
publish.yml on jacob-bd/the-antigravity-mcp-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
antigravity_mcp_cli-0.2.0.tar.gz -
Subject digest:
6e334d479e0ab9b718517a4cec26f71cd5d1bff29d771874c9cbe94f3bbf8448 - Sigstore transparency entry: 1191404035
- Sigstore integration time:
-
Permalink:
jacob-bd/the-antigravity-mcp-cli@3de7172f7505a8b7c07dcf11f17de02356e8474d -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/jacob-bd
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3de7172f7505a8b7c07dcf11f17de02356e8474d -
Trigger Event:
push
-
Statement type:
File details
Details for the file antigravity_mcp_cli-0.2.0-py3-none-any.whl.
File metadata
- Download URL: antigravity_mcp_cli-0.2.0-py3-none-any.whl
- Upload date:
- Size: 102.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f367e26ca21f1d304fabcdb881163ee33353cfed9afdb37fb29aedeefd2a00f8
|
|
| MD5 |
4b4eedbb79e3cdd054cba4ac96cd2bca
|
|
| BLAKE2b-256 |
cc3781289576d1b8cb4aaf8e2af6e45b190b9956e3e18b41ea313593e1026353
|
Provenance
The following attestation bundles were made for antigravity_mcp_cli-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on jacob-bd/the-antigravity-mcp-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
antigravity_mcp_cli-0.2.0-py3-none-any.whl -
Subject digest:
f367e26ca21f1d304fabcdb881163ee33353cfed9afdb37fb29aedeefd2a00f8 - Sigstore transparency entry: 1191404037
- Sigstore integration time:
-
Permalink:
jacob-bd/the-antigravity-mcp-cli@3de7172f7505a8b7c07dcf11f17de02356e8474d -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/jacob-bd
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3de7172f7505a8b7c07dcf11f17de02356e8474d -
Trigger Event:
push
-
Statement type: