Gemini CLI: The Model Context Protocol (MCP)
Discover the Model Context Protocol (MCP) and learn how to automate Jekyll blog management using Gemini CLI with MCP servers.
Welcome to Part 5 of the Gemini CLI tutorial series. In the previous post, we explored configuration and customization.
This is where Gemini CLI becomes a development superpower. MCP servers transform Gemini CLI from a general AI assistant into a specialized agent with deep integration into your entire development infrastructure.
In this post, we’ll dive into MCP (Model Context Protocol) servers—one of the most powerful features of Gemini CLI. MCP servers dramatically expand what Gemini CLI can do by connecting to external services like GitHub, Google Workspace, Firebase, databases, and more.
What is the Model Context Protocol (MCP)?
The Model Context Protocol (MCP) is an open standard developed by Anthropic that enables AI models to securely interact with external tools and data sources in a structured way.
Key benefits of MCP:
- Standardized tool communication - Consistent interface for all integrations
- Security - Permissions and sandboxing built-in
- Scalability - Easy to add new integrations
- Transparency - AI shows what it’s doing before doing it
Think of MCP servers as “skill plugins” that give Gemini CLI access to specific systems (GitHub, databases, APIs, etc.).
Available MCP Servers for Gemini CLI
Official MCP Servers
GitHub MCP Server
- Manage repositories, issues, pull requests
- Read code across your projects
- Automate workflows
Firebase MCP Server
- Deploy applications to Firebase
- Manage databases and authentication
- Configure cloud functions
Google Workspace MCP Server
- Create and edit Google Docs
- Manage Gmail and Calendar
- Work with Google Sheets
Google Gen AI Media Services
- Generate and edit images
- Process media files
- Convert between formats
MCP Toolbox (Database Support)
- Connect to PostgreSQL, MySQL, MongoDB
- Run queries and manage data
- Schema inspection and migrations
Installing and Configuring MCP Servers
Step 1: Install MCP Server Packages
# GitHub MCP Server for repository management pip install anthropic-mcp-github # SQLite Database MCP Server for local databases pip install mcp-sqlite # Simple Text Files MCP Server pip install mcp-filesystem Step 2: Configure MCP Servers
Edit ~/.gemini/config.json:
{ "mcp": { "servers": [ { "name": "github", "command": "python3", "args": ["-m", "anthropic_mcp_github"], "env": { "GITHUB_TOKEN": "ghp_YOUR_TOKEN_HERE" } }, { "name": "sqlite", "command": "python3", "args": ["-m", "mcp_sqlite", "--db", "/path/to/database.db"] }, { "name": "filesystem", "command": "python3", "args": ["-m", "mcp_filesystem", "/home/user/projects"] } ] } } Step 3: Get Authentication Tokens
GitHub Token:
- Go to https://github.com/settings/tokens
- Click “Generate new token (classic)”
- Select scopes:
repo,gist,read:user - Copy token and add to
.env:
export GITHUB_TOKEN="ghp_your_personal_access_token" Step 4: Test the Connection
gemini Then in Gemini CLI:
/mcp list You should see your configured servers!
Real-World Example: GitHub Integration
Let’s automate a GitHub workflow using the GitHub MCP Server.
Use Case: Automated Code Review
Request:
Review all open pull requests in my repository myorg/myproject. For each PR: 1. Analyze the code changes 2. Check for potential issues 3. Provide feedback 4. Add a comment to the PR with your analysis What Gemini CLI will do:
- Use the GitHub MCP server to fetch open PRs
- Get the full diff for each PR
- Analyze the code with Gemini
- Post comments back to GitHub (with your permission)
Use Case: Automated Issue Triage
Request:
Review all open issues in my repository with the 'bug' label. For each issue: 1. Read the issue description 2. Check related code files mentioned 3. Suggest a priority level (high/medium/low) 4. Propose a potential fix 5. Add labels to categorize the issue Real-World Example: Database Integration
Let’s use the MCP Database Toolbox to query and analyze your database.
Use Case: Schema Analysis
Request:
Analyze my PostgreSQL database schema. Create a comprehensive documentation of: - All tables and their purposes - Relationships between tables - Indexes and their effectiveness - Potential optimization opportunities What it will do:
- Query the database schema
- Analyze table sizes and relationships
- Review index performance
- Generate recommendations
- Create documentation
Use Case: Data Migration
Request:
I have a table 'users' with old_email and new_email columns. Help me create a migration script that: 1. Validates all emails are properly formatted 2. Updates the main email column 3. Removes duplicate entries 4. Creates proper indexes 5. Tests the migration on sample data Real-World Example: Google Workspace Integration
Automate documentation and collaboration.
Use Case: Auto-Generate Documentation
Request:
Create a Google Doc with comprehensive documentation for the Gemini CLI project. Include: 1. Installation instructions 2. Quick start guide 3. Configuration reference 4. FAQ section 5. Links to official resources Share it with my team. Real-World Example: Firebase Integration
Deploy and manage serverless applications.
Use Case: Deploy a Web App
Request:
Deploy this Flask web application to Firebase: 1. Create a production environment 2. Set up environment variables 3. Deploy the application 4. Configure custom domain 5. Set up monitoring and alerts 6. Verify the deployment Listing and Managing MCP Servers
Check what MCP servers are available:
/mcp list See detailed info:
/mcp info github Disable a server temporarily:
/mcp disable firebase Best Practices for Using MCP Servers
- Use appropriate permissions - Grant only necessary access tokens
- Test in development first - Don’t run automated tasks directly on production
- Review changes before approval - Always check what the AI proposes before confirming
- Keep credentials secure - Never commit
.envfiles with tokens to git - Monitor usage - Watch MCP server logs for errors or unexpected behavior
- Document your workflows - Create notes on which MCP servers you use for what tasks
Security Considerations
Sandbox Mode Always run sensitive operations in sandbox mode:
{ "sandbox": true, "mcp": { "restrictedServers": ["database", "github"] } } Audit MCP Operations
/mcp audit log Part 6 Preview
In Part 6, we’ll explore even more MCP servers including:
- Building custom MCP servers
- Integrating with more services
- Creating complex automated workflows