Skip to main content
Tutorial2 min read

Gemini CLI MCP setup: add servers to the terminal agent (2026)

Google's Gemini CLI speaks MCP. Drop a server into ~/.gemini/settings.json and its tools appear in the terminal agent. Config, env handling and a first server, step by step.

MCP started as a Claude-and-Cursor story, but Google's Gemini CLI — the open-source agent that lives in your terminal — is now a first-class MCP client too. If you've configured servers for Claude Code, the mental model carries over almost unchanged: declare a server, and its tools show up for the agent to call. Here's the exact setup.

Where the config lives

Gemini CLI reads MCP servers from a settings.json file. Global servers go in ~/.gemini/settings.json; per-project servers go in a .gemini/settings.json at your repo root, which you can check into version control so a whole team shares the same tools. Both use the same mcpServers block that Claude and Cursor use, so a config you've already written mostly copies across.

Add your first server

Open ~/.gemini/settings.json and add an mcpServers entry. A local stdio server — say the GitHub one — looks like this:

{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"]
    }
  }
}

Restart the CLI and the server's tools are discovered automatically. Servers can also expose resources — contextual documents you can reference directly in the chat — which Gemini CLI picks up alongside tools.

Environment variables and sanitisation

Secrets belong in the env property of the server entry, not baked into args. Gemini CLI does something useful here: when it spawns a server process it sanitises the environment, redacting sensitive host variables so a third-party server can't scoop up credentials it was never handed. You still pass what a server genuinely needs — an API token, a region — explicitly, and nothing more leaks through.

How it differs from Claude Code and Cursor

The plumbing is the same JSON-RPC-over-stdio (or remote HTTP) you already know; the differences are cosmetic. Gemini CLI's file lives under ~/.gemini/ rather than a Claude or Cursor path, and its env-sanitisation default is a touch stricter. Write a clean server once and it runs across all three.

Going further

New to the format? Start with what is an MCP server, then pick tools from the best MCP servers for developers. For remote servers, read Streamable HTTP vs SSE vs stdio, and keep third-party servers honest with MCP security best practices. Comparing terminal and editor agents? See Claude Desktop vs Cursor vs Windsurf.

Loadout

Build your AI agent loadout

The directory of MCP servers and AI agents that actually work. Pick the right loadout for Slack, Postgres, GitHub, Figma and 20+ integrations — with install commands ready to paste into Claude Desktop, Cursor or your own stack.

© 2026 Loadout. Built on Angular 21 SSR.