Antigravity CLI
Install context-mode in Antigravity CLI (agy) with one plugin command — it registers the MCP server, a routing rule, a routing skill, and bounded JSON hooks.
Antigravity CLI (agy) is the command-line companion to Google Antigravity, a
Gemini-based agent. Unlike the Antigravity IDE, agy has a native plugin system
(agy plugin install) and a hook surface, so context-mode ships as a first-class
agy plugin. A single command registers the MCP server, a routing rule, a routing
skill, and bounded PreToolUse/PostToolUse/Stop hooks that steer data-heavy
tool output into the sandbox — the model writes a program that processes the data
and prints only the answer.
context-mode runs 100% locally with zero telemetry. Indexing and execution never leave your machine.
Install
The plugin install is a single agy command, but the plugin's MCP server and
hooks run the global context-mode binary, so npm install -g context-mode is a
prerequisite.
The GitHub-subpath install requires agy 1.0.7 or newer (subpath and branch
resolution landed in 1.0.7). Run agy update if you are on an older build.
Verified on agy 1.0.10.
Install the package
Install context-mode globally. The plugin's MCP server launches this binary, and the hooks dispatch through it.
npm install -g context-modeInstall the plugin
Run the plugin install. agy clones the repo, resolves the
configs/antigravity-cli subpath, and registers the bundle's native MCP server,
routing rule, routing skill, and hooks into its plugin profile under
~/.gemini/config/plugins/context-mode/.
agy plugin install https://github.com/mksglu/context-mode/tree/main/configs/antigravity-cliThe install wires three bounded hooks — PreToolUse, PostToolUse, and Stop —
each dispatching through the context-mode binary with a lowercase event token:
context-mode hook antigravity-cli pretooluse
context-mode hook antigravity-cli posttooluse
context-mode hook antigravity-cli stopTo remove the plugin later, run agy plugin uninstall context-mode.
Hook scope
context-mode wires only the surfaces that have a verified mapping on agy:
| Hook | Mode | What it does |
|---|---|---|
PreToolUse | Bounded blocking | Routing enforcement on the mapped high-flood tools — run_command, view_file, grep_search, web_fetch, read_url_content. Other tools are not PreToolUse-routed. |
PostToolUse | Capture-only | Records executed tool calls into the session database. agy's PostToolUse payload carries no tool-output text, so byte accounting for output is unavailable on this surface, but the tool call, project, and error state are still captured. |
Stop | Capture-only, best-effort | Session-end marker. It is registered, but agy did not emit it through agy 1.0.10 probes, so treat it as best-effort. |
PreCompact, SessionStart, PreInvocation, and PostInvocation are not
wired. context-mode cannot modify args or output, or inject session context, on
this host — PreToolUse enforcement is bounded blocking only.
Where agy reads its config
agy shares the ~/.gemini/ session root with the rest of the Gemini family;
the session database is keyed by project hash to prevent collisions. The relevant
paths:
| Surface | Path |
|---|---|
| Global MCP profile | ~/.gemini/config/mcp_config.json (not the Antigravity IDE's ~/.gemini/antigravity/mcp_config.json) |
| Global hooks | ~/.gemini/config/hooks.json |
| Plugin profile (what the install writes) | ~/.gemini/config/plugins/context-mode/ |
The plugin install registers everything under its plugin profile rather than the global MCP and hooks files.
Alternative (MCP only, no plugin)
If you cannot use the plugin install, register the MCP server manually by adding
context-mode to ~/.gemini/config/mcp_config.json under mcpServers. This path
ships no hooks, so routing enforcement is advisory only.
{
"mcpServers": {
"context-mode": {
"command": "context-mode",
"env": {
"CONTEXT_MODE_PLATFORM": "antigravity-cli"
}
}
}
}agy is also detected automatically through the MCP handshake (clientInfo.name
of agy / antigravity-cli) and config-dir markers, so the
CONTEXT_MODE_PLATFORM env above is a belt-and-suspenders override rather than a
strict requirement — it pins detection when another host like Claude Code is
co-installed.
Verify your savings
Confirm context-mode is actually saving you tokens, not just that the tools respond.
- In an agy session, type
ctx statsin chat to see the tokens saved and the savings ratio for the session — or run any prompt and re-check after a few data-heavy operations. - Run
context-mode doctorto confirm the hooks and MCP server are registered.
context-mode doctorcontext-mode doctor checks:
- Language runtimes
- The FTS5 knowledge base
- MCP registration
- The
PreToolUse/PostToolUse(best-effortStop) hooks, across both the plugin profile (~/.gemini/config/plugins/context-mode/) and the global manual profile
When degraded, it prints agy plugin install ... or context-mode upgrade as
the repair fix. A clean run means the MCP server is reachable and the hooks are
wired.
The MCP-registration check is specific to the CLI context-mode doctor binary.
The in-session MCP doctor (ctx doctor in chat, backed by the ctx_doctor
tool) validates only the hooks — it does not emit an MCP-registration line — so
run the CLI context-mode doctor when you want the registration check.
agy caches each server's tool schemas under
~/.gemini/antigravity-cli/mcp/context-mode/ and does not refresh them on
reconnect. If the ctx_* tools do not appear after an upgrade, delete that
cache directory and restart agy to force a re-fetch.
Related
Antigravity
Install context-mode in the Antigravity IDE as an MCP-only host: register the context-mode MCP server and copy a GEMINI.md routing file that steers data-heavy output into the sandbox.
Kiro
Install context-mode in Kiro, AWS's agentic IDE, with an MCP server plus native preToolUse, postToolUse, agentSpawn, and userPromptSubmit hooks that reroute data-heavy tool output into the sandbox.