Gemini MCP Server
This MCP server provides comprehensive access to Google's Gemini AI models for chat, file processing, image generation, batch operations, and embeddings generation.
Core Chat & Conversation: Engage in multi-turn chat sessions with Gemini models (2.5-pro, 2.5-flash, 2.0-flash-exp) with text messages and optional file attachments. Manage conversation sessions (start, continue, clear) and configure generation parameters (temperature 0-2, max tokens up to 500K).
File Management: Upload single or multiple files (2-40+) with automatic MIME type detection, parallel processing, and retry logic. List, retrieve metadata, delete individual files, or bulk cleanup all files. Files automatically expire after 48 hours with 20GB project storage limit.
Image Generation: Create new images or edit existing ones using the Gemini 2.5 Flash Image model with text prompts, supporting various aspect ratios and batch generation.
Batch Processing (50% Cost Savings): Process large-scale async tasks with ~24-hour turnaround. Complete automated workflows handle ingestion, upload, job creation, polling, and results download. Supports CSV, JSON, TXT, MD, and JSONL formats with intelligent content conversion.
Embeddings Generation: Create 1536-dimensional embeddings using gemini-embedding-001 model with 8 task types (SEMANTIC_SIMILARITY, CLASSIFICATION, CLUSTERING, RETRIEVAL_DOCUMENT, RETRIEVAL_QUERY, CODE_RETRIEVAL_QUERY, QUESTION_ANSWERING, FACT_VERIFICATION). Includes AI-powered task type selector for optimal recommendations.
Job Management: Monitor batch job status with optional auto-polling (PENDING → RUNNING → SUCCEEDED/FAILED), cancel running jobs, download and parse results, and delete completed jobs.
System Resources: Access metadata on available Gemini models (gemini://models/available) and active conversation sessions (gemini://conversations/active).
Provides access to Google's Gemini AI models (2.5 Pro, 2.5 Flash, 2.0 Flash, and Embedding-001) with support for file uploads, multi-turn conversations, batch processing at reduced cost, and embedding generation for various tasks like search, classification, and clustering.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Gemini MCP Server generate an image of a sunset over mountains with a lake in the foreground"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Gemini MCP Server
An MCP Server that provides access to the Gemini Suite.
✨ Features
Support for 1.5 through 2.5 pro
Nano Banana
Embeddings
File Upload
Batch (NLP and Embeddings)
Related MCP server: Gemini RAG MCP Server
🚀 Quick Start
Option 1: NPX (No Install Required)
claude mcp add gemini -s user --env GEMINI_API_KEY=YOUR_KEY_HERE -- npx -y @mintmcqueen/gemini-mcp@latestOption 2: Global Install
# Install globally
npm install -g @mintmcqueen/gemini-mcp
# Add to Claude Code
claude mcp add gemini -s user --env GEMINI_API_KEY=YOUR_KEY_HERE -- gemini-mcpOption 3: Local Project Install
# Install in your project
npm install @mintmcqueen/gemini-mcp
# Add to Claude Code (adjust path as needed)
claude mcp add gemini -s project --env GEMINI_API_KEY=YOUR_KEY_HERE -- node node_modules/@mintmcqueen/gemini-mcp/build/index.jsAfter any installation method, restart Claude Code and you're ready to use Gemini.
Shell Environment
File:
~/.zshrcor~/.bashrcFormat:
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
generate_images
Generate images from text prompts or edit existing images using Gemini 2.5 Flash Image model.
Parameters:
prompt(required): Text description of image to generate or editing instructionsaspectRatio(optional): Image aspect ratio -1:1,2:3,3:2,3:4,4:3,4:5,5:4,9:16,16:9,21:9(default:1:1)numImages(optional): Number of images to generate, 1-4 (default:1). Note: Makes sequential API calls, ~10-15s per image.inputImageUri(optional): File URI from uploaded file for image editing (omit for text-to-image generation)outputDir(optional): Directory to save generated images (default:./generated-images)temperature(optional): Controls randomness (0.0-2.0, default: 1.0)
Returns:
Array of generated images with file paths and base64 data
Token usage (~1,290-1,300 tokens per image)
All images include SynthID watermark
Performance Note: The Gemini API generates one image per request. When numImages > 1, the tool makes multiple sequential API calls to generate the requested number of images. Expect ~10-15 seconds per image.
Text-to-Image Example:
generate_images({
prompt: "A photorealistic coffee cup on a wooden table",
aspectRatio: "16:9",
numImages: 2
})
// Generates 2 images saved to ./generated-images/Image Editing Example:
// First, upload the image to edit
upload_file({ filePath: "./photo.jpg" })
// Returns: { uri: "files/abc123" }
// Then edit it
generate_images({
prompt: "Add a wizard hat to the subject",
inputImageUri: "files/abc123"
})
// Generates edited image saved to ./generated-images/🆕 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 metadataAdvanced (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 arrayAdvanced (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 vectorsTask 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 InspectorConnection 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
Available Tools
21 toolsbatch_cancelA
CANCEL BATCH JOB - Request cancellation of running batch job. WORKFLOW: 1) Sends cancel request to Gemini API, 2) Job transitions to CANCELLED state, 3) Processing stops (may take a few seconds), 4) Partial results may be available. USE CASE: Stop long-running job due to errors, changed requirements, or cost management. NOTE: Cannot cancel SUCCEEDED or FAILED jobs.
Inputs: batchName (required).
batch_createA
CREATE BATCH JOB - Create async content generation batch job with Gemini. COST: 50% cheaper than standard API. TURNAROUND: ~24 hours target. WORKFLOW: 1) Prepare JSONL file with requests (or use batch_ingest_content first), 2) Upload file with upload_file, 3) Call batch_create with file URI, 4) Use batch_get_status to monitor progress, 5) Use batch_download_results when complete. SUPPORTS: Inline requests (<20MB) or file-based (JSONL for large batches). Returns batch job ID and initial status.
Inputs: model, requests, inputFileUri, displayName, +2 more.
batch_create_embeddingsA
CREATE EMBEDDINGS BATCH JOB - Create async embeddings generation batch job. COST: 50% cheaper than standard API. MODEL: gemini-embedding-001 (1536 dimensions). WORKFLOW: 1) Prepare content (use batch_ingest_embeddings for conversion), 2) Select task type (use batch_query_task_type if unsure), 3) Upload file, 4) Call batch_create_embeddings, 5) Monitor with batch_get_status, 6) Download with batch_download_results. TASK TYPES: See batch_query_task_type for descriptions and recommendations.
Inputs: taskType (required), model, requests, inputFileUri, +2 more.
batch_deleteA
DELETE BATCH JOB - Permanently delete batch job and associated data. WORKFLOW: 1) Validates job exists, 2) Deletes job metadata from Gemini API, 3) Removes from internal tracking. USE CASE: Clean up completed/failed jobs, manage job history, free storage. WARNING: Irreversible operation. Results will be lost if not downloaded first. Recommended to download results before deletion.
Inputs: batchName (required).
batch_download_resultsA
DOWNLOAD BATCH RESULTS - Download and parse results from completed batch job. WORKFLOW: 1) Checks job status (must be SUCCEEDED), 2) Downloads result file from Gemini API, 3) Parses JSONL results, 4) Saves to local file, 5) Returns parsed results array. RETURNS: Array of results with original keys, responses, and metadata. Also saves to file in outputLocation.
Inputs: batchName (required), outputLocation.
batch_get_statusA
GET BATCH JOB STATUS - Check status of running batch job with optional auto-polling. STATES: PENDING (queued), RUNNING (processing), SUCCEEDED (complete), FAILED (error), CANCELLED (user stopped), EXPIRED (timeout). WORKFLOW: 1) Call with batch job name/ID, 2) Optionally enable polling to wait for completion, 3) Returns current state, progress stats, and completion info. USAGE: Pass job name from batch_create response. Enable autoPoll for hands-off waiting.
Inputs: batchName (required), autoPoll, pollIntervalSeconds, maxWaitMs.
batch_ingest_contentA
INTELLIGENT CONTENT INGESTION - Analyzes content file, converts to JSONL for batch processing. WORKFLOW: 1) Detects format (CSV, JSON, TXT, MD), 2) Analyzes structure/complexity, 3) Writes analysis scripts if needed, 4) Converts to proper JSONL format, 5) Validates JSONL structure. SUPPORTS: CSV (converts rows), JSON (wraps objects), TXT/MD (splits by lines/sections). RETURNS: Conversion report with outputFile path, validation status, and any generated scripts.
Inputs: inputFile (required), outputFile, generateScripts.
batch_ingest_embeddingsA
EMBEDDINGS CONTENT INGESTION - Specialized ingestion for embeddings batch processing. WORKFLOW: 1) Analyzes content structure, 2) Extracts text for embedding, 3) Formats as JSONL with proper embedContent structure including task_type, 4) Validates format. OPTIMIZED FOR: Text extraction from various formats (CSV columns, JSON fields, TXT lines, MD sections). RETURNS: JSONL file ready for batch_create_embeddings with task_type embedded in each request.
Inputs: inputFile (required), taskType (required), outputFile, textField.
batch_processA
COMPLETE BATCH WORKFLOW - End-to-end content generation batch processing. WORKFLOW: 1) Ingests content file (CSV, JSON, TXT, etc.), 2) Converts to JSONL, 3) Uploads to Gemini, 4) Creates batch job, 5) Polls until complete, 6) Downloads and parses results. BEST FOR: Users who want simple one-call solution. RETURNS: Final results with metadata. For more control, use individual tools (batch_ingest_content, batch_create, batch_get_status, batch_download_results).
Inputs: inputFile (required), model, outputLocation, pollIntervalSeconds, +1 more.
batch_process_embeddingsA
COMPLETE EMBEDDINGS WORKFLOW - End-to-end embeddings batch processing. WORKFLOW: 1) Ingests content, 2) Queries user for task type (or auto-recommends), 3) Converts to JSONL, 4) Uploads, 5) Creates batch job, 6) Polls until complete, 7) Downloads results. BEST FOR: Simple one-call embeddings generation. RETURNS: Embeddings array (1536-dimensional vectors) with metadata.
Inputs: inputFile (required), taskType, model, outputLocation, +1 more.
batch_query_task_typeA
INTERACTIVE TASK TYPE SELECTOR - Helps choose optimal embedding task type with recommendations. WORKFLOW: 1) Optionally analyzes sample content, 2) Shows all 8 task types with descriptions, 3) Provides AI recommendation based on context, 4) Returns selected task type. TASK TYPES: SEMANTIC_SIMILARITY (compare text similarity), CLASSIFICATION (categorize text), CLUSTERING (group similar items), RETRIEVAL_DOCUMENT (index for search), RETRIEVAL_QUERY (search queries), CODE_RETRIEVAL_QUERY (code search), QUESTION_ANSWERING (Q&A systems), FACT_VERIFICATION (check claims).
Inputs: context, sampleContent.
chatA
SEND MESSAGE TO GEMINI (with optional files) - Chat with Gemini, optionally including uploaded files for multimodal analysis. TYPICAL USE: 0-2 files for most tasks (code review, document analysis, image description). SCALES TO: 40+ files when needed for comprehensive analysis. WORKFLOW: 1) Upload files first using upload_file (single) or upload_multiple_files (multiple), 2) Pass returned URIs in fileUris array, 3) Include your text prompt in message. The server handles file object caching and proper API formatting. Supports conversation continuity via conversationId. RETURNS: response text, token usage, conversation ID. Files are passed as direct objects to Gemini (not fileData structures). Auto-retrieves missing files from API if not cached.
Inputs: message (required), model, fileUris, temperature, +2 more.
cleanup_all_filesA
BULK DELETE ALL FILES - Removes ALL files from Gemini File API associated with current API key. Clears entire cache. RETURNS: Count of deleted vs failed deletions with detailed lists. USE CASE: Complete cleanup after batch processing, reset environment, clear storage quota. WARNING: Irreversible operation affecting all uploaded files.
Inputs: no named parameters.
clear_conversationA
CLEAR CONVERSATION HISTORY - Deletes specified conversation session and all associated message history. Frees memory and resets context. USAGE: Pass conversationId from start_conversation or chat response. Returns confirmation or 'not found' message. Use when switching topics or cleaning up after completion.
Inputs: id (required).
delete_fileA
DELETE FILE FROM GEMINI - Permanently removes file from Gemini File API and clears from cache. USAGE: Pass fileUri from upload or list_files. Immediate deletion, cannot be undone. USE CASE: Clean up after processing, manage storage quota, remove sensitive data. NOTE: Files auto-delete after 48 hours if not manually removed.
Inputs: fileUri (required).
generate_imagesA
GENERATE OR EDIT IMAGES - Create images from text prompts or edit existing images using Gemini image models. CAPABILITIES: Text-to-image generation, image editing with instructions, multiple image generation (1-4 images), configurable aspect ratios. MODELS: gemini-3-pro-image-preview (default, with thinking support) or gemini-2.5-flash-image (faster). WORKFLOW: 1) Provide text prompt, 2) Optionally specify model, aspect ratio, and number of images, 3) For editing: provide inputImageUri from uploaded file, 4) Images auto-saved to outputDir. RETURNS: Array of generated images with file paths. COST: ~1,290 tokens per image. All images include SynthID watermark.
Inputs: prompt (required), model, aspectRatio, numImages, +3 more.
get_fileA
GET FILE METADATA & UPDATE CACHE - Retrieves current metadata for specific file from Gemini API and updates cache. USAGE: Pass fileUri from upload response or list_files. RETURNS: Complete file info including uri, displayName, mimeType, sizeBytes, create/update/expiration times, sha256Hash, state. Automatically adds to cache if missing. USE CASE: Verify file state, check expiration, refresh cache entry.
Inputs: fileUri (required).
list_filesA
LIST ALL UPLOADED FILES - Retrieves metadata for all files currently in Gemini File API (associated with API key). Updates internal cache with latest file states. RETURNS: Array of files with uri, displayName, mimeType, sizeBytes, createTime, expirationTime, state. Also shows cachedCount indicating files ready for immediate use. USAGE: Check file availability before chat, monitor upload status, audit storage usage (20GB project limit).
Inputs: pageSize.
start_conversationA
INITIALIZE CONVERSATION SESSION - Creates new conversation context for multi-turn chat with Gemini. Generates unique ID if not provided. Stores message history for context continuity. Returns conversationId to use in subsequent chat calls. USAGE: Call before first chat or to start fresh context. Pass returned ID to chat tool's conversationId parameter for continuation.
Inputs: id.
upload_fileA
UPLOAD SINGLE FILE - Standard method for uploading one file to Gemini. BEST FOR: Single documents, images, or code files for immediate analysis. Includes automatic retry and state monitoring until file is ready. WORKFLOW: 1) Upload with auto-detected MIME type, 2) Wait for processing to complete (usually 10-30 seconds), 3) Returns URI for chat tool. RETURNS: fileUri (pass to chat tool), displayName, mimeType, sizeBytes, state. Files auto-delete after 48 hours. For 2+ files, consider upload_multiple_files for efficiency.
Inputs: filePath (required), displayName, mimeType.
upload_multiple_filesA
UPLOAD MULTIPLE FILES EFFICIENTLY - Handles 2-40+ files with smart parallel processing. TYPICAL USE: 2-10 files for multi-document analysis, code reviews, or comparative tasks. SCALES TO: 40+ files for comprehensive dataset processing. FEATURES: Automatic retry (3 attempts), parallel uploads (5 concurrent default), processing state monitoring (waits for ACTIVE state). WORKFLOW: 1) Provide array of file paths, 2) System uploads in optimized batches, 3) Returns URIs for use in chat tool. PERFORMANCE: 2 files = ~30 seconds, 10 files = ~1-2 minutes, 40 files = ~2-3 minutes. Each successful upload returns: originalPath, file object, URI. Failed uploads include error details. Use upload_file for single files instead.
Inputs: filePaths (required), maxConcurrent, waitForProcessing.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 21 tools
Most tools have distinct purposes, but there is some overlap between batch_process and batch_process_embeddings with their individual component tools (e.g., batch_process includes batch_ingest_content, batch_create, etc.), which could cause confusion about when to use the comprehensive versus granular tools. However, descriptions clarify that the comprehensive tools are for 'simple one-call solutions,' helping to mitigate misselection.
Tool names follow a highly consistent snake_case pattern with clear verb_noun structures (e.g., batch_create, upload_file, list_files). The naming is predictable across all tools, making it easy for agents to understand and navigate the set without confusion.
With 21 tools, the count feels heavy for a Gemini MCP server, as it includes both comprehensive workflow tools and their granular components, leading to redundancy. While the domain (batch processing, file management, chat, embeddings) is broad, the tool set could be more streamlined to avoid overlap and reduce complexity.
The tool set provides complete coverage for the Gemini API domain, including batch job lifecycle (create, cancel, delete, status, results), file management (upload, list, get, delete), chat with conversation handling, embeddings generation, and image generation. There are no obvious gaps, and agents can perform all core workflows without dead ends.
Maintenance
Related MCP Connectors
GPT, Claude, Gemini, DeepSeek, Grok, Qwen and GLM through one API key. Pay per token.
LLM chat, text tools, image generation, editing, batch image jobs, and asynchronous video generation
Every major chat, image and video model on one prepaid key. OpenAI, Anthropic and Gemini formats.
33 tools: LLM chat, summaries, translation, embeddings, speech, images. From $0.002.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables Claude Desktop to interact with Google's Gemini API, allowing users to query Gemini models directly or facilitate conversations between Claude and Gemini with conversation history management.-
- AlicenseAqualityFmaintenanceEnables creation and querying of knowledge bases using Google's Gemini API File Search feature, allowing AI applications to upload documents and retrieve information through RAG (Retrieval-Augmented Generation).315 npm6MIT
- AlicenseAqualityNot gradedmaintenanceConnects to Google Gemini API for text-to-image generation and image editing, with batch processing at reduced cost and aspect ratio control.6MIT
- AlicenseAqualityDmaintenanceEnables image generation, editing, and analysis using Google's Gemini 2.5 Flash and Gemini 3 Pro models, with support for batch processing, style templates, and high-resolution output.81MIT