- Google Gemini CLI installed (see official Gemini CLI documentation)
- GitHub Personal Access Token with appropriate scopes
- For local installation: Docker installed and running
Storing Your PAT Securely
For security, avoid hardcoding your token. Create or update ~/.gemini/.env (where ~ is your home or project directory) with your PAT:
# ~/.gemini/.env
GITHUB_PAT=your_token_hereMCP servers for Gemini CLI are configured in its settings JSON under an mcpServers key.
- Global configuration:
~/.gemini/settings.jsonwhere~is your home directory - Project-specific:
.gemini/settings.jsonin your project directory
After securely storing your PAT, you can add the GitHub MCP server configuration to your settings file using one of the methods below. You may need to restart the Gemini CLI for changes to take effect.
Note: For the most up-to-date configuration options, see the main README.md.
The simplest way is to use GitHub's hosted MCP server:
// ~/.gemini/settings.json
{
"mcpServers": {
"github": {
"httpUrl": "https://api.githubcopilot.com/mcp/",
"trust": true,
"headers": {
"Authorization": "Bearer $GITHUB_PAT"
}
}
}
}With docker running, you can run the GitHub MCP server in a container:
// ~/.gemini/settings.json
{
"mcpServers": {
"github": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"GITHUB_PERSONAL_ACCESS_TOKEN",
"ghcr.io/github/github-mcp-server"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "$GITHUB_PAT"
}
}
}
}You can download the latest binary release from the GitHub releases page or build it from source by running go build -o github-mcp-server ./cmd/github-mcp-server.
Then, replacing /path/to/binary with the actual path to your binary, configure Gemini CLI with:
// ~/.gemini/settings.json
{
"mcpServers": {
"github": {
"command": "/path/to/binary",
"args": ["stdio"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "$GITHUB_PAT"
}
}
}
}To verify that the GitHub MCP server has been configured, start Gemini CLI in your terminal with gemini, then:
-
Check MCP server status:
/mcp listℹConfigured MCP servers: 🟢 github - Ready (96 tools, 2 prompts) Tools: - github__add_comment_to_pending_review - github__add_issue_comment - github__add_sub_issue ... -
Test with a prompt
List my GitHub repositories
- Docker errors: Ensure Docker Desktop is running
docker --version
- Image pull failures: Try
docker logout ghcr.iothen retry - Docker not found: Install Docker Desktop and ensure it's running
- Invalid PAT: Verify your GitHub PAT has correct scopes:
repo- Repository operationsread:packages- Docker image access (if using Docker)
- Token expired: Generate a new GitHub PAT
- Invalid JSON: Validate your configuration:
cat ~/.gemini/settings.json | jq .
- MCP connection issues: Check logs for connection errors:
gemini --debug "test command"
- Gemini CLI Docs > MCP Configuration Structure