Gemini CLI Orchestrator MCP
A lightweight MCP server that enables AI agents to perform deep codebase analysis by leveraging Gemini's massive context window for cross-file analysis and intelligent file selection.
README
Gemini CLI Orchestrator MCP
A lightweight CLI tool and MCP server enabling AI agents to perform deep codebase analysis with Gemini's massive context window.
🚀 Getting Started
Step 1: Install Gemini CLI
npm install -g @google/gemini-cli
Step 2: Install this tool
npm install
Step 3: Test it works
npm run analyze "What does this code do?"
That's it! Authentication happens automatically on first use.
Two Ways to Use
🚀 MCP Server (Recommended for Agents)
Makes this tool available to any AI agent via Model Context Protocol
# Install dependencies
npm install
MCP Configuration by IDE
Claude Code CLI
# Quick setup
claude mcp add gemini-cli-orchestrator node /path/to/your/gemini-cli-orchestrator/mcp-server.mjs
# Or edit ~/.claude/settings.local.json:
{
"permissions": {
"allow": ["mcp__gemini-cli-orchestrator__analyze_with_gemini"]
},
"mcpServers": {
"gemini-cli-orchestrator": {
"command": "node",
"args": ["/path/to/your/gemini-cli-orchestrator/mcp-server.mjs"]
}
}
}
Claude Desktop
Config file locations:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"gemini-cli-orchestrator": {
"command": "node",
"args": ["/path/to/your/gemini-cli-orchestrator/mcp-server.mjs"]
}
}
}
Cursor IDE
Config file: .cursor/mcp.json (project) or ~/.cursor/mcp.json (global)
{
"mcpServers": {
"gemini-cli-orchestrator": {
"command": "node",
"args": ["/path/to/your/gemini-cli-orchestrator/mcp-server.mjs"]
}
}
}
Windsurf IDE
Config file: ~/.codeium/windsurf/mcp_config.json
{
"mcpServers": {
"gemini-cli-orchestrator": {
"command": "node",
"args": ["/path/to/your/gemini-cli-orchestrator/mcp-server.mjs"],
"disabled": false
}
}
}
📁 Quick Setup: Copy example configs from .ide-configs/ directory
Any agent can now use:
analyze_with_gemini("find security issues", "@src/auth/ @middleware/")- Intelligent file selection guided by tool description
- Cross-file analysis with Gemini's massive context window
💻 Direct CLI (For Scripts/Power Users)
Ultra-simple direct usage
Quick Start
# Install
npm install
# Basic usage
npm run analyze "What does this code do?" @src/main.js
# Templates
npm run analyze --template security @src/ @package.json
# Verification (Reddit-style)
npm run analyze "Is JWT auth implemented?" @src/auth/
# Semantic keywords (NEW!)
npm run analyze "Review authentication security" @authentication
Features
✅ @ syntax file inclusion - @src/ @**/*.js @package.json
✅ Semantic keywords - @authentication @database @config (via .gemini-direct.json)
✅ 5 core templates - security, architecture, performance, quality, debug
✅ Direct Gemini calls - no MCP overhead
✅ Zero configuration - works immediately
✅ Single dependency - just glob
Examples
# File analysis
npm run analyze "Explain this code" @src/main.js
# Directory analysis
npm run analyze "Review architecture" @src/
# Multiple files
npm run analyze "Compare these" @src/old.js @src/new.js
# Security audit
npm run analyze --template security @src/ @package.json
# Verification questions
npm run analyze "Is error handling robust?" @src/ @api/
npm run analyze "Are WebSocket hooks present?" @src/hooks/
npm run analyze "Is dark mode implemented?" @src/ @styles/
How It Works
The tool has two components:
- CLI Tool (
gemini-direct.mjs): Aggregates files using @ syntax and sends to Gemini CLI - MCP Server (
mcp-server.mjs): Makes the CLI tool available to AI agents via standard protocol
File patterns like @src/ expand to include multiple files in a single Gemini analysis request.
Requirements
- Node.js 18+
- Google Gemini CLI installed and authenticated (see setup below)
⚡ Quick Setup Check
# 1. Check if Gemini CLI is installed
gemini --version
# 2. Test authentication (will prompt if needed)
echo "Hello" | gemini
# 3. Install this tool
npm install
# 4. Test the tool
npm run analyze "What does this code do?"
Setup
1. Install Gemini CLI
# Install the official Google Gemini CLI
npm install -g @google/gemini-cli
2. Authenticate with Google (OAuth - FREE)
The Gemini CLI uses OAuth authentication. No explicit auth command needed - authentication happens automatically on first use.
# Test authentication (will prompt for login if needed)
echo "Hello Gemini" | gemini
First Run: If not authenticated, Gemini CLI will automatically open your browser for OAuth login.
What Gets Created:
~/.gemini/
├── settings.json # {"selectedAuthType": "oauth-personal"}
├── oauth_creds.json # OAuth tokens (auto-refreshed)
├── user_id # Your unique identifier
└── google_account_id # Google account reference
How It Works:
- First time: Any
geminicommand opens browser for OAuth - Subsequent calls: Gemini CLI automatically uses stored tokens
- Token refresh: Happens automatically when needed
- Your tool: Inherits authentication from Gemini CLI
Cross-Platform Paths:
| OS | Auth Directory |
|---|---|
| Linux/macOS | ~/.gemini/ |
| Windows | %USERPROFILE%\.gemini\ |
| Docker | Mount host ~/.gemini/ as volume |
Uses Google OAuth authentication (personal Google account).
3. Verify Authentication
# Test that authentication works
echo "Hello Gemini" | gemini
# You should see a response from Gemini
4. Install and Test This Tool
# Clone or download this project
git clone <repository-url>
cd gemini-cli-orchestrator
# Install dependencies
npm install
# Test the tool
npm run analyze "What is 2+2?"
Authentication Details
No Code Changes Needed - Your tool automatically inherits authentication because:
// Spawns gemini CLI with full environment
const child = spawn(geminiPath, ['-m', 'gemini-2.5-flash'], {
stdio: ['pipe', 'pipe', 'pipe'],
env: { ...process.env } // ← Passes through all environment
});
The Gemini CLI handles reading ~/.gemini/oauth_creds.json automatically.
Authentication is handled by the Gemini CLI, so the tool inherits existing credentials automatically.
Troubleshooting
"Command not found: gemini"
# Check if Gemini CLI is installed
npm list -g @google/gemini-cli
# If not installed, install it
npm install -g @google/gemini-cli
"Authentication failed"
# Test authentication (will re-prompt if needed)
echo "test" | gemini
# If still failing, check if ~/.gemini/ directory exists
ls -la ~/.gemini/
"GEMINI_CLI_PATH not found"
The tool automatically finds the Gemini CLI. If you have issues:
# Find where Gemini is installed
which gemini
# Set environment variable if needed (optional)
export GEMINI_CLI_PATH=$(which gemini)
Templates
- security - OWASP-style security audit
- architecture - System design and patterns analysis
- performance - Bottleneck identification and optimization
- quality - Code quality and best practices review
- debug - Bug identification and troubleshooting
Semantic Keywords
Create a .gemini-direct.json file in your project root to define semantic keywords that map to file patterns:
{
"aliases": {
"authentication": ["src/auth/**/*", "middleware/auth*", "**/*auth*"],
"database": ["src/models/**/*", "src/db/**/*", "**/*model*"],
"api": ["src/api/**/*", "src/routes/**/*", "**/*controller*"],
"config": ["*.config.*", ".env*", "package.json"],
"tests": ["test/**/*", "**/*.test.*", "**/*.spec.*"]
},
"limits": {
"maxFiles": 30,
"maxCharsPerFile": 8000
}
}
Usage:
# Instead of guessing project structure
npm run analyze "security audit" @authentication @config
# Works across any project type (JavaScript, Python, Go, etc.)
npm run analyze "find database issues" @database
Distribution
This tool is designed to be:
- Copied - 3 files, copy anywhere
- Shared - Send to colleagues, zero setup
- Embedded - Drop into any project
- Global -
npm install -gfor system-wide use
Perfect for getting real value from Gemini's massive context window without the complexity overhead.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。