Gemini CLI

Gemini CLI MCP servers: gemini mcp add and mcpServers in settings.json

How do I add an MCP server to Gemini CLI?

Run gemini mcp add with a name and a command or URL, or add an entry under mcpServers in settings.json. Each server needs one of command (stdio), url (SSE) or httpUrl (streamable HTTP). Check status with gemini mcp list in your shell or /mcp inside the CLI.

Add a server from the command line

gemini mcp add writes to .gemini/settings.json by default. Use -s user to write to ~/.gemini/settings.json instead.

stdio server

gemini mcp add -e API_KEY=123 my-stdio-server /path/to/server arg1 arg2

HTTP server with a header

gemini mcp add --transport http --header "Authorization: Bearer abc123" secure-http https://api.example.com/mcp/

SSE server

gemini mcp add --transport sse sse-server https://api.example.com/sse/
  • -s, --scope: user or project. Default is project.
  • -t, --transport: stdio, sse or http. Default is stdio.
  • -e, --env and -H, --header: set env vars and HTTP headers.
  • --trust: skip all tool call confirmations for this server.
  • --include-tools and --exclude-tools: comma separated tool lists.
  • --timeout: connection timeout in milliseconds.

Configure mcpServers in settings.json

settings.json

{
  "mcpServers": {
    "serverName": {
      "command": "path/to/server",
      "args": ["--arg1", "value1"],
      "env": {
        "API_KEY": "$MY_API_TOKEN"
      },
      "cwd": "./server-directory",
      "timeout": 30000,
      "trust": false
    }
  }
}
  • Required: one of command, url or httpUrl.
  • timeout is in milliseconds. Default is 600,000 (10 minutes).
  • trust defaults to false. true bypasses all confirmations for that server.
  • includeTools is an allowlist. excludeTools wins if a tool is in both.
  • headers sets custom HTTP headers for url or httpUrl servers.

Keep secrets out of the file

Values in env can reference variables with $VAR or ${VAR} on all platforms, or %VAR% on Windows. The CLI redacts sensitive host variables such as *TOKEN*, *SECRET* and *KEY* from MCP processes unless you list them explicitly in env.

Allow or block servers globally

settings.json

{
  "mcp": {
    "allowed": ["my-trusted-server"],
    "excluded": ["experimental-server"]
  }
}

List, remove, disable and authenticate

Shell

gemini mcp list
gemini mcp remove my-server
gemini mcp disable my-server --session
gemini mcp enable my-server

Inside Gemini CLI

/mcp
/mcp auth
/mcp auth serverName

stdio servers only show as Connected in gemini mcp list when the current folder is trusted. Remote servers that need OAuth open a browser for sign in, so this does not work in headless or SSH sessions without a browser.

Sources

More on Gemini CLI

Other guides

Cursor: allow all terminal commandsClaude Code: allow commands without promptsCodex CLI: approval and sandbox modesGemini CLI: YOLO mode, auto_edit and allowing specific shell commandsCursor Privacy Mode: telemetry, training and data retentionClaude Code telemetry and data retention: what is sent and how to turn it offGemini CLI: turn off usage statistics and telemetryCLAUDE.md: where it goes, how it loads, and how it works with AGENTS.mdClaude Code hooks: format on save, block risky edits, get notifiedClaude Code subagents: create one, limit its tools, and call itAdd MCP servers to Cursor with mcp.json: Keep files out of Cursor with .cursorignore: Configure Codex with config.toml: Configure Gemini CLI with settings.json: Add MCP servers to Claude Code (claude mcp add, .mcp.json, scopes): Claude Code custom slash commands and skills (SKILL.md): GitHub Copilot custom instructions: Adding MCP servers to GitHub Copilot: Claude Code settings.json: file locations, precedence, and key settingsClaude Code plugins and marketplaces: install, create, and shareGemini CLI extensions and custom commands: Configuring OpenCode with opencode.json: Cline Rules: workspace, global, and conditional rulesKiro steering files: .kiro/steering, inclusion modes, and AGENTS.mdZed agent: instruction files, MCP servers, tool permissions, and ACP agentsCursor CLI: install, headless mode, permissions and CIAider: CONVENTIONS.md, .aider.conf.yml and API keysJunie guidelines, MCP and the Action Allowlist: Amp AGENTS.md, settings.json and MCP: Configure Goose extensions, hints, recipes and permissions: Customize OpenHands with skills, AGENTS.md, setup.sh and MCP: Configure Factory Droid CLI: AGENTS.md, settings.json, autonomy, custom droids and MCPConfigure Qwen Code: settings.json, providers, QWEN.md, MCP and approval modesCursor hooks: hooks.json, beforeShellExecution, afterFileEdit and exit codesCursor sandbox: sandbox.json, network allowlist and run modesCursor settings: settings.json, Cursor Settings and the ~/.cursor config filesCursor browser agent: @browser, browser automation and approval modesCursor subagents: .cursor/agents, frontmatter, built-in Explore, Bash and BrowserCursor telemetry and OpenTelemetry export (Privacy Mode, OTLP, Analytics API): Cursor rules setup: .cursor/rules, .mdc frontmatter, globs, alwaysApply and AGENTS.mdClaude Code headless mode: claude -p, --output-format json, --bare and CI flagsClaude Code statusline: custom status bar in settings.json with context %, cost and git branchClaude Code /model: switch models, aliasesClaude Code /cost and /usage: check token spend, usage limits and reduce costsClaude Code VS Code extension: install, shortcuts, settings and /ideCodex AGENTS.md: global, project and override instruction files explainedCodex MCP servers: codex mcp add and [mcp_servers] in config.tomlCodex sandbox modes: read-only, workspace-write, danger-full-access and network accesscodex exec: run Codex non-interactively in scripts and CI with JSON outputCodex skills: create SKILL.md, skill folder locations and $skill invocationGEMINI.md in Gemini CLI: context file locations, imports and /memoryGemini CLI custom slash commands: TOML files, {{args}}, !{shell} and @{file}Gemini CLI headless mode: gemini -p, JSON output and exit codes for scripts and CIGemini CLI sandbox: enable Docker, Podman, macOS Seatbelt or gVisorcopilot-setup-steps.yml: set up the GitHub Copilot cloudGitHub Copilot CLI permissions: --allow-tool, --deny-tool, --allow-all-tools and trusted directoriesGitHub Copilot custom agents: .github/agents/*.agent.md profiles, tools and frontmatterGitHub Copilot code review settings: automatic PR reviews, rulesets, effort level and approvals

Get the weekly agent stack update

New official MCP servers, spec changes and harness releases, checked against the source. One email a week, no fluff.

Reviewed Oct 13, 2026. Settings change often; the linked vendor docs are the source of truth.