Provides comprehensive codebase analysis tools using Google's Gemini AI, including file analysis, directory scanning, security audits, architecture evaluation, and feature verification with support for large codebases through Gemini's massive context window.
Gemini MCP Server
An MCP (Model Context Protocol) server that provides tools for analyzing codebases using the Gemini CLI. This server leverages Gemini's massive context window to perform comprehensive codebase analysis, verification, and security audits.
Features
File Analysis: Analyze specific files using Gemini's @ syntax
Directory Analysis: Analyze entire directories and subdirectories
All Files Analysis: Analyze complete projects using --all_files flag
Implementation Verification: Check if specific features are implemented
Security Audits: Perform security analysis for common vulnerabilities
Architecture Analysis: Analyze codebase structure and patterns
Prerequisites
Gemini CLI: You must have the Gemini CLI installed and configured
# Using npx (no installation required) npx https://github.com/google-gemini/gemini-cli # Install Gemini CLI (example - check official docs for latest instructions) npm install -g @google/gemini-cli@latest # or brew install gemini-cliPython 3.12+ and uv package manager
Installation
Clone or download this project
Install dependencies:
cd gemini-mcp uv sync
Usage
Running the MCP Server
Available Tools
1. gemini_analyze_files
Analyze specific files using Gemini CLI with @ syntax.
Parameters:
files(array): List of file paths to analyzeprompt(string): Analysis prompt to send to Geminiworking_directory(optional): Directory to run command from
Example:
2. gemini_analyze_directories
Analyze entire directories using Gemini CLI.
Parameters:
directories(array): List of directory paths to analyzeprompt(string): Analysis prompt to send to Geminiworking_directory(optional): Directory to run command from
Example:
3. gemini_analyze_all_files
Analyze all files in the current directory using --all_files flag.
Parameters:
prompt(string): Analysis prompt to send to Geminiworking_directory(optional): Directory to run command from
Example:
4. gemini_verify_implementation
Verify if specific features or patterns are implemented in the codebase.
Parameters:
feature_name(string): Name of the feature to verifysearch_paths(array): Directories/files to search inverification_prompt(optional): Custom verification promptworking_directory(optional): Directory to run command from
Example:
5. gemini_security_audit
Perform security analysis of the codebase.
Parameters:
audit_type(enum): Type of audit -sql_injection,xss,auth,general,input_validationpaths(array): Paths to audit (files or directories)working_directory(optional): Directory to run command from
Example:
6. gemini_architecture_analysis
Analyze codebase architecture and patterns.
Parameters:
analysis_type(enum): Type of analysis -overview,dependencies,patterns,structure,couplingpaths(array): Paths to analyzeworking_directory(optional): Directory to run command from
Example:
Integration with Claude Code
Using claude mcp command (Recommended)
The easiest way to add this MCP server to Claude Code is using the built-in claude mcp command with uv's script dependencies:
Or if you want to install it globally first:
Manual Configuration
Alternatively, you can manually add it to your MCP configuration:
Or if installed globally:
Managing the MCP Server
Using MCP Prompts
The server exposes prompts that can be used directly via slash commands:
Available Prompts
The MCP server exposes the following prompts:
analyze_files- Analyze specific files with optional custom promptArguments:
files(required),prompt(optional)
security_audit- Perform security auditsArguments:
audit_type(required: sql_injection, xss, auth, general, input_validation),paths(required)
architecture_analysis- Analyze codebase architectureArguments:
analysis_type(required: overview, dependencies, patterns, structure, coupling),paths(required)
verify_feature- Verify if features are implementedArguments:
feature_name(required),search_paths(optional)
project_overview- Get comprehensive project overviewArguments:
focus(optional)
Use Cases
Large Codebase Analysis
When analyzing large codebases that exceed Claude's context limits, use Gemini's massive context window:
Full project overviews
Cross-file dependency analysis
Architecture documentation generation
Feature Verification
Check if specific features are implemented:
Authentication systems
Error handling patterns
Security measures
Design patterns
Security Audits
Perform comprehensive security analysis:
SQL injection vulnerability scanning
XSS vulnerability detection
Authentication/authorization review
Input validation analysis
Code Quality Assessment
Analyze code quality and structure:
Architectural pattern compliance
Code organization evaluation
Coupling analysis
Dependency management review
Development
Project Structure
Contributing
Fork the repository
Create a feature branch
Make your changes
Add tests if applicable
Submit a pull request
License
This project is licensed under the MIT License.
Troubleshooting
Common Issues
"Gemini CLI not found"
Ensure Gemini CLI is installed and in your PATH
Verify installation with
which gemini
API Key Issues
Configure Gemini CLI with your API key:
gemini config set api-key YOUR_KEYCheck if the key is valid with a simple test:
gemini -p "Hello"
Permission Errors
Ensure the working directory is accessible
Check file permissions for the files you're trying to analyze
Large File Timeouts
For very large codebases, consider analyzing specific subdirectories first
Use the directory analysis tools to break down the analysis
Updates and Maintenance
For updates to this local MCP server:
Since this is installed in "editable" mode with -e, code changes are automatically reflected without reinstalling.
Support
For issues specific to this MCP server, please check the logs and ensure:
Gemini CLI is properly installed and configured
File paths are correct and accessible
Working directory permissions are set correctly
For Gemini CLI issues, refer to the official Gemini documentation.
This server cannot be installed
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 CLI and its massive context window. Supports file/directory analysis, security audits, architecture analysis, feature verification, and complete project overviews for large codebases that exceed other AI models' context limits.