Gemini CLI mcp add --exclude-tools Ignores Comma Lists
Gemini CLI 0.71.1 saves comma-separated tool names as one entry. Check user and project settings and fix the arrays while preserving existing server options.
gemini mcp add can report success with --exclude-tools x,y and still leave both x and y available.
[1] Check your version and the help text.
$ gemini --version0.71.1$ gemini mcp add --help… --include-tools A comma-separated list of tools to include [array] --exclude-tools A comma-separated list of tools to exclude [array]…The docs and CLI help describe both flags as accepting comma-separated names. With 0.71.1 and a fresh home directory, all three registrations below printed added and exited with code 0. The arrays on disk differed. Official MCP registration docs · Issue #30330
| Registration flag | Saved value |
|---|---|
--include-tools a,b | includeTools: ["a,b"] |
--exclude-tools x,y | excludeTools: ["x,y"] |
--exclude-tools x --exclude-tools y | excludeTools: ["x","y"] |
- Include lists look for an exact tool name or the name followed immediately by
(. If the server publishesaandbas separate names,"a,b"matches neither. An include list that matches zero tools hides every tool from that server. - Exclude lists run first and check for exact tool names. The entry
"x,y"blocks neitherxnory. Both can remain available if the include list and other settings allow them. Keep access controls independent of this filter.
The registration code saves the array options without splitting on commas. The tool selection behavior follows from the filter in the same release tag. v0.71.1 registration code · v0.71.1 tool filter
[2] Check both ~/.gemini/settings.json and the project's .gemini/settings.json. Save the script below as check-mcp-filters.cjs in the project root and run it there. It reads the two files and prints only the server name, setting key, and array index for each match.
const fs = require('node:fs');const os = require('node:os');const path = require('node:path'); const files = [ ['user', path.join(os.homedir(), '.gemini', 'settings.json')], ['project', path.resolve('.gemini', 'settings.json')],];const isObject = (value) => value !== null && typeof value === 'object' && !Array.isArray(value); for (const [scope, file] of files) { let reason = 'cannot read file'; try { const text = fs.readFileSync(file, 'utf8'); reason = 'invalid JSON'; const settings = JSON.parse(text); reason = 'unexpected MCP settings structure'; if (!isObject(settings)) throw new Error(); const servers = Object.hasOwn(settings, 'mcpServers') ? settings.mcpServers : {}; if (!isObject(servers)) throw new Error(); const hits = []; for (const [name, server] of Object.entries(servers)) { if (!isObject(server)) throw new Error(); for (const key of ['includeTools', 'excludeTools']) { if (!Object.hasOwn(server, key)) continue; const tools = server[key]; if (!Array.isArray(tools) || tools.some((tool) => typeof tool !== 'string')) { throw new Error(); } tools.forEach((tool, index) => { if (tool.includes(',')) hits.push(`${JSON.stringify(name)} ${key}[${index}]`); }); } } if (hits.length === 0) console.log(`${scope}: no comma entries`); for (const hit of hits) console.log(`${scope}: ${hit}`); } catch { console.error(`${scope}: no result (${reason})`); process.exitCode = 1; }}$ node check-mcp-filters.cjsuser: "demo-include" includeTools[0]user: "demo-exclude" excludeTools[0]project: "project-demo" excludeTools[1]Indices start at zero. If both files contain the same server name, use the scope printed on each line to locate the entry. A missing or unreadable file, malformed array, or invalid JSON produces no result for that scope and exit code 1. Gemini CLI accepts comments in its settings, but this script reports no result for them, so check those files in your editor. no comma entries means that the script successfully checked that file and found no comma entries. The script does not check system settings, servers provided by extensions, or settings moved with environment variables. Gemini CLI settings file locations and precedence
[3] Keep a copy of the affected settings.json in a private location before editing. The env and headers fields can contain secrets, so keep the full contents out of terminal output and shared notes. In your editor, change only the affected server's includeTools or excludeTools array. For example, change "excludeTools": ["x,y"] to "excludeTools": ["x", "y"]. Apply the same edit to an affected include list and keep the other entries.
For a fresh registration, repeat the flag once per tool. This user-scope example uses echo as a stand-in for a real MCP server.
$ gemini mcp add --scope user demo-repeat echo --exclude-tools x --exclude-tools yMCP server "demo-repeat" added to user settings. (stdio)Re-adding the same name in the same scope replaces the entire server entry. In the test, the stdio server lost its env, original arguments, and timeout, and the HTTP server lost its headers. Both lost their previous description. If you choose to re-add an existing server, supply the same scope, transport, URL or command, arguments, and all the settings you still need. v0.71.1 server entry write
[4] Run the same check after the edit. Confirm that the script no longer flags the edited server and key, then verify in your editor that each tool name has a separate array entry. If you need to undo the edit, check for intervening changes before restoring the copy.
At 06:57 KST on November 30, 2026, npm view @google/gemini-cli dist-tags showed latest pointing to 0.71.1, the release that reproduced the behavior. PR #30332, which adds comma splitting, was open when checked at 06:55 KST that day. The latest stable release still had the issue at that point. Fix PR #30332