How to add MCP servers to Gemini CLI (settings.json)
Gemini CLI reads MCP servers from the mcpServers object in its settings.json. The gemini mcp add command writes it for you.
Checked against the official docs on 2026-11-26. Apps change often; the sources are linked at the bottom.
Where the config file lives
| Your servers, all projects | ~/.gemini/settings.json |
| One project | .gemini/settings.json |
| Top-level key | mcpServers |
Add a remote server (a URL)
- Add a Streamable HTTP server
Use--transport http. Note thatgemini mcp addsaves to the project file unless you pass--scope user.gemini mcp add --transport http --scope user linear https://mcp.linear.app/mcp - In settings.json, use httpUrl for HTTP servers
In Gemini CLI,urlmeans an SSE endpoint andhttpUrlmeans Streamable HTTP (why this matters).{ "mcpServers": { "linear": { "httpUrl": "https://mcp.linear.app/mcp" } } } - Sign in
Run/mcp authto see servers that need sign-in, then/mcp auth NAME./mcp auth linear
Add a local server (runs on your computer)
- Add a command (stdio) server
The default transport is stdio. Pass environment variables with-e.gemini mcp add --scope user -e API_KEY=123 my-server npx -y @example/mcp-server - Or edit settings.json
timeoutis in milliseconds (default 600,000).trust: trueskips every tool confirmation, so leave it off unless you fully trust the server.{ "mcpServers": { "context7": { "command": "npx", "args": ["-y", "@upstash/context7-mcp"], "timeout": 30000, "trust": false } } }
Check and manage servers
gemini mcp list
# inside Gemini CLI: /mcp
Tips
- OAuth tokens are stored in
~/.gemini/mcp-oauth-tokens.json. - Gemini CLI's site notes that for unpaid-tier and Google One users, Gemini CLI was replaced by Antigravity CLI on June 18, 2026. Antigravity keeps MCP servers in its own
mcp_config.json, so this guide applies only if you still use Gemini CLI.
Common problems in Gemini CLI
- Gemini CLI: remote MCP server won't connect (httpUrl vs url)
- Remote MCP server says "Needs authentication" or 401 after it used to work
- Fix "spawn npx ENOENT" when starting an MCP server