Skip to main content
Glama

Gemini CLI MCP Server

by Artegy

Gemini CLI MCP Server

A Model Context Protocol (MCP) server that integrates Gemini CLI with Claude Code for comprehensive codebase analysis using code2prompt.

Features

  • Comprehensive Codebase Review: Full architectural analysis using Gemini's 1M token context window
  • Targeted Component Analysis: Focused analysis on specific files/folders
  • Code2Prompt Integration: Efficient codebase context extraction with token optimization
  • OAuth Support: Works with your existing Gemini CLI OAuth authentication
  • Claude Code Sub-Agent: Specialized agent for intelligent analysis orchestration

Prerequisites

Required Tools

  1. Node.js 18+ - For running the MCP server
  2. Gemini CLI - Google's CLI tool with OAuth authentication
  3. code2prompt - Rust CLI tool for codebase extraction
  4. Claude Code - For sub-agent integration

Installation Steps

1. Install Gemini CLI
npm install -g @google/gemini-cli

Authenticate with your Google account:

gemini # Follow OAuth setup prompts
2. Install code2prompt
# macOS/Linux with Homebrew brew install mufeedvh/tap/code2prompt # Or build from source cargo install code2prompt
3. Install MCP Server Dependencies
cd /Users/ryangould/Dev/gemini-cli-mcp npm install

Setup & Configuration

1. Build the MCP Server

npm run build

2. Configure Claude Code MCP Settings

Add to your Claude Code MCP settings (usually ~/.config/claude-desktop/mcp_settings.json):

{ "mcpServers": { "gemini-cli-mcp": { "command": "node", "args": [ "/Users/ryangould/Dev/gemini-cli-mcp/dist/server.js" ], "env": {} } } }

3. Restart Claude Code

Restart Claude Code to load the new MCP server.

Available Tools

gemini_comprehensive_review

Performs a complete codebase architectural review using Gemini CLI.

Parameters:

  • workingDir (string): Path to the codebase directory
  • excludePatterns (array, optional): Additional patterns to exclude

Usage Example:

// Called by Claude Code sub-agent gemini_comprehensive_review({ workingDir: "/path/to/your/project" })

gemini_targeted_analysis

Analyzes specific files or folders with focused insights.

Parameters:

  • workingDir (string): Path to the codebase directory
  • targetPaths (array): Specific files/folders to analyze
  • analysisContext (string, optional): Additional context for the analysis

Usage Example:

// Called by Claude Code sub-agent gemini_targeted_analysis({ workingDir: "/path/to/your/project", targetPaths: ["src/api/", "src/controllers/auth.js"], analysisContext: "Security review of authentication components" })

Claude Code Integration

Sub-Agent Usage

The gemini-code-analyzer sub-agent is automatically available in Claude Code once the MCP server is configured.

Example Commands:

  • "Please analyze this entire codebase for architectural issues"
  • "Review the authentication module in src/auth/ for security vulnerabilities"
  • "Analyze the API endpoints in src/controllers/ for performance bottlenecks"

Manual Tool Access

You can also call the MCP tools directly through Claude Code's tool interface:

  1. Use /tools to see available MCP tools
  2. Select gemini_comprehensive_review or gemini_targeted_analysis
  3. Provide required parameters

Development

Running in Development Mode

npm run dev

Building for Production

npm run build npm start

Project Structure

gemini-cli-mcp/ ├── src/ │ ├── server.ts # Main MCP server │ ├── tools/ # MCP tool implementations │ │ ├── comprehensive-review.ts │ │ └── targeted-analysis.ts │ └── utils/ # Utility functions │ ├── code2prompt-executor.ts │ └── gemini-executor.ts ├── prompts/ # Prompt templates │ ├── comprehensive-review.md │ └── targeted-analysis.md ├── dist/ # Built TypeScript output └── package.json

Troubleshooting

Common Issues

"gemini command not found"

Ensure Gemini CLI is installed and in your PATH:

npm install -g @google/gemini-cli which gemini
"code2prompt command not found"

Install code2prompt:

cargo install code2prompt # or brew install mufeedvh/tap/code2prompt
Authentication Issues

Re-authenticate with Gemini CLI:

gemini # Follow OAuth prompts again
MCP Server Not Connecting
  1. Check Claude Code MCP settings configuration
  2. Verify the server path is correct
  3. Check console logs for errors
  4. Restart Claude Code after configuration changes

Logging

The MCP server logs to stderr. Monitor logs when running:

npm run dev

Configuration Options

Excluding Files/Patterns

The comprehensive review automatically excludes common patterns:

  • node_modules/**
  • .git/**
  • *.log
  • dist/**, build/**
  • .next/**
  • coverage/**

Add custom exclusions via the excludePatterns parameter.

Token Management

  • code2prompt provides token counting for large codebases
  • Gemini CLI handles the 1M token context window automatically
  • Large codebases are efficiently processed through code2prompt's optimization

Security Considerations

  • Uses your existing Gemini CLI OAuth authentication
  • No API keys stored in the MCP server
  • Codebase content is sent to Gemini for analysis
  • Consider data sensitivity when analyzing proprietary code

License

MIT License - See LICENSE file for details

-
security - not tested
F
license - not found
-
quality - not tested

local-only server

The server can only run on the client's local machine because it depends on local resources.

Enables comprehensive codebase analysis using Google's Gemini AI through CLI integration. Provides architectural reviews and targeted code analysis with code2prompt integration for efficient context extraction.

  1. Features
    1. Prerequisites
      1. Required Tools
      2. Installation Steps
    2. Setup & Configuration
      1. 1. Build the MCP Server
      2. 2. Configure Claude Code MCP Settings
      3. 3. Restart Claude Code
    3. Available Tools
      1. gemini_comprehensive_review
      2. gemini_targeted_analysis
    4. Claude Code Integration
      1. Sub-Agent Usage
      2. Manual Tool Access
    5. Development
      1. Running in Development Mode
      2. Building for Production
      3. Project Structure
    6. Troubleshooting
      1. Common Issues
      2. Logging
    7. Configuration Options
      1. Excluding Files/Patterns
      2. Token Management
    8. Security Considerations
      1. License

        Related MCP Servers

        • -
          security
          F
          license
          -
          quality
          Provides AI-powered assistance for coding problems using Google's Gemini AI, combined with Perplexity insights and Stack Overflow references, facilitating contextual analysis and automatic response archiving for improved troubleshooting.
          Last updated -
          13
        • -
          security
          A
          license
          -
          quality
          Connects Claude Code with Google's Gemini AI, allowing users to ask Gemini questions, get code reviews, and brainstorm ideas directly within Claude Code.
          Last updated -
          222
          MIT License
        • A
          security
          A
          license
          A
          quality
          Pairs Claude Code with Google's Gemini AI for complementary code analysis, enabling intelligent routing where Claude handles local-context operations while Gemini leverages its 1M token context for distributed system debugging and long-trace analysis.
          Last updated -
          10
          90
          MIT License
        • A
          security
          A
          license
          A
          quality
          A lightweight MCP server that enables AI agents to perform deep codebase analysis by leveraging Gemini's massive context window for cross-file analysis and intelligent file selection.
          Last updated -
          4
          13
          MIT License
          • Apple
          • Linux

        View all related MCP servers

        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/Artegy/gemini-cli-mcp'

        If you have feedback or need assistance with the MCP directory API, please join our Discord server