gemini-cli
Click on "Install 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-cliExplain the difference between async and await"
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 CLI MCP Server
A Model Context Protocol (MCP) server that integrates the local gemini CLI tool with Claude Code. This server acts as a bridge, allowing Claude Code to execute Gemini AI queries through the standardized MCP protocol.
Made 99% with Claude Code (including this line).
How It Works
This MCP server provides a simple interface between Claude Code and the Gemini CLI tool:
Claude Code sends a prompt via MCP protocol
The server receives the prompt through stdio JSON-RPC communication
Server executes
gemini -p "<prompt>"as a child processGemini CLI response is captured and returned to Claude Code
Claude Code displays the result to the user
Claude Code ↔ [JSON-RPC stdio] ↔ MCP Server ↔ [child_process] ↔ gemini CLIRelated MCP server: Codex MCP Server
Prerequisites
Node.js v18+ installed
Gemini CLI tool installed and available in your PATH
Test with:
gemini -p "Hello world"
Claude Code installed and configured
Installation
Clone or download this repository:
git clone <repository-url> cd gemini-mcp-serverInstall dependencies:
npm installBuild the project:
npm run build
Claude Code Configuration
Method 1: Using Claude Code CLI (Recommended)
claude mcp add gemini-cli node /absolute/path/to/gemini-mcp-server/dist/index.jsMethod 2: Manual Configuration
Edit your Claude Code configuration file (~/.claude.json):
{
"mcpServers": {
"gemini-cli": {
"type": "stdio",
"command": "node",
"args": ["/absolute/path/to/gemini-mcp-server/dist/index.js"]
}
}
}Important: Use the absolute path to your built index.js file.
Method 3: Development Mode
For development, you can run directly with ts-node:
{
"mcpServers": {
"gemini-cli": {
"type": "stdio",
"command": "npx",
"args": ["ts-node", "/absolute/path/to/gemini-mcp-server/src/index.ts"]
}
}
}Setup Verification
Restart Claude Code after configuration changes
Check MCP server status:
claude mcp listVerify in Claude Code:
Run
/mcpcommandShould show
gemini-cli: connected
Test the integration:
Hey Claude, use the gemini-cli tool to ask: "What is TypeScript?"
Available Tools
gemini_query
Executes a query using the local Gemini CLI tool.
Parameters:
prompt(string, required): The text prompt to send to Geminimodel(string, optional): Gemini model to use (defaults togemini-2.5-flash)
Example usage in Claude Code:
Please use the gemini_query tool with prompt: "Explain the difference between async and await"
# With model selection (otherwise defaults to gemini-2.5-flash)
Please use the gemini_query tool with prompt: "What is TypeScript?" and model: "gemini-1.5-flash"Development
Project Structure
gemini-mcp-server/
├── src/
│ ├── index.ts # Main MCP server
│ ├── gemini-cli.ts # CLI wrapper
│ └── types.ts # TypeScript interfaces
├── dist/ # Compiled output
├── package.json
├── tsconfig.json
├── PLAN.md # Implementation details
└── README.md # This fileDevelopment Commands
# Install dependencies
npm install
# Build for production
npm run build
# Development with auto-reload
npm run dev
# Run tests
npm test
# Run tests with coverage
npm run test:coverage
# Run tests in watch mode
npm run test:watchDevelopment Mode
For active development, you can run the server directly:
npm run devThen configure Claude Code to use ts-node as shown in Method 3 above.
Troubleshooting
Common Issues
"Connection closed" error
Ensure you're using absolute paths in configuration
Check that Node.js can execute the built file
Verify the gemini CLI is in your PATH
"Command not found: gemini"
Install the Gemini CLI tool
Ensure it's in your system PATH
Test manually:
gemini -p "test"
Server not appearing in /mcp
Restart Claude Code after configuration changes
Check the configuration file syntax
Verify absolute paths are correct
Tool not available
Run
claude mcp listto check server statusLook for connection errors in Claude Code logs
Debugging
Test the server manually:
node dist/index.js # Send JSON-RPC messages via stdin for testingTest with simulated responses (when Gemini CLI quota is exhausted):
GEMINI_TEST_MODE=true node dist/index.js # Uses simulated responses instead of calling Gemini CLICheck Gemini CLI directly:
# Test with default model (gemini-2.5-flash) gemini -m gemini-2.5-flash -p "Hello world"Verify Claude Code configuration:
claude mcp list
Testing the MCP Server
Test 1: Basic Server Test
cd /Users/zain/code/mcp/gemini-mcp-claude
node dist/index.jsThen send these JSON-RPC messages one by one:
# 1. Initialize the server
{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0.0"}}}
# 2. List available tools
{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}
# 3. Test basic query (uses gemini-2.5-flash by default)
{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"gemini_query","arguments":{"prompt":"What is 2+2?"}}}
# 4. Test with model override
{"jsonrpc":"2.0","id":4,"method":"tools/call","params":{"name":"gemini_query","arguments":{"prompt":"Hello world","model":"gemini-1.5-flash"}}}Press Ctrl+C to exit when done.
Test 2: Test Mode (If Quota Exhausted)
cd /Users/zain/code/mcp/gemini-mcp-claude
GEMINI_TEST_MODE=true node dist/index.jsSend the same JSON-RPC messages as above. You'll get simulated responses instead of hitting the Gemini API.
Test 3: Verify Gemini CLI Directly
# Test default model
gemini -m gemini-2.5-flash -p "What is 2+2?"
# Test alternative model
gemini -m gemini-1.5-flash -p "Hello world"Test 4: Configure in Claude Code
# Add to Claude Code
claude mcp add gemini-cli node $(pwd)/dist/index.js
# Verify configuration
claude mcp list
# Test in Claude Code
# Run /mcp command to see connection statusExpected Results
Initialize: Returns server info with protocol version
List tools: Shows
gemini_querytool with model parameter supportTool calls: Return Gemini responses or proper error messages
Test mode: Returns simulated responses immediately
Claude Code: Shows
gemini-cli: connectedstatus
If you hit quota limits, the server will timeout after 5 minutes (or 10 seconds in test mode) and return a proper error message.
Testing
The project includes comprehensive test suites:
Running Tests
# Run all tests
npm test
# Run tests with coverage report
npm run test:coverage
# Run tests in watch mode (for development)
npm run test:watchTest Coverage
Unit Tests:
tests/gemini-cli.test.ts- Tests for CLI wrapper functionsIntegration Tests:
tests/mcp-server.test.ts- Full MCP server testingJSON Error Handling: Tests for robust JSON parsing
Model Selection: Tests for default and custom model usage
Validation: Tests for input validation and error cases
The test suite provides:
92%+ coverage of the CLI module
Full MCP protocol compliance testing
Error scenario testing (invalid JSON, timeouts, etc.)
Both test and production mode validation
Security Notes
The server validates input to prevent command injection
Prompts are properly escaped when passed to the shell
Command execution is limited by timeout (5 minutes for production, 10 seconds for test mode)
Only stderr is used for logging (stdout reserved for MCP protocol)
Contributing
Fork the repository
Create a feature branch
Make your changes
Test with Claude Code
Submit a pull request
License
MIT License - see LICENSE file for details.
Available Tools
1 toolgemini_queryA
Execute a query using the local Gemini CLI tool. Best used for: 1) Detailed codebase analysis requiring deep understanding of multiple files and complex relationships, 2) Web searches for current documentation, API references, and coding best practices, 3) Getting a different AI perspective on complex technical problems, 4) Research tasks that benefit from Gemini's training data and capabilities. 5) Code reviews, to get a different perspective on potential issues and improvements.
| Name | Required | Description | Default |
|---|---|---|---|
| model | No | Optional Gemini model to use (defaults to gemini-2.5-flash) | gemini-2.5-flash |
| prompt | Yes | The text prompt to send to Gemini AI |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations exist, so the description must carry the full burden. It does reveal that this is a local CLI tool capable of web searches and AI-based analysis, hinting at network usage and nondeterministic behavior. Yet it omits key operational details such as latency, side effects, output format, error handling, or rate limits, making transparency only partial.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured, front-loaded with a clear one-sentence purpose followed by a numbered list of use cases. While listing five use cases makes it somewhat verbose, every item adds distinct value and contributes to the reader's understanding.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the absence of annotations and an output schema, the description should cover return behavior, errors, or operational risk, but it does not. It adequately explains the tool's intended use cases and parameters, yet for an AI-querying tool this is a notable gap that leaves the agent partially uninformed about what to expect after invocation.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, with both 'prompt' and 'model' parameters already well-documented in the schema, including types, defaults, constraints, and examples. The description adds no additional parameter-level meaning beyond what the schema provides, so the baseline score of 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description opens with a specific verb+resource statement: 'Execute a query using the local Gemini CLI tool.' It then elaborates with five concrete use cases, making the tool's scope and intent unmistakable even without sibling tools for comparison.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The 'Best used for' section provides explicit contexts for use, covering codebase analysis, web searches, alternative perspectives, research, and code reviews. However, it does not mention when not to use the tool or any alternative approaches, so it falls short of the full 5 criteria.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
1 tool update
v1.0.0- First observed
gemini_query
TDQS
With only one tool, there is no possibility of confusion or overlap. The tool's purpose is clearly defined as executing queries via the Gemini CLI.
The single tool name 'gemini_query' follows a clear noun_verb pattern and is descriptive. Since there is only one tool, consistency cannot be fully assessed, but the name is reasonable and follows common conventions.
A server with a single tool feels thin for the broad range of tasks described (code analysis, web search, code review). While a single tool can be acceptable for a simple CLI wrapper, the scope of use cases suggests more tools might be expected.
The single tool appears to cover a wide range of query types, but the lack of any additional tools for managing sessions, configurations, or other CLI capabilities leaves notable gaps. The surface is functional but not fully complete for a comprehensive Gemini CLI integration.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Use AI models for chat, image, and video generation from Claude Code and other MCP hosts.
- QuallaaOAuthcom.quallaa
Talk to your public-facing AI from any MCP client — Claude, ChatGPT, Cursor, Cline, Windsurf.
Source-checked CLI guides and model-aware planning for Claude Code, Codex, and Grok Build.
Hosted MCP server connecting claude.ai, ChatGPT and other AI apps to your own computer
Related MCP Servers
- AlicenseBqualityDmaintenanceA tool that allows Claude Code to use Gemini AI as an MCP server, leveraging Gemini's large context window for analyzing large files while saving Claude Code tokens.130MIT
- AlicenseNot gradedqualityDmaintenanceIntegrates OpenAI Codex CLI with Claude Code via MCP, enabling code execution, analysis, fixing, and web search within Claude Code.7651ISC
- AlicenseNot gradedqualityDmaintenanceMCP server that enables Claude Code to interact with Google's Gemini API for code analysis, chat, and summarization tasks.70MIT
- FlicenseNot gradedqualityDmaintenanceEnables interaction with Claude and Gemini command-line tools through the MCP protocol, allowing users to send prompts to either or both LLMs and receive responses.-
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/ZainRizvi/gemini-cli-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server