Gemini CLI MCP Server
Enables comprehensive codebase analysis using Google's Gemini AI through CLI integration. Provides architectural reviews and targeted code analysis with code2prompt integration for efficient context extraction.
README
Gemini CLI MCP Server
A Model Context Protocol (MCP) server that integrates Gemini CLI with Claude Code for comprehensive codebase analysis using code2prompt.
Features
- Comprehensive Codebase Review: Full architectural analysis using Gemini's 1M token context window
- Targeted Component Analysis: Focused analysis on specific files/folders
- Code2Prompt Integration: Efficient codebase context extraction with token optimization
- OAuth Support: Works with your existing Gemini CLI OAuth authentication
- Claude Code Sub-Agent: Specialized agent for intelligent analysis orchestration
Prerequisites
Required Tools
- Node.js 18+ - For running the MCP server
- Gemini CLI - Google's CLI tool with OAuth authentication
- code2prompt - Rust CLI tool for codebase extraction
- Claude Code - For sub-agent integration
Installation Steps
1. Install Gemini CLI
npm install -g @google/gemini-cli
Authenticate with your Google account:
gemini
# Follow OAuth setup prompts
2. Install code2prompt
# macOS/Linux with Homebrew
brew install mufeedvh/tap/code2prompt
# Or build from source
cargo install code2prompt
3. Install MCP Server Dependencies
cd /Users/ryangould/Dev/gemini-cli-mcp
npm install
Setup & Configuration
1. Build the MCP Server
npm run build
2. Configure Claude Code MCP Settings
Add to your Claude Code MCP settings (usually ~/.config/claude-desktop/mcp_settings.json):
{
"mcpServers": {
"gemini-cli-mcp": {
"command": "node",
"args": [
"/Users/ryangould/Dev/gemini-cli-mcp/dist/server.js"
],
"env": {}
}
}
}
3. Restart Claude Code
Restart Claude Code to load the new MCP server.
Available Tools
gemini_comprehensive_review
Performs a complete codebase architectural review using Gemini CLI.
Parameters:
workingDir(string): Path to the codebase directoryexcludePatterns(array, optional): Additional patterns to exclude
Usage Example:
// Called by Claude Code sub-agent
gemini_comprehensive_review({
workingDir: "/path/to/your/project"
})
gemini_targeted_analysis
Analyzes specific files or folders with focused insights.
Parameters:
workingDir(string): Path to the codebase directorytargetPaths(array): Specific files/folders to analyzeanalysisContext(string, optional): Additional context for the analysis
Usage Example:
// Called by Claude Code sub-agent
gemini_targeted_analysis({
workingDir: "/path/to/your/project",
targetPaths: ["src/api/", "src/controllers/auth.js"],
analysisContext: "Security review of authentication components"
})
Claude Code Integration
Sub-Agent Usage
The gemini-code-analyzer sub-agent is automatically available in Claude Code once the MCP server is configured.
Example Commands:
- "Please analyze this entire codebase for architectural issues"
- "Review the authentication module in src/auth/ for security vulnerabilities"
- "Analyze the API endpoints in src/controllers/ for performance bottlenecks"
Manual Tool Access
You can also call the MCP tools directly through Claude Code's tool interface:
- Use
/toolsto see available MCP tools - Select
gemini_comprehensive_revieworgemini_targeted_analysis - Provide required parameters
Development
Running in Development Mode
npm run dev
Building for Production
npm run build
npm start
Project Structure
gemini-cli-mcp/
├── src/
│ ├── server.ts # Main MCP server
│ ├── tools/ # MCP tool implementations
│ │ ├── comprehensive-review.ts
│ │ └── targeted-analysis.ts
│ └── utils/ # Utility functions
│ ├── code2prompt-executor.ts
│ └── gemini-executor.ts
├── prompts/ # Prompt templates
│ ├── comprehensive-review.md
│ └── targeted-analysis.md
├── dist/ # Built TypeScript output
└── package.json
Troubleshooting
Common Issues
"gemini command not found"
Ensure Gemini CLI is installed and in your PATH:
npm install -g @google/gemini-cli
which gemini
"code2prompt command not found"
Install code2prompt:
cargo install code2prompt
# or
brew install mufeedvh/tap/code2prompt
Authentication Issues
Re-authenticate with Gemini CLI:
gemini
# Follow OAuth prompts again
MCP Server Not Connecting
- Check Claude Code MCP settings configuration
- Verify the server path is correct
- Check console logs for errors
- Restart Claude Code after configuration changes
Logging
The MCP server logs to stderr. Monitor logs when running:
npm run dev
Configuration Options
Excluding Files/Patterns
The comprehensive review automatically excludes common patterns:
node_modules/**.git/***.logdist/**,build/**.next/**coverage/**
Add custom exclusions via the excludePatterns parameter.
Token Management
- code2prompt provides token counting for large codebases
- Gemini CLI handles the 1M token context window automatically
- Large codebases are efficiently processed through code2prompt's optimization
Security Considerations
- Uses your existing Gemini CLI OAuth authentication
- No API keys stored in the MCP server
- Codebase content is sent to Gemini for analysis
- Consider data sensitivity when analyzing proprietary code
License
MIT License - See LICENSE file for details
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。