Get the FREE Ultimate OpenClaw Setup Guide →

GeminiMcpServer

Wraps Gemini 2.5 flash in an MCP server

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio kousen-geminimcpserver java -jar /path/to/GeminiMcpServer/build/libs/GeminiMcpServer-0.0.1-SNAPSHOT.jar \
  --env GEMINI_API_KEY="your-api-key-here"

How to use

GeminiMCPServer provides two primary MCP tools to leverage Google Gemini for large-context codebase analysis. The gemini_scanAndPlan tool scans a given codebase, applying include/exclude patterns, file/byte limits, and automatic sharding to produce an analysis plan tailored for Gemini. This plan determines which files will be analyzed and how to chunk them for Gemini’s context window. The gemini_analyzeCodebase tool then executes the actual analysis against the scanned files using the Gemini CLI, producing a report (e.g., a markdown summary) that can be saved and reviewed. In typical Claude Code or Claude Desktop workflows, you first use gemini_scanAndPlan to prepare the scope, then run gemini_analyzeCodebase to obtain Gemini’s analysis, with the results being written to a report file such as gemini-analysis-<timestamp>.md.

How to install

Prerequisites

  • Java 21 or higher
  • Google Gemini CLI installed and accessible via the gemini command in PATH
  • Gemini API key configured (environment variable GEMINI_API_KEY or Gemini CLI config)

Installation steps

  1. Build the server project (from the repository root):
./gradlew build
  1. Build the executable JAR (this is the artifact used by MCP clients):
./gradlew bootJar
  1. Verify the JAR exists at the expected path (example):
ls build/libs/GeminiMcpServer-0.0.1-SNAPSHOT.jar
  1. Optional: Run tests to verify the build:
./gradlew test
  1. Run the server directly (for debugging):
java -jar build/libs/GeminiMcpServer-0.0.1-SNAPSHOT.jar

Note: The MCP client will manage starting/stopping this server in normal usage; you typically only need to ensure the JAR is built and accessible to the client configuration.

Additional notes

Tips and common issues:

  • Ensure GEMINI_API_KEY is set in the environment or configured via Gemini CLI before starting the MCP server.
  • When using includePatterns and excludePatterns, test with small scopes to validate filtering before large scans.
  • If you encounter token limits, adjust maxFiles, maxBytes, or targetTokens in gemini_scanAndPlan to optimize chunking.
  • The server is configured to prefer the Gemini 2.5 Flash model by default for maximum context; you can override the model in gemini_analyzeCodebase if needed.
  • For Claude Code integration, point the MCP client to the Java-based server and pass the appropriate arguments; example configurations are provided in the README.

Related MCP Servers

Sponsor this space

Reach thousands of developers