Gemini MCP Tool

A server for integrating with the Google Gemini CLI to perform AI-powered tasks.

Gemini MCP Tool

GitHub Release npm version npm downloads License: MIT Open Source

📚 View Full Documentation - Search me!, Examples, FAQ, Troubleshooting, Best Practices

This is a simple Model Context Protocol (MCP) server that allows AI assistants to interact with the Gemini CLI. It enables the AI to leverage the power of Gemini's massive token window for large analysis, especially with large files and codebases using the @ syntax for direction.

  • Ask gemini natural questions, through claude or Brainstorm new ideas in a party of 3!

TLDR: Claude + Google Gemini

Goal: Use Gemini's powerful analysis capabilities directly in Claude Code to save tokens and analyze large files.

Prerequisites

Before using this tool, ensure you have:

  1. Node.js (v16.0.0 or higher)
  2. Google Gemini CLI installed and configured

One-Line Setup

claude mcp add gemini-cli -- npx -y gemini-mcp-tool

Verify Installation

Type /mcp inside Claude Code to verify the gemini-cli MCP is active.


Alternative: Import from Claude Desktop

If you already have it configured in Claude Desktop:

  1. Add to your Claude Desktop config:
"gemini-cli": {
  "command": "npx",
  "args": ["-y", "gemini-mcp-tool"]
}
  1. Import to Claude Code:
claude mcp add-from-claude-desktop

Configuration

Register the MCP server with your MCP client:

For NPX Usage (Recommended)

Add this configuration to your Claude Desktop config file:

{
  "mcpServers": {
    "gemini-cli": {
      "command": "npx",
      "args": ["-y", "gemini-mcp-tool"]
    }
  }
}

For Global Installation

If you installed globally, use this configuration instead:

{
  "mcpServers": {
    "gemini-cli": {
      "command": "gemini-mcp"
    }
  }
}

Configuration File Locations:

  • Claude Desktop:
    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
    • Linux: ~/.config/claude/claude_desktop_config.json

After updating the configuration, restart your terminal session.

Example Workflow

  • Natural language: "use gemini to explain index.html", "understand the massive project using gemini", "ask gemini to search for latest news"
  • Claude Code: Type /gemini-cli and commands will populate in Claude Code's interface.

Usage Examples

With File References (using @ syntax)

  • ask gemini to analyze @src/main.js and explain what it does
  • use gemini to summarize @. the current directory
  • analyze @package.json and tell me about dependencies

General Questions (without files)

  • ask gemini to search for the latest tech news
  • use gemini to explain div centering
  • ask gemini about best practices for React development related to @file_im_confused_about

Using Gemini CLI's Sandbox Mode (-s)

The sandbox mode allows you to safely test code changes, run scripts, or execute potentially risky operations in an isolated environment.

  • use gemini sandbox to create and run a Python script that processes data
  • ask gemini to safely test @script.py and explain what it does
  • use gemini sandbox to install numpy and create a data visualization
  • test this code safely: Create a script that makes HTTP requests to an API

Tools (for the AI)

These tools are designed to be used by the AI assistant.

  • ask-gemini: Asks Google Gemini for its perspective. Can be used for general questions or complex analysis of files.
    • prompt (required): The analysis request. Use the @ syntax to include file or directory references (e.g., @src/main.js explain this code) or ask general questions (e.g., Please use a web search to find the latest news stories).
    • model (optional): The Gemini model to use. Defaults to gemini-2.5-pro.
    • sandbox (optional): Set to true to run in sandbox mode for safe code execution.
  • sandbox-test: Safely executes code or commands in Gemini's sandbox environment. Always runs in sandbox mode.
    • prompt (required): Code testing request (e.g., Create and run a Python script that... or @script.py Run this safely).
    • model (optional): The Gemini model to use.
  • Ping: A simple test tool that echoes back a message.
  • Help: Shows the Gemini CLI help text.

Slash Commands (for the User)

You can use these commands directly in Claude Code's interface (compatibility with other clients has not been tested).

  • /analyze: Analyzes files or directories using Gemini, or asks general questions.
    • prompt (required): The analysis prompt. Use @ syntax to include files (e.g., /analyze prompt:@src/ summarize this directory) or ask general questions (e.g., /analyze prompt:Please use a web search to find the latest news stories).
  • /sandbox: Safely tests code or scripts in Gemini's sandbox environment.
    • prompt (required): Code testing request (e.g., /sandbox prompt:Create and run a Python script that processes CSV data or /sandbox prompt:@script.py Test this script safely).
  • /help: Displays the Gemini CLI help information.
  • /ping: Tests the connection to the server.
    • message (optional): A message to echo back.

Contributing

Contributions are welcome! Please see our Contributing Guidelines for details on how to submit pull requests, report issues, and contribute to the project.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Disclaimer: This is an unofficial, third-party tool and is not affiliated with, endorsed, or sponsored by Google.

Related Servers