Skip to content

Connecting CodeNavi to Gemini CLI

Gemini CLI is Google's terminal coding agent. It speaks MCP natively and reaches CodeNavi over Streamable HTTP. Once connected, its agent gets CodeNavi's tools: semantic search, the call graph (find_callers, impact_analysis, diff_impact), the overview and the index tools by default, with grep, file reading and the rest one reveal_tools() call away (config.md).

Gemini CLI is not Antigravity. Both keep files under ~/.gemini/, but Antigravity reads ~/.gemini/config/mcp_config.json and Gemini CLI reads ~/.gemini/settings.json. A block in one file does nothing for the other. Antigravity has its own page: Antigravity.

The endpoint

  • URL: http://localhost:8765/mcp (unscoped) or /mcp/<codebase> (scoped)
  • Header: Authorization: Bearer <CODENAVI_AUTH_TOKEN>
  • Get the token from your install's .env: grep '^CODENAVI_AUTH_TOKEN=' .env | cut -d= -f2- (run from your install directory)

The /connect page on your server builds the exact block for you, with your server's address and token filled in.

Configure it

The quickest way is the CLI. -s user writes your user settings, so the server is there in every project. Without it, Gemini CLI writes the project's .gemini/settings.json.

gemini mcp add -s user --transport http \
  --header "Authorization: Bearer <PASTE_TOKEN>" \
  codenavi http://localhost:8765/mcp

Or edit ~/.gemini/settings.json (user) or .gemini/settings.json (project) by hand:

{
  "mcpServers": {
    "codenavi": {
      "url": "http://localhost:8765/mcp",
      "type": "http",
      "headers": { "Authorization": "Bearer <PASTE_TOKEN>" }
    }
  }
}

If your server runs with auth turned off, drop the headers line.

Verify

From the shell:

gemini mcp list

codenavi should show as Connected. If it shows Disabled with a warning that the folder is untrusted, see "The things that bite people" below. Inside a session, /mcp lists the server with its tools. Then try:

"Use semantic_search to find where payment processing happens."

The things that bite people

  1. Untrusted folders turn MCP servers off. Gemini CLI disables every MCP server, user-level ones too, in a folder you have not trusted. Start gemini in your project once and choose Trust folder (or Trust parent folder). For headless runs, pass --skip-trust or set GEMINI_CLI_TRUST_WORKSPACE=true.
  2. Keep "type": "http" next to url. That is what gemini mcp add writes. Older guides use httpUrl; it still works but is deprecated.
  3. Paste the literal token. Gemini CLI documents variable expansion for a server's env block, not for headers. Put the real Bearer value in the header and keep the file private (chmod 600 ~/.gemini/settings.json).
  4. Leave the server's trust off. "trust": true on the server entry (not the same as trusting a folder) skips the confirmation for every tool call, including reindex_full, restore and delete_note. If you want an agent that can only read, run the server with CODENAVI_MCP_READ_ONLY=true instead (config.md).
  5. Unscoped vs scoped /mcp. Use unscoped /mcp unless you know the codebase name. /mcp/<name> returns Unknown codebase (404) for a name that isn't configured; a single-codebase install is usually named default.

Agent instructions

Gemini CLI has no CodeNavi plugin. To make it prefer semantic_search over grep, copy the usage rules from the /connect page into your GEMINI.md.

Privacy

Gemini CLI sends your prompts, and the code chunks CodeNavi returns, to Google's hosted Gemini models. Whatever leaves the agent leaves your machine. Scope CodeNavi to codebases you're comfortable sharing. The CodeNavi server itself never phones home.