MCP Servers & GitHub Integration
Connect Gemini CLI to external tools via MCP, trigger Gemini reviews in GitHub Actions, and use the @gemini-cli mention in PRs for automated analysis.
Connect Gemini CLI to external tools via MCP, trigger Gemini reviews in GitHub Actions, and use the @gemini-cli mention in PRs for automated analysis.
Model Context Protocol (MCP) lets you connect Gemini CLI to external data sources and tools — databases, APIs, GitHub, Slack, and more. Once connected, Gemini can call these tools automatically as part of answering your requests.
MCP servers are configured in ~/.gemini/settings.json:
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_TOKEN": "${GITHUB_TOKEN}"
}
},
"postgres": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://localhost/mydb"
]
},
"slack": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-slack"],
"env": {
"SLACK_BOT_TOKEN": "${SLACK_BOT_TOKEN}",
"SLACK_TEAM_ID": "${SLACK_TEAM_ID}"
}
}
}
}These settings apply globally — every Gemini CLI session can use these servers.
After configuration, Gemini automatically discovers and calls MCP tools:
You can also define MCP servers in a local GEMINI.md using a code block:
## MCP Servers
```json
{
"mcpServers": {
"local-db": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres", "${DATABASE_URL}"]
}
}
}
Project-scoped servers only activate when running `gemini` in that directory.
## GitHub Actions Integration
Gemini CLI has first-class GitHub Actions integration. You can run Gemini in CI pipelines to automate code review, PR analysis, and issue triage.
### Automatic PR Review
The official `google-gemini/gemini-cli-action` GitHub Action runs Gemini on every PR:
```yaml
# .github/workflows/gemini-review.yml
name: Gemini Code Review
on:
pull_request:
types: [opened, synchronize]
jobs:
review:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Gemini PR Review
uses: google-gemini/gemini-cli-action@v1
with:
gemini_api_key: ${{ secrets.GEMINI_API_KEY }}
prompt: |
Review this pull request. Check for:
- Logic errors and edge cases
- Missing error handling
- Security issues (SQL injection, XSS, auth bypass)
- Performance concerns
Post a concise review comment with specific line references.
Gemini posts a review comment directly on the PR.
After installing the Gemini CLI GitHub App, team members can mention @gemini-cli in any PR comment to trigger an analysis:
@gemini-cli Can you explain what this function does and whether there's
a simpler implementation?
Gemini replies in the thread with its analysis. This works in PR review comments, issue comments, and discussion threads.
# .github/workflows/gemini-triage.yml
name: Gemini Issue Triage
on:
issues:
types: [opened]
jobs:
triage:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Triage with Gemini
uses: google-gemini/gemini-cli-action@v1
with:
gemini_api_key: ${{ secrets.GEMINI_API_KEY }}
prompt: |
Read this new GitHub issue and:
1. Add appropriate labels (bug, feature, question, docs)
2. Write a brief triage comment assessing priority and complexity
3. If it's a duplicate, link to the original issueFor advanced automation, run Gemini in fully non-interactive mode as part of larger scripts:
Set GEMINI_API_KEY as a repository secret in GitHub Actions. Never hardcode API keys in workflow files. Use ${{ secrets.GEMINI_API_KEY }} to reference the secret.
MCP servers connect Gemini CLI to databases, GitHub, Slack, and any other tool with an MCP adapter. GitHub Actions integration enables automated PR review and issue triage without manual invocation. The @gemini-cli mention brings AI analysis into code review threads. Combined with GEMINI.md and non-interactive mode, these features make Gemini CLI a programmable AI layer for your entire development pipeline.