Gemini CLI MCP Servers From Setup to Tool Calls
Gemini CLI MCP servers are configured through gemini mcp add or the mcpServers object in .gemini/settings.json. Add a local executable or a hosted endpoint, then inspect its tools inside Gemini CLI before asking the agent to use them. The official Gemini CLI MCP documentation covers both connection types.
The examples below connect a browser server and GitHub’s hosted server. You’ll also choose where each configuration lives, restrict the tools Gemini can use, and check an actual call rather than stopping at a connection indicator.
Add your first server from the terminal
With Gemini CLI and Node.js installed, run this from your project directory:
gemini mcp add --scope project playwright npx -y @playwright/mcp@latest
gemini
This combines Gemini CLI’s documented add command with Microsoft’s Playwright MCP package. The explicit project scope keeps the entry in the current project’s configuration. The command registers the server; the package runs through npx when the client starts it. Review the Playwright MCP repository before allowing it to run.
Inside the Gemini CLI session, enter:
/mcp list
/mcp desc
These commands list configured servers and their tools, with descriptions available through desc. They’re interactive Gemini CLI commands, so enter them at Gemini’s prompt rather than your operating system’s shell.
Use this connection choice for subsequent additions:
| What the server’s documentation provides | Gemini CLI configuration | Choose it when |
|---|---|---|
| An executable and arguments | command and args | You want Gemini CLI to launch the server locally |
| A Streamable HTTP endpoint | httpUrl, plus documented authentication | You want to connect to an already hosted server |
These are Gemini CLI’s configuration fields; its configuration reference documents their meanings.
Connect a local server or a hosted endpoint
Local process with Playwright MCP
Playwright MCP exposes browser automation through an MCP server. It fits a Gemini CLI session that needs to open a page and inspect or interact with its content. Microsoft documents the package and its browser options in the server README.
Best for: Browser work where you’re prepared to run the server and browser on your development machine.
Here’s a complete project configuration for .gemini/settings.json:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"-y",
"@playwright/mcp@latest",
"--headless",
"--isolated"
]
}
}
}
The --headless option runs without a visible browser window. The --isolated option uses an isolated browser profile; its session storage is lost when the browser closes. That’s useful for an initial test, but it won’t preserve a login across closed browser sessions. Both options belong to Playwright MCP, so they go in args.
After connecting, try this bounded request:
Use the Playwright MCP tools to open https://example.com.
Report the page title and main heading. Do not follow links.
Keep the first task small enough that you can inspect every requested action. Save authenticated browser workflows for a separate test after this basic call succeeds.
Hosted endpoint with GitHub MCP Server
GitHub provides a hosted MCP endpoint and a Gemini CLI installation guide. Its direct-connection example uses a personal access token in an authorization header. You don’t need to launch the GitHub server locally for this connection.
Best for: GitHub access without maintaining a local GitHub MCP server process.
Use this configuration, adapted from the Gemini CLI guide linked in GitHub’s server documentation:
{
"mcpServers": {
"github": {
"httpUrl": "https://api.githubcopilot.com/mcp/",
"headers": {
"Authorization": "Bearer $GITHUB_MCP_PAT"
}
}
}
}
Make GITHUB_MCP_PAT available to the Gemini CLI process before starting the session. GitHub documents storing it in a Gemini .env file, and Gemini CLI supports environment-variable references in settings strings. Keep the actual token out of the JSON you share.
For the first request, choose a repository you can already access:
Use the GitHub MCP tools to list the five most recently
updated open pull requests in OWNER/REPOSITORY.
Return their titles and URLs. Do not change anything.
Replace OWNER/REPOSITORY before submitting the request. Give the token only the repository access and permissions needed for your intended task; a request that says “do not change anything” isn’t a substitute for restricted credentials.
For additional integrations, AllMCPs helps you find, inspect, and install MCP servers. Its Gemini CLI setup page is a useful starting point, then check the selected server’s own documentation for its executable or endpoint.
Choose project scope or user scope deliberately
Gemini CLI has two everyday locations for server entries: .gemini/settings.json in a project and ~/.gemini/settings.json for your user. Project settings have higher precedence than user settings, while managed system settings can override both. See the official configuration layers reference.
Use project scope for integrations that belong to one repository. For example, keep a browser test server beside the application whose UI you’re inspecting. That makes the intended connection visible during configuration review.
Use user scope for a personal integration you deliberately want across projects:
gemini mcp add --scope user playwright npx -y @playwright/mcp@latest
The --scope user flag changes the destination settings file. Without a scope flag, gemini mcp add defaults to project scope. Specify the scope in commands you put in team documentation so readers don’t have to infer the destination.
When editing an existing file, merge the new entry into its current mcpServers object. Don’t replace unrelated settings with a standalone example. For the broader rules around client configuration shapes, use the MCP configuration JSON guide.
Expose only the tools your task needs
Gemini CLI supports per-server includeTools and excludeTools filters. Its enterprise documentation recommends an explicit includeTools allowlist when you need a restricted subset of a server’s tools. These filters control which tools the client exposes to the model.
For a deliberately small Playwright test, add an allowlist to the existing server entry:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"-y",
"@playwright/mcp@latest",
"--headless",
"--isolated"
],
"includeTools": ["browser_navigate"]
}
}
}
browser_navigate is a documented Playwright MCP tool. This example intentionally excludes the rest of the server’s tools. It’s appropriate for a navigation smoke test, not a complete browser workflow.
Start with the smallest task you need to support. Inspect the available tool descriptions, then add tools by their documented names as the workflow requires them. Avoid copying an allowlist from an unrelated integration.
Leave trust unset during initial setup. Gemini CLI documents trust: true as bypassing tool-call confirmations for that server. A familiar package name alone isn’t a reason to remove that checkpoint.
Verify discovery and then complete one tool call
After a configuration edit, start a fresh Gemini CLI session. Alternatively, the interactive command reference documents /mcp reload for reloading MCP servers and rediscovering their tools. Use /mcp schema when you need to inspect tool descriptions and input schemas.
Run:
/mcp reload
/mcp list
/mcp schema
Then repeat the bounded prompt for the server you added. Check three separate things during this acceptance test:
- The intended server appears in the session’s server list.
- Its exposed tools match the subset you intended to enable.
- The conversation shows a tool invocation and a result that answers your test request.
Don’t accept a natural-language claim of access as the entire test. Ask for a specific operation whose result you can check independently, such as the heading on a public page or the titles of pull requests you can view in GitHub.
For a team setup, record the server name, configuration scope, credential variable name, and test prompt alongside the repository’s setup instructions. Leave credential values out. This gives the next developer a repeatable acceptance test without requiring them to reconstruct your session.
Remove a server from the intended scope
To delete a server registration, use gemini mcp remove with the same scope you used when adding it:
gemini mcp remove --scope project playwright
For a user-level registration:
gemini mcp remove --scope user playwright
The remove command deletes the named configuration entry from the selected scope. It defaults to project scope, so retain the explicit flag in cleanup instructions.
Treat removal as configuration cleanup. Separately revoke any credentials you created solely for the integration if you no longer need them.