
This guide is part of our MCP setup guides, within The MCP Guide. Paths are checked against each app's documentation on the date shown.
Gemini CLI reads MCP servers from the mcpServers object in settings.json: ~/.gemini/settings.json for your user, or .gemini/settings.json inside a project. The fastest way to add one is gemini mcp add <name> <command-or-url>, then type /mcp in a session to confirm it connected.
Before you start, check which CLI you are actually on. Google's docs say Gemini CLI was replaced by Antigravity CLI for unpaid-tier and Google One users on 18 June 2026. Antigravity CLI uses a different config file, covered at the end of this guide.
Checked against: the Gemini CLI MCP server docs and Google's Antigravity MCP docs on 2 November 2026.
Key Takeaways
- User servers go in
~/.gemini/settings.json; project servers go in.gemini/settings.json. gemini mcp adddefaults to project scope and the stdio transport; pass-s useror-t httpto change that.- Use
httpUrlfor Streamable HTTP servers andurlfor SSE servers in the JSON file. - In untrusted folders, stdio servers show as "Disconnected" until you run
gemini trust. - Antigravity CLI reads
~/.gemini/config/mcp_config.jsonand usesserverUrlfor remote servers.
Which CLI do you have?
The Gemini CLI docs carry a notice that Gemini CLI was replaced by Antigravity CLI "for unpaid tier and Google One users" on 18 June 2026. Users with a paid API key or Gemini Code Assist Standard or Enterprise kept Gemini CLI, per Google's announcement summarized in our Google and MCP overview. If your terminal command is agy, skip to the Antigravity section.
Option 1: Add a server with gemini mcp add
The command syntax from the docs:
gemini mcp add [options] <name> <commandOrUrl> [args...]
Key flags:
| Flag | Meaning | Default |
|---|---|---|
-s, --scope | user or project | project |
-t, --transport | stdio, sse or http | stdio |
-e, --env | Environment variable, KEY=value | none |
-H, --header | HTTP header for sse or http | none |
--trust | Skip tool confirmation prompts | off |
--include-tools / --exclude-tools | Comma-separated tool lists | all tools |
Examples from the docs:
# Local stdio server with two environment variables
gemini mcp add -e API_KEY=123 -e DEBUG=true my-stdio-server /path/to/server arg1 arg2 arg3
# Remote Streamable HTTP server with a bearer token
gemini mcp add --transport http --header "Authorization: Bearer abc123" secure-http https://api.example.com/mcp/
Add -s user if you want the server in every project. Leave --trust off unless you have reviewed every tool; it removes the confirmation step.
Option 2: Edit settings.json
Open ~/.gemini/settings.json (or .gemini/settings.json in a project) and add an mcpServers object. Each server needs exactly one of:
commandfor a local stdio serverurlfor an SSE endpointhttpUrlfor a Streamable HTTP endpoint
This example, based on the docs' GitHub token example, runs a local server and reads the token from your shell rather than storing it:
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@github/github-mcp-server"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "$GITHUB_PERSONAL_ACCESS_TOKEN"
}
}
}
}
A remote server looks like this:
{
"mcpServers": {
"remoteTools": {
"httpUrl": "https://example.com/mcp",
"headers": { "Authorization": "Bearer ${MY_TOKEN}" }
}
}
}
Both blocks were checked against the Gemini CLI docs on 2 November 2026. Optional fields include args, env, cwd, headers, timeout (600,000 ms by default), trust and includeTools or excludeTools. Variables can use $VAR or ${VAR} on all platforms, or %VAR% on Windows. Undefined variables become empty strings.
The docs also warn: do not use underscores in server names. Use my-server, not my_server, because the policy parser splits tool names on the first underscore and rules "can fail silently."
Verify it loaded
- From the shell:
gemini mcp listshows each server's name, config and connection status. - In a session: type
/mcpto see status, tools and resources./mcp listgives more detailed diagnostics.
If a stdio server shows "Disconnected," the folder may be untrusted. The docs say stdio servers are only tested "if the current folder is trusted." Run gemini trust in that folder.
OAuth for remote servers
Gemini CLI supports OAuth 2.0 for remote SSE and HTTP servers. If a server returns 401, the CLI can discover its OAuth settings automatically. Run /mcp auth <serverName> to sign in or re-authenticate. Tokens are saved in ~/.gemini/mcp-oauth-tokens.json.
Sign-in opens a browser, so the docs note it will not work on a headless machine. Our MCP authentication guide explains the flow.
If you use Antigravity CLI instead
Google's Antigravity docs describe a different setup:
- Interactive: type
/mcpin the prompt to open the MCP Manager, which shows server status and connection logs. - Global file:
~/.gemini/config/mcp_config.json, shared with the Antigravity IDE. - Workspace file:
<workspace>/.agents/mcp_config.json.
Remote servers use serverUrl (the docs say url also works). Google's example:
{
"mcpServers": {
"my-remote-server": {
"serverUrl": "https://api.example.com/mcp/",
"headers": {
"Authorization": "Bearer YOUR_API_TOKEN"
},
"timeoutSeconds": 600
}
}
}
The docs add that "the legacy HTTP+SSE transport and the httpUrl field aren't supported." So a Gemini CLI block with httpUrl must be changed to serverUrl when you move it. Restart the CLI after editing the file.
Common mistakes
- Adding to the wrong scope.
gemini mcp addwrites to the project file by default. - Using
urlfor a Streamable HTTP server in Gemini CLI.urlmeans SSE there; usehttpUrl. - Copying Gemini CLI config into Antigravity unchanged. Switch
httpUrltoserverUrl. - Underscores in server names. They can break policy rules silently.
If a server fails in Gemini CLI, test it alone with the MCP Inspector (npx @modelcontextprotocol/inspector, Node 22.19.0 or newer) to see whether the fault is in the server or the config. More fixes are in our Gemini CLI MCP errors guide.
Next step
Compare Gemini's MCP support with other apps in ChatGPT vs Gemini for MCP and the client support matrix. The MCP config generator can draft a starting block.
More in the MCP Guide
Free tools: MCP Config Generator · Client Support Matrix
Latest research: State of MCP: October 2026
Frequently asked questions
Where is the Gemini CLI MCP config file?
In ~/.gemini/settings.json for user-wide servers, or .gemini/settings.json inside a project. MCP servers go under the mcpServers key.
What is the difference between url and httpUrl in Gemini CLI?
url is for SSE endpoints and httpUrl is for Streamable HTTP endpoints. Each server uses one of them, or command for a local process.
How do I check that Gemini CLI connected to my server?
Run gemini mcp list in your shell, or type /mcp inside a session. Both show connection status, and /mcp also lists the server's tools.
Does Antigravity CLI read my Gemini CLI settings.json?
Google's Antigravity docs only describe ~/.gemini/config/mcp_config.json and .agents/mcp_config.json. Plan to recreate your servers there, using serverUrl for remote ones.











