Skip to content

Connecting CodeNavi to Google Antigravity CLI (agy)

Antigravity CLI (agy, Google's evolution of Gemini CLI) talks to CodeNavi over MCP. The integration ships as a bundle, plugins/antigravity/ (included in every air-gapped package, MIT-licensed). It has three parts:

  1. The MCP server → ~/.gemini/config/mcp_config.json, one file shared by the agy CLI, the Antigravity IDE and the 2.0 desktop app, so wiring it once connects all three. This is what gives Antigravity CodeNavi's tools: semantic search, the call graph, the overview and the index tools by default, with the rest (grep, file reading, wiki, notes, crawler, backup) run on demand via reveal_tools().
  2. The codenavi agy plugin (agy 1.3.2 or newer) → ~/.gemini/config/plugins/codenavi/: the using-codenavi skill, so it prefers semantic search over grep; thirteen /codenavi: commands (search, status, review, compliance, doctor, feedback, …); and two hooks, one tells the agent at session start that the index is up (or that the licence has run out and the tools refuse, with the way back), the other, when you turn it on, answers a grep of an indexed tree from the index (CODENAVI_HOOK_GREP=hint; CODENAVI_HOOK_GREP=block in agy's environment denies that grep instead, Plugins → Grep hook). Older agy builds get only the skill, in ~/.gemini/skills/.
  3. The statusline → see Statusline below.

Antigravity ≠ Claude Code ≠ Codex. All three agents read different files, use different field names, and treat the bearer token differently. A config copied from one will silently fail in the others. Wire each one explicitly.

Cloud agent: data leaves your machine. agy runs the model in Google's cloud, so anything CodeNavi returns to it gets sent to Google. Scope to codebases you're comfortable sharing; see docs/connecting-antigravity-windows.md for a full privacy/scoping walkthrough that applies on Linux/Mac too.

Fast path

cd plugins/antigravity
./connect-codenavi.sh --env-file ../../.env

Antigravity on a different machine than the server? The server hands the bundle out itself, no token needed for /plugins/*:

git clone http://<server-ip>:8765/plugins/antigravity.git && cd antigravity
export CODENAVI_AUTH_TOKEN=<token>
./connect-codenavi.sh --host <server-ip> --port 8765

No git on the client? curl -O http://<server-ip>:8765/plugins/antigravity.zip unpacks to codenavi-plugin-antigravity/.

connect-codenavi.sh is idempotent: it backs up mcp_config.json, merges the [mcpServers.codenavi] block while preserving any other servers, installs the plugin with agy plugin install (agy cannot add a custom plugin marketplace, so it does not update the way Claude Code and Codex do: after a server update, fetch the bundle again, git pull, or the .zip, and re-run the script), installs the statusline (see Statusline below), and verifies an authenticated tools/list against the exact URL before declaring success. Then restart agy:

# Restart agy, then in the TUI run /mcp — 'codenavi' should be listed.
# Headless check:  agy -p "list codebases with the codenavi list_codebases tool"

Manual mcp_config.json

If you'd rather not run the script, paste the snippet from plugins/antigravity/mcp/mcp_config.json.snippet into ~/.gemini/config/mcp_config.json. The minimal block:

{
  "mcpServers": {
    "codenavi": {
      "serverUrl": "http://localhost:8765/mcp",
      "headers": {
        "Authorization": "Bearer <PASTE_TOKEN_HERE>"
      }
    }
  }
}

The three things that bite people

  1. Antigravity uses serverUrl: NOT Claude Code's {"type":"http","url":...} and NOT Codex's bearer_token_env_var. A config copied from another agent silently won't connect, the field name is wrong, codenavi gets dropped, and agy falls back to curling the endpoint with no schemas (which masks the failure since the data still comes back).
  2. The token must be the LITERAL value. Antigravity CLI 1.0.8 does not expand ${VAR} in MCP headers, with the env-var form, codenavi silently 401s and is dropped. connect-codenavi.sh bakes the real token from your .env into a 0600 file by default. --env-token opts into the unsupported ${VAR} form for a future Antigravity that adds expansion. This is the opposite of Codex, which needs the env-var NAME and rejects a literal.
  3. Use the unscoped /mcp path unless you know the codebase name. /mcp/<name> returns Unknown codebase '<name>' (404) unless <name> is configured, a single-codebase install is usually named default. Check with list_codebases. Connecting a cloud agent to a multi-codebase server? Then scope it on purpose (--codebase NAME), see Privacy first. For scoped wiring, pass --codebase NAME to connect-codenavi.sh.

Headless agy --print and the workspace-CLAUDE.md derail

agy --print "<prompt>" is the headless mode (good for scripts, CI, demos). Two caveats from real runs:

  • agy --print reads any CLAUDE.md / GEMINI.md / AGENTS.md in the workspace before doing anything. If that file defines a custom CLI or PreToolUse hook (e.g. the cpx CLI in some shops), agy goes shell-first and may never reach the codenavi MCP tools, even when the prompt explicitly says "use the codenavi MCP tools only" and the using-codenavi skill is loaded. For headless structural demos, run from a directory without a workspace CLAUDE.md, or remove the shell-tool guidance from it.
  • Flag echoes leak into the prompt. Long flags like --print-timeout=9m can bleed into the model's context and turn into a search target. Keep flags strictly before the prompt string and avoid mentioning flag names in the prompt itself.

The TUI doesn't have either failure mode, the workspace file is loaded as documentation rather than tool-policy, and there are no --print flags to echo.

Verifying connection

agy inspect / agy mcp are TUI-only (they need a real TTY, so they fail over SSH without a PTY). To verify headlessly:

agy -p "list codebases with the codenavi list_codebases tool"
# If 'codenavi' is wired, agy reads the tool schema and calls it directly.
# If not, it usually falls back to `curl http://localhost:8765/mcp` — that response
# looks similar but means the integration is broken (no tool schemas, no other tools).

You can also check the cli log at ~/.gemini/antigravity-cli/log/cli-*.log for mcp__codenavi__* entries.

Statusline

connect-codenavi.sh also installs a statusline into the agy CLI, a prompt badge showing the current repo's index coverage (✦) and whether CodeNavi was used on the last turn (🟢), rebuilt from the Claude Code plugin's statusline so the two can't drift.

  • It lands in agy's app-data dir ($GEMINI_HOME/antigravity-cli) and is wired into that settings.json, a different file from the ~/.gemini/config/mcp_config.json that holds the MCP block. Pass --settings PATH if your agy build reads it from elsewhere.
  • Skip it with --no-statusline. Revert with python3 statusline/install.py disable: the previous statusLine, if any, is saved and restored exactly.
  • agy has no plugin cache, so the statusline is a frozen copy: re-run the script after a plugin update to refresh it.

Windows (native, no bash)

connect-codenavi.sh needs bash, so on Windows do its three steps by hand in PowerShell. You need the agy CLI (the Antigravity 2.0 app does not include it; install the CLI separately) and Python 3 on PATH as python3 for the plugin's hooks. Use plugin 0.4.6 or newer: older versions break every shell command on Windows (agy runs hook commands through cmd.exe).

# 1. Install the plugin from the server's bundle
cd $HOME\Downloads
curl.exe -o codenavi-agy.zip http://<server-ip>:8765/plugins/antigravity.zip
Expand-Archive -Force codenavi-agy.zip codenavi-agy
agy plugin install "$PWD\codenavi-agy\codenavi-plugin-antigravity"

# 2. Add codenavi to mcp_config.json, keeping any other servers.
#    Stops without writing if the file is not valid JSON. Writes mcp_config.json.bak first.
$env:CODENAVI_AUTH_TOKEN = Read-Host "CodeNavi token"
$f = Join-Path $HOME '.gemini\config\mcp_config.json'
$ErrorActionPreference = 'Stop'
$entry = [pscustomobject]@{ serverUrl = "http://<server-ip>:8765/mcp"; headers = [pscustomobject]@{ Authorization = "Bearer $env:CODENAVI_AUTH_TOKEN" } }
if (Test-Path $f) { $c = Get-Content -Raw $f | ConvertFrom-Json; Copy-Item $f "$f.bak" } else { New-Item -ItemType Directory -Force (Split-Path $f) | Out-Null; $c = [pscustomobject]@{} }
if (-not $c.mcpServers) { $c | Add-Member -Force mcpServers ([pscustomobject]@{}) }
$c.mcpServers | Add-Member -Force codenavi $entry
[IO.File]::WriteAllText($f, ($c | ConvertTo-Json -Depth 10))
  1. Start a new agy session and run /codenavi:status. Expected: healthy (<version>) at http://<server-ip>:8765 and your codebases.

The token goes into the file as a literal value (see The three things that bite people). Headless agy --print also needs the mcp(codenavi/*) allow rule in ~/.gemini/antigravity-cli/settings.json; the interactive session asks instead.

The Antigravity 2.0 app

The app reads the same mcp_config.json and the plugins that agy plugin install puts in ~/.gemini/config/plugins/. After the steps above (or connect-codenavi.sh on Linux and macOS), fully quit the app and start it again: Customizations → Installed lists codenavi, and an agent can call list_codebases. In the app you start a plugin skill by typing its name (for example codebases) and choosing the match, not with /codenavi:<name>. Verified on Windows, 2026-10-20.

Windows / WSL2

If you're running CodeNavi inside WSL2 and want to use Antigravity on the Windows host (or its IDE), the networking + scoping story is different, see connecting-antigravity-windows.md.

Other MCP clients

Cursor, Windsurf, VS Code, and other MCP-capable clients connect to the same http://localhost:8765/mcp endpoint, but the config shape differs per client (Windsurf uses serverUrl, Cursor needs no type, VS Code uses servers). See connecting-vscode.md for the exact per-client config.