Intelligently handles Git repositories by filtering out .git directories during codebase analysis to focus on relevant code files.
Leverages Google's Gemini AI with its 1M token context window for comprehensive codebase analysis, including semantic search, architecture analysis, and code flow tracing across entire projects.
Prioritizes JavaScript files during codebase analysis, with special handling for index.js files and proper syntax highlighting for improved code understanding.
Provides specialized support for Python codebases with priority handling of Python files and special recognition of main.py and app.py entry points.
Supports React applications with recognition and handling of JSX/TSX files in the codebase analysis.
Includes support for Svelte applications by recognizing and handling Svelte files during codebase analysis.
Supports TypeScript projects with priority handling of TypeScript files and JSX/TSX files for React applications.
Enhanced Gemini MCP Server
Intelligent Codebase Analysis with Gemini's 1M Token Context Window
Transform your development workflow with this enhanced MCP server that leverages Google's Gemini AI for comprehensive codebase analysis. Load entire projects into Gemini's massive context window and get intelligent insights about your code.
Key Features
- Intelligent Codebase Loading - Smart file prioritization and relevance scoring
- 1M Token Context - Leverage Gemini's full context window for comprehensive analysis
- Semantic Search - Natural language code search across your entire project
- Architecture Analysis - Get detailed insights into your codebase structure
- Smart Improvements - Targeted suggestions for performance, security, and maintainability
- Code Flow Tracing - Understand how functionality works across files
- Project Summaries - Comprehensive overviews of any codebase
- Session Caching - 30-minute cache for faster repeated analyses
- Export Sessions - Save important findings for future reference
Quick Start
Prerequisites
- Python 3.8+ installed
- Claude Code CLI installed
- Google Gemini API key (Get one free)
Installation
- Clone the repository:
- Run enhanced setup:
- Enter your Gemini API key when prompted
That's it!
Available Tools
Core Analysis Tools
load_codebase
Load an entire project into Gemini's context with intelligent prioritization:
analyze_architecture
Get comprehensive architecture analysis:
semantic_search
Search your codebase using natural language:
suggest_improvements
Get targeted improvement suggestions:
explain_codeflow
Trace how functionality works across your codebase:
codebase_summary
Get a comprehensive project overview:
ask_with_context
Ask any question about your loaded codebase:
Session Management Tools
export_session
Export cached analysis results to a markdown file:
session_stats
Get current session cache statistics:
Session Caching
The enhanced server includes intelligent session caching to improve performance:
- Automatic Caching: Analysis results are cached for 30 minutes
- Smart Invalidation: Cache clears when switching projects
- Performance Boost: Repeated queries return instantly from cache
- Export Capability: Save important findings before they expire
Caching Benefits
- Faster Iterations: Re-run analyses without waiting
- Token Savings: Avoid redundant API calls to Gemini
- Persistent Insights: Export sessions for long-term reference
Usage Examples
Complete Workflow Example
How It Works
Intelligent File Prioritization
The server uses a sophisticated scoring system to determine which files are most relevant:
- Language weights - Core languages (Python, JavaScript, TypeScript) get higher priority
- Directory importance -
src/
,lib/
,core/
directories are prioritized - File size optimization - Balances completeness with context limits
- Special files -
main.py
,index.js
,app.py
get bonus priority
Smart Token Management
- Uses
tiktoken
for accurate token counting - Stays within Gemini's 1M token limit intelligently
- Fallback estimation when tiktoken unavailable
- Structured context formatting for optimal analysis
Context Creation
Creates comprehensive context including:
- File tree structure with metadata
- Complete file contents with syntax highlighting
- Relevance scores and language detection
- Project statistics and organization
Technical Details
Supported File Types
- Languages: Python, JavaScript, TypeScript, Java, C++, Go, Rust, Swift, Kotlin, Scala
- Web: HTML, CSS, SCSS, Vue, Svelte, React (JSX/TSX)
- Config: JSON, YAML, XML, Dockerfile, Terraform
- Documentation: Markdown, SQL scripts
Performance Features
- Intelligent file filtering (skips
node_modules
,.git
,__pycache__
, etc.) - Relevance-based file selection
- Token-aware content loading
- Efficient context creation
Installation Details
The enhanced server is installed at: ~/.claude-mcp-servers/gemini-collab-enhanced/
File Structure
Troubleshooting
Server not showing up?
Token counting issues?
Large codebase not loading completely?
- Increase
max_tokens
parameter - Check file relevance scores
- Exclude unnecessary directories
Connection errors?
- Verify Gemini API key is valid
- Check internet connection
- Ensure dependencies are installed:
pip install -r requirements.txt
Updates
From Basic to Enhanced
If upgrading from the basic MCP server:
- Install enhanced version:
- Remove old version (optional):
Best Practices
For Large Codebases
- Start with architectural analysis
- Use semantic search to find specific areas
- Focus improvement suggestions on specific areas
- Break down complex questions into smaller parts
For Security Analysis
- Load codebase
- Run security-focused improvements
- Use semantic search for auth/validation code
- Ask specific security questions with context
For Performance Optimization
- Analyze architecture first
- Search for performance-critical code
- Get performance-focused suggestions
- Trace code flow for bottlenecks
Contributing
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Submit a pull request
License
MIT License - Use freely!
Acknowledgments
- Built for the Claude Code community
- Powered by Google's Gemini AI
- Enhanced by ECamposSoria
Ready to revolutionize your code analysis?
Start by loading your first codebase and experience the power of AI-driven development insights!
This server cannot be installed
Leverages Google's Gemini AI with a 1M token context window for comprehensive codebase analysis, enabling intelligent code search, architecture analysis, and targeted improvement suggestions.
Related MCP Servers
- -securityFlicense-qualityProvides 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 -12TypeScript
- -securityAlicense-qualityConnects 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 -204PythonMIT License
- AsecurityAlicenseAqualityPairs 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 -1067TypeScriptMIT License
- AsecurityAlicenseAqualityProvides Google Search functionality for AI models using Gemini's built-in Grounding with Google Search feature, returning real-time web search results with source citations.Last updated -157TypeScriptApache 2.0