Gemini MCP Server
Enables interaction with Google's Gemini AI models including file uploads, conversation management, and batch API processing for large-scale tasks at reduced costs. Supports multiple Gemini models with advanced features like embeddings generation and automated workflow processing.
README
Gemini MCP Server
An MCP Server that provides access to Google's Gemini models with file uploads and Batch API integration.
✨ Features
- Multiple Gemini Models on Request: Gemini 2.5 Pro, 2.5 Flash, 2.0 Flash, and Embedding-001
- 🆕 Batch API Integration (v0.3.0): Async processing at 50% cost with ~24hr turnaround
- 11 batch tools for content generation and embeddings
- Intelligent JSONL conversion (CSV, JSON, TXT, MD)
- Complete workflow automation
- 8 embedding task types with AI recommendations
- Advanced File Handling: Upload and process 40+ files with batch support
- Automatic Configuration: Interactive API key setup for Claude Code & Claude Desktop
- Conversation Management: Multi-turn conversations with history tracking
- Type Safety: Full TypeScript implementation with proper type definitions
- Production Ready: Retry logic, error handling, and file state monitoring
🚀 Quick Start
Option 1: Global Install (Recommended for Claude Code)
# Install globally
npm install -g @mintmcqueen/gemini-mcp
# Add to Claude Code
claude mcp add --transport stdio gemini --scope user --env GEMINI_API_KEY=YOUR_KEY_HERE -- gemini-mcp
Option 2: Local Project Install
# Install in your project
npm install @mintmcqueen/gemini-mcp
# Add to Claude Code (adjust path as needed)
claude mcp add --transport stdio gemini --scope project --env GEMINI_API_KEY=YOUR_KEY_HERE -- node node_modules/@mintmcqueen/gemini-mcp/build/index.js
After any installation method, restart Claude Code and you're ready to use Gemini.
🔑 API Key Setup
Get Your API Key
- Visit Google AI Studio
- Create a new API key (free)
- Copy your key (starts with "AIza...")
Configure Anytime
npm run configure
The configuration wizard will:
- Validate your API key format
- Test the key with a real Gemini API request
- Write configuration to your chosen location(s)
- Provide next steps
📦 What Gets Configured
Claude Code (Global Install)
- File:
~/.claude.json(user scope) - Format: stdio MCP server with environment variables
{
"mcpServers": {
"gemini": {
"type": "stdio",
"command": "gemini-mcp",
"env": {
"GEMINI_API_KEY": "your-key-here"
}
}
}
}
Claude Code (Local Install)
- File:
.mcp.json(project scope) - Format: stdio MCP server with node execution
{
"mcpServers": {
"gemini": {
"type": "stdio",
"command": "node",
"args": ["node_modules/@mintmcqueen/gemini-mcp/build/index.js"],
"env": {
"GEMINI_API_KEY": "your-key-here"
}
}
}
}
Claude Desktop
- File:
~/Library/Application Support/Claude/claude_desktop_config.json(macOS) - Format: Standard MCP server configuration
Shell Environment
- File:
~/.zshrcor~/.bashrc - Format:
export GEMINI_API_KEY="your-key-here"
Usage
MCP Tools
The server provides the following tools:
chat
Send a message to Gemini with optional file attachments.
Parameters:
message(required): The message to sendmodel(optional): Model to use (gemini-2.5-pro, gemini-2.5-flash, gemini-2.5-flash-lite)files(optional): Array of files with base64 encoded datatemperature(optional): Controls randomness (0.0-2.0)maxTokens(optional): Maximum response tokensconversationId(optional): Continue an existing conversation
start_conversation
Start a new conversation session.
Parameters:
id(optional): Custom conversation ID
clear_conversation
Clear a conversation session.
Parameters:
id(required): Conversation ID to clear
🆕 Batch API Tools (v0.3.0)
Process large-scale tasks asynchronously at 50% cost with ~24 hour turnaround.
Content Generation
Simple (Automated):
// One-call solution: Ingest → Upload → Create → Poll → Download
batch_process({
inputFile: "prompts.csv", // CSV, JSON, TXT, or MD
model: "gemini-2.5-flash"
})
// Returns: Complete results with metadata
Advanced (Manual Control):
// 1. Convert your file to JSONL
batch_ingest_content({ inputFile: "prompts.csv" })
// Returns: { outputFile: "prompts.jsonl", requestCount: 100 }
// 2. Upload JSONL
upload_file({ filePath: "prompts.jsonl" })
// Returns: { uri: "files/abc123" }
// 3. Create batch job
batch_create({
inputFileUri: "files/abc123",
model: "gemini-2.5-flash"
})
// Returns: { batchName: "batches/xyz789" }
// 4. Monitor progress
batch_get_status({
batchName: "batches/xyz789",
autoPoll: true // Wait until complete
})
// Returns: { state: "SUCCEEDED", stats: {...} }
// 5. Download results
batch_download_results({ batchName: "batches/xyz789" })
// Returns: { results: [...], outputFile: "results.json" }
Embeddings
Simple (Automated):
// One-call solution with automatic task type prompting
batch_process_embeddings({
inputFile: "documents.txt",
// taskType optional - will prompt if not provided
})
// Returns: 1536-dimensional embeddings array
Advanced (Manual Control):
// 1. Select task type (if unsure)
batch_query_task_type({
context: "Building a search engine"
})
// Returns: { selectedTaskType: "RETRIEVAL_DOCUMENT", recommendation: {...} }
// 2. Ingest content for embeddings
batch_ingest_embeddings({ inputFile: "documents.txt" })
// Returns: { outputFile: "documents.embeddings.jsonl" }
// 3-5. Same as content generation workflow
// 6. Results contain 1536-dimensional vectors
Task Types (8 options):
SEMANTIC_SIMILARITY- Compare text similarityCLASSIFICATION- Categorize contentCLUSTERING- Group similar itemsRETRIEVAL_DOCUMENT- Build search indexesRETRIEVAL_QUERY- Search queriesCODE_RETRIEVAL_QUERY- Code searchQUESTION_ANSWERING- Q&A systemsFACT_VERIFICATION- Fact-checking
Job Management
// Cancel running job
batch_cancel({ batchName: "batches/xyz789" })
// Delete completed job
batch_delete({ batchName: "batches/xyz789" })
Supported Input Formats:
- CSV (converts rows to requests)
- JSON (wraps objects as requests)
- TXT (splits lines as requests)
- MD (markdown sections as requests)
- JSONL (ready to use)
MCP Resources
gemini://models/available
Information about available Gemini models and their capabilities.
gemini://conversations/active
List of active conversation sessions with metadata.
🔧 Development
npm run build # Build TypeScript
npm run watch # Watch mode
npm run dev # Build + auto-restart
npm run inspector # Debug with MCP Inspector
npm run configure # Reconfigure API key
Connection Failures
If Claude Code fails to connect:
- Verify your API key is correct
- Check that the command path is correct (for local installs)
- Restart Claude Code after configuration changes
🔒 Security
- API keys are never logged or echoed
- Files created with 600 permissions (user read/write only)
- Masked input during key entry
- Real API validation before storage
🤝 Contributing
Contributions are welcome! This package is designed to be production-ready with:
- Full TypeScript types
- Comprehensive error handling
- Automatic retry logic
- Real API validation
📄 License
MIT - see LICENSE file
🙋 Support
- MCP Protocol: https://modelcontextprotocol.io
- Gemini API Docs: https://ai.google.dev/docs
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。