Gemini MCP Server
Provides web search with Google Search grounding and access to Gemini AI models via the Google AI Studio API.
Allows using Vertex AI for authentication and accessing Gemini models via Google Cloud's Vertex AI platform.
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 analyze the full codebase for architectural issues"
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
Give Claude Code the power of Gemini 3.1
An MCP server that connects Claude Code to Google's Gemini 3.1, unlocking capabilities that complement Claude's strengths.
Why Gemini + Claude?
Gemini's Strengths | Use Case |
1M Token Context | Analyze entire codebases in one shot |
Google Search Grounding | Get real-time documentation & latest info |
Multimodal Vision | Understand screenshots, diagrams, designs |
Philosophy: Claude is the commander, Gemini is the specialist.
Related MCP server: Gemini MCP Server
Quick Start
Add to your MCP config file:
Mac:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.jsonLinux:
~/.config/Claude/claude_desktop_config.json
Then restart Claude Code.
Authentication
Two authentication modes are supported. The server auto-detects which mode to use based on environment variables.
Option 1: AI Studio API Key (Simplest)
Best for personal development and quick trials.
Visit Google AI Studio and create an API key
Add to your MCP config:
{
"mcpServers": {
"gemini": {
"command": "npx",
"args": ["-y", "@lkbaba/mcp-server-gemini"],
"env": {
"GEMINI_API_KEY": "your-api-key"
}
}
}
}Option 2: Vertex AI (Recommended for Production)
More secure, uses Google Cloud IAM authentication.
Prerequisites:
A Google Cloud project with Vertex AI API enabled
A service account with Vertex AI User role (create one here)
Setup (2 minutes):
Create a service account in GCP Console → download JSON key file
Open the JSON key file, copy all key-value pairs
Paste them into the
envsection of your MCP config:
{
"mcpServers": {
"gemini": {
"command": "npx",
"args": ["-y", "@lkbaba/mcp-server-gemini"],
"env": {
"type": "service_account",
"project_id": "your-project-id",
"private_key_id": "key-id-here",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEv...\n-----END PRIVATE KEY-----\n",
"client_email": "your-sa@your-project.iam.gserviceaccount.com",
"client_id": "123456789",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/your-sa%40your-project.iam.gserviceaccount.com",
"universe_domain": "googleapis.com"
}
}
}
}The server auto-detects service account credentials from env vars — no GOOGLE_GENAI_USE_VERTEXAI or GOOGLE_CLOUD_PROJECT needed. Just paste and go.
Tip: On Windows, the server automatically fixes slash corruption (
/→\) in PEM private keys that some MCP clients introduce.
Advanced options: You can also use
GOOGLE_GENAI_USE_VERTEXAI=true+GOOGLE_CREDENTIALS_JSON,GOOGLE_APPLICATION_CREDENTIALS(file path), orgcloud auth application-default login. See the environment variables reference below.
Paste JSON approach (Option 2 above — simplest for Vertex AI):
Just paste the service account JSON fields directly into env. No extra variables needed — the server auto-detects type: "service_account".
Explicit Vertex AI mode (advanced):
Variable | Required | Description |
| Yes | Set to |
| Yes | GCP project ID |
| No | Region (default: |
| No* | Entire service account JSON as a single string |
| No* | File path to service account JSON key |
* At least one credential source is needed: GOOGLE_CREDENTIALS_JSON, GOOGLE_APPLICATION_CREDENTIALS, or gcloud ADC.
AI Studio mode:
Variable | Required | Description |
| Yes | API key from Google AI Studio |
If both modes are configured, Vertex AI takes priority.
Migration Notice
v2.0.0 (2026-04): The protocol layer has been rewritten on top of the official @modelcontextprotocol/sdk. This fixes a JSON-RPC notifications/initialized spec violation inherited from the upstream fork, which caused strict MCP clients (recent Claude CLI, some VS Code extensions) to drop the connection with MCP error -32000: Connection closed or to silently omit the Gemini tools from the tool list. No user-facing API changes — upgrade is drop-in.
v1.3.0+:
The default model is now
gemini-3.1-pro-previewOld model names are automatically mapped (no config changes needed)
See CHANGELOG.md for details
Tools (5)
Research & Search
Tool | Description |
| Web search with Google Search grounding. Get real-time info, latest docs, current events. |
Analysis (1M Token Context)
Tool | Description |
| Analyze entire projects with 1M token context. Supports directory path, file paths, or direct content. |
| Analyze code, documents, or data. Supports file path or direct content input. |
Multimodal
Tool | Description |
| Analyze images with natural language. Understand designs, diagrams, screenshots. |
Creative
Tool | Description |
| Generate creative ideas with project context. Supports reading README, PRD files. |
Model Selection (v1.3.0)
All tools now support an optional model parameter:
Model | Speed | Best For |
| Standard | Complex analysis, deep reasoning, agentic workflows (default) |
| Fast | Simple tasks, quick responses, search queries |
Note: gemini-3-pro-preview is deprecated (retired 2026-03-09) and will be automatically mapped to gemini-3.1-pro-preview.
Example: Use the new default model
{
"name": "gemini_analyze_content",
"arguments": {
"filePath": "./src/index.ts",
"task": "review",
"model": "gemini-3.1-pro-preview"
}
}Usage Examples
Analyze a Large Codebase
"Use Gemini to analyze the ./src directory for architectural patterns and potential issues"Search for Latest Documentation
"Search for the latest Next.js 15 App Router documentation"Analyze an Image
"Analyze this architecture diagram and explain the data flow" (attach image)Brainstorm with Context
"Brainstorm feature ideas based on this project's README.md"Proxy Configuration
Add proxy environment variable to your config:
{
"mcpServers": {
"gemini": {
"command": "npx",
"args": ["-y", "@lkbaba/mcp-server-gemini"],
"env": {
"GEMINI_API_KEY": "your_api_key_here",
"HTTPS_PROXY": "http://127.0.0.1:7897"
}
}
}
}Local Development
git clone https://github.com/LKbaba/Gemini-mcp.git
cd Gemini-mcp
npm install
npm run build
export GEMINI_API_KEY="your_api_key_here"
npm startProject Structure
src/
├── config/
│ ├── models.ts # Model configurations
│ └── constants.ts # Global constants
├── tools/
│ ├── definitions.ts # MCP tool definitions
│ ├── multimodal-query.ts # Multimodal queries
│ ├── analyze-content.ts # Content analysis
│ ├── analyze-codebase.ts # Codebase analysis
│ ├── brainstorm.ts # Brainstorming
│ └── search.ts # Web search
├── utils/
│ ├── gemini-factory.ts # Dual-mode auth factory (API Key + Vertex AI)
│ ├── gemini-client.ts # Gemini API client
│ ├── file-reader.ts # File system access
│ ├── security.ts # Path validation
│ ├── validators.ts # Parameter validation
│ └── error-handler.ts # Error handling
├── types.ts # Type definitions
└── server.ts # Main serverCredits
Based on aliargun/mcp-server-gemini
License
MIT
Available Tools
5 toolsgemini_analyze_codebaseA
Analyze entire codebase using 1M token context. Supports directory path, file paths, or file contents. Provides architecture overview, identifies patterns, security issues, performance bottlenecks, and dependency problems.
Inputs: files, focus, model, exclude, +6 more.
gemini_analyze_contentA
Analyze code, documents, or data. Supports file path or direct content input. Provides summarization, code review, explanation, optimization, and debugging. Auto-detects content type and programming language.
TIP: This tool supports PARALLEL calls - analyze multiple files simultaneously for faster results.
Inputs: task, type, focus, model, +4 more.
gemini_brainstormA
Generate creative ideas and solutions. Provides multiple ideas with pros/cons and feasibility assessment. Supports reading project context files to generate ideas that fit your project.
Inputs: topic (required), count, model, style, +3 more.
gemini_multimodal_queryA
Query using images + text for multimodal understanding. Analyze designs, diagrams, screenshots, or any visual content with natural language questions.
Inputs: images (required), prompt (required), model, context, +1 more.
gemini_searchA
Search the web using Gemini's built-in Google Search grounding.
Features:
Returns up-to-date information with source citations
Supports thinkingLevel for reasoning depth control
Ideal for: current events, latest documentation, real-time data, fact-checking
Usage Tips:
Use thinkingLevel: 'low' for simple queries (faster response)
Use thinkingLevel: 'high' for complex analysis (deeper reasoning)
Use outputFormat: 'json' when you need structured data
Search results include source URLs in groundingMetadata
PARALLEL CALLS SUPPORTED: Search multiple queries simultaneously for faster results
Inputs: query (required), model, context, outputFormat, +1 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool targets a distinct capability: multimodal query, content analysis, codebase analysis, brainstorming, and web search. No two tools have overlapping purposes, and descriptions are clear about their unique inputs and outputs.
All tools share the consistent 'gemini_' prefix and use descriptive action words (query, analyze, brainstorm, search). However, 'gemini_multimodal_query' phrases the action as a noun-verb combination, while others are more straightforward verb-object patterns, so there is a minor deviation.
With only 5 tools, the server is well-scoped and avoids unnecessary bloat. Each tool covers a distinct major feature of the Gemini API, making the set easy to navigate and understand.
The tool surface covers the primary Gemini capabilities: multimodal understanding, content analysis, codebase analysis, ideation, and web search. A pure text generation tool is missing, but the existing tools can handle summarization, explanation, and brainstorming, so there are no critical dead ends.
Maintenance
Related MCP Connectors
Web search, scraping, Google Trends and data lookups. Paid per call in USDC on Base via x402.
Google search, news, maps, webpages, cited answers, research and ChatGPT/Gemini answers for agents.
Search Google straight from your AI agent. Web results, images, videos, news, products, scholarly ar
Live SEO workflow tools for Claude Code, Codex, and AI agents.
Related MCP Servers
- AlicenseCqualityDmaintenanceIntegrates Google's Gemini AI with Claude Code to provide advanced development assistance including code analysis, implementation planning, technical explanations, debugging support, and strategic development guidance.10285 npm7MIT
- AlicenseNot gradedqualityDmaintenanceIntegrates Google Gemini API capabilities into Claude Code, supporting text generation, image analysis, and AI image creation. It features specialized tools for creative brainstorming and managing multi-turn chat sessions.285 npmMIT
- AlicenseAqualityDmaintenanceEnables Claude to analyze codebases, search the web, process images, and brainstorm ideas using Gemini's massive context window.9247 npm35MIT
- AlicenseBqualityDmaintenanceEnables Claude to offload large codebase analysis to Google Gemini with 1M+ token context windows, persistent sessions, and dramatic token savings.844 npm1MIT