docs/cli/tutorials/mcp-setup.md
Connect Gemini CLI to your external databases and services. In this guide, you'll learn how to extend Gemini CLI's capabilities by installing the GitHub MCP server and using it to manage your repositories.
Most MCP servers require authentication. For GitHub, you need a PAT.
macOS/Linux
export GITHUB_PERSONAL_ACCESS_TOKEN="github_pat_..."
Windows (PowerShell)
$env:GITHUB_PERSONAL_ACCESS_TOKEN="github_pat_..."
You tell Gemini about new servers by editing your settings.json.
~/.gemini/settings.json (or the project-specific
.gemini/settings.json).mcpServers block. This tells Gemini: "Run this docker container
and talk to it."{
"mcpServers": {
"github": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"GITHUB_PERSONAL_ACCESS_TOKEN",
"ghcr.io/github/github-mcp-server:latest"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_PERSONAL_ACCESS_TOKEN}"
}
}
}
}
[!NOTE] The
commandisdocker, and the rest are arguments passed to it. We map the local environment variable into the container so your secret isn't hardcoded in the config file.
Restart Gemini CLI. It will automatically try to start the defined servers.
Command: /mcp list
You should see: ✓ github: docker ... - Connected
If you see Disconnected or an error, check that Docker is running and your API
token is valid.
Now that the server is running, the agent has new capabilities ("tools"). You don't need to learn special commands; just ask in natural language.
Prompt: List the open PRs in the google/gemini-cli repository.
The agent will:
mcp_github_list_pull_requests.Prompt:
Create an issue in my repo titled "Bug: Login fails" with the description "See logs".
/mcp reload to force the CLI to re-query the server
for its capabilities.