ai newsFr., 4. Dez.
EilmeldungAlibaba Releases Qwen4-35B-A3B: Open-Weight MoE Model With 1M Context

MCP-Server in der Gemini CLI hinzufügen: gemini mcp add und settings.json

Die Gemini CLI ist Googles Open-Source-Coding-Agent fürs Terminal. MCP-Server liefern ihm Zusatzwerkzeuge, etwa Browsersteuerung oder aktuelle Bibliotheksdokumentation, und lassen sich per Befehl hinzufügen.

dev.toMittwoch 19:28 · 02.12.DE6 Min. Lesezeit
Bild: dev.to

Posted on Dec 2 • Originally published at pluginstackai.com

Checked against the official docs: Dec 2, 2026

Gemini CLI is Google's open-source coding agent for the terminal. MCP (Model Context Protocol) servers give it extra tools, such as driving a browser or looking up current library docs. You can add one with a single gemini mcp add command or by editing settings.json. This guide covers both, how to check the server really connected, and the folder trust setting that blocks MCP servers for a lot of people. It was checked against Google's Gemini CLI docs on 2 December 2026, and the commands were run on Gemini CLI 0.72.0.

You need Gemini CLI installed (it needs Node.js 20 or newer). Google lists npm and Homebrew among the install options:

# npm npm install -g @google/gemini-cli # Homebrew (macOS / Linux) brew install gemini-cli Enter fullscreen mode Exit fullscreen mode Local servers started with npx need Node.js too, and servers started with uvx need uv. Check what the server you want asks for before adding it.

The gemini mcp add command writes the entry into your settings file for you. The pattern is gemini mcp add [options] <name> <command-or-url> [args...].

This adds Playwright MCP, which lets Gemini open and control a browser:

gemini mcp add playwright npx @playwright/mcp@latest Enter fullscreen mode Exit fullscreen mode If the server needs its own flags, put -- before them so Gemini CLI doesn't read them as its own. Google's example: gemini mcp add python-server python server.py -- --server-arg my-value.

Use --transport http for servers that give you a normal MCP URL (Streamable HTTP), or --transport sse for older SSE URLs. This adds Context7, which looks up current library docs:

gemini mcp add --transport http context7 https://mcp.context7.com/mcp Enter fullscreen mode Exit fullscreen mode To send an API key in a header, add -H, for example -H "Authorization: Bearer YOUR_KEY". That saves the key in the settings file as plain text, so for anything shared, use an environment variable in settings.json instead (shown below).

If you run gemini mcp add in your home folder without -s user, it stops with "Please use --scope user to edit settings in the home directory."

Gemini CLI reads servers from an mcpServers object in settings.json. The two files you'll normally use are ~/.gemini/settings.json (just you, every folder) and.gemini/settings.json in a project (that project only; project settings override user settings). There are also system-wide files for admins.

~/.gemini/settings.json or.gemini/settings.json

{ "mcpServers": { "playwright": { "command": "npx", "args": [ "@playwright/mcp@latest" ] }, "context7": { "httpUrl": "https://mcp.context7.com/mcp" } } } Enter fullscreen mode Exit fullscreen mode The fields that matter most:

Entries written by gemini mcp add --transport http look slightly different: a url plus "type": "http". Both forms connected in our test, so you don't need to change one into the other.

Google warns against underscores in server names (use my-server, not my_server ). Gemini CLI names each tool mcp_<server>_<tool>, and an underscore in the server name can make permission rules silently fail.

Coming from Cursor or Claude Desktop? Local server entries use the same command and args shape, so you can usually copy them across. For hosted servers, Gemini CLI uses httpUrl where Cursor uses url. See how to add an MCP server to Cursor for Cursor's version.

Don't paste keys straight into settings.json. Gemini CLI fills in $NAME or ${NAME} from your environment when it loads the file:

{ "mcpServers": { "my-server": { "command": "npx", "args": [ "-y", "some-mcp-server" ], "env": { "API_KEY": "$MY_API_KEY" } } } } Enter fullscreen mode Exit fullscreen mode This matters more than in other apps. To protect your secrets, Gemini CLI removes sensitive variables from what a local server inherits, including names that contain TOKEN, SECRET, PASSWORD, KEY, AUTH or CREDENTIAL. A key that is set in your shell is not passed on unless you list it in that server's env. If a server says its API key is missing, this is the first thing to check.

A variable that isn't set becomes an empty string, so set it (for example export MY_API_KEY=... in your shell profile) and open a new terminal before starting gemini.

Many hosted servers use OAuth sign-in instead of a key. You only need the URL. When the server answers that sign-in is needed, Gemini CLI finds the sign-in details, opens your browser and saves the tokens. Inside Gemini CLI, /mcp auth lists servers that support sign-in, and /mcp auth <name> signs in again, for example when a token has expired.

The browser has to be able to reach localhost on the same computer. Sign-in doesn't work over a plain SSH session, in a container without a browser, or on a headless server.

After editing settings.json while Gemini CLI is running, /mcp reload reconnects the servers. To turn a server off without deleting it, use gemini mcp disable <name> (add --session for this session only) and gemini mcp enable <name> to turn it back on. gemini mcp remove <name> deletes it; add -s user for a user-scope server.

Gemini CLI's Trusted Folders setting is on by default in current versions (the settings reference lists it as on, and our test on 0.72.0 matched). The first time you start gemini in a new folder, it asks whether to trust it. In a folder you haven't trusted, it doesn't load the project's.gemini/settings.json and doesn't connect to MCP servers at all, including ones in your user settings. Start gemini in the folder, run /permissions and choose to trust it. Your choices are saved in ~/.gemini/trustedFolders.json.

For scripts and CI, where there is nobody to answer the prompt, setting GEMINI_CLI_TRUST_WORKSPACE=true trusts the current folder for that run.

This comes from gemini mcp add in a folder that isn't trusted. Trust the folder first (above), or add the server to your user settings with -s user.

Check includeTools and excludeTools in the entry. If the server is your own, make sure it registers its tools. Gemini CLI also closes connections to servers that offer no tools.

Raise timeout (milliseconds) on that server. More on timeouts in every client: fix MCP error -32001: Request timed out.

The official MCP Inspector connects to a server on its own and lists its tools, which tells you whether the problem is the server or the Gemini CLI settings. See how to use MCP Inspector.

~/.gemini/settings.json for your user, or.gemini/settings.json in a project folder. Servers go under the top-level mcpServers key.

Yes. Use httpUrl for Streamable HTTP or url for SSE, or gemini mcp add --transport http or --transport sse.

Yes. Put them in.gemini/settings.json in the project and commit it, with keys coming from environment variables. Each person still has to trust the folder before the servers connect.

Setting "trust": true on a server (or --trust when adding it) skips the prompts for that server. Google's docs say to use it only for servers you completely control.

PluginStack is independent and not affiliated with or endorsed by the companies mentioned. Spotted something out of date? Email pluginstackai@gmail.com.

This guide was first published on PluginStack. Browse the PluginStack directory for more hand-checked MCP servers, plugins and setup guides.

Originaltitel: How to add an MCP server to Gemini CLI (gemini mcp add, settings.json, fixes)Quelle: dev.to (dev.to). Original öffnen