MCP Codebase Analyser
Fetches and analyzes GitHub repositories, cloning and caching them locally to extract code sections, index them semantically, and provide AI-powered recommendations.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
π MCP Codebase Analyser
An intelligent Model Context Protocol (MCP) server that analyzes GitHub repositories and provides AI-powered recommendations for finding the right code sections for your features.
π― What Does It Do?
This MCP server allows you to ask questions like:
"I need to create a product fetch popup modal. Find the best section from jolly-commerce/jolly-sections."
The server will:
Fetch & analyze the repository (clones and caches locally)
Parse source code files (JS/TS only, skips minified bundles)
Extract functions, classes, and components with full code
Index sections using semantic embeddings (OpenAI or Ollama)
Search semantically for relevant code
Provide AI recommendations with reasoning and implementation advice
Related MCP server: Smart Code Search MCP Server
β¨ Features
π Semantic Code Search - Find code by meaning, not just keywords (0.7+ relevance scores)
π€ AI-Powered Recommendations - Get intelligent suggestions with high confidence
π Smart Filtering - Automatically skips minified files (.min.js, .chunk.js, bundles)
π» JavaScript/TypeScript Focus - Optimized for modern web development
πΎ Persistent Cache - Repositories and embeddings cached for instant repeated queries
π³ Docker Ready - Production-ready containerized deployment
π MCP Compatible - Works seamlessly with Cursor IDE and other MCP clients
β‘ Production Tested - Successfully indexes jolly-commerce/jolly-sections (152 sections, 100% success rate)
π Quick Start
Prerequisites: Docker Desktop, OpenAI API Key
1. Setup Environment
cp env.example .env
# Edit .env and add your OpenAI API key:
# LLM_API_KEY=sk-your-key-here2. Start Server
docker-compose up -d
docker-compose logs -f # Wait for "All components initialized"3. Configure Cursor
Add to Cursor MCP settings (Cmd/Ctrl + , β search "MCP"):
{
"mcpServers": {
"codebase-analyser": {
"url": "http://localhost:8050/sse",
"transport": {"type": "sse"}
}
}
}Restart Cursor.
4. Test It
In Cursor, try:
Analyze the repository jolly-commerce/jolly-sectionsWait 2-3 minutes, then:
I need to create a product fetch popup modal. Find the best section.β Expected: FetchModalProductPopUp class with code snippet
Alternative: Local Development (without Docker)
pip install uv
uv pip install -e .
# Edit .env with your API key
uv run src/main.pyπ Usage Examples
1. Analyze a Repository
First, analyze the repository you want to search:
User: Analyze the repository jolly-commerce/jolly-sections
AI uses: analyze_repository("jolly-commerce/jolly-sections")Result:
{
"success": true,
"message": "Successfully analyzed jolly-commerce/jolly-sections",
"indexing": {
"indexed": 152,
"errors": 0,
"total": 152
},
"files_analyzed": 43,
"section_types": {
"functions": 37,
"classes": 74,
"react_component": 32
}
}2. Find the Best Section for Your Feature
User: I need to create a product fetch popup modal.
Find the best section from jolly-commerce/jolly-sections.
AI uses: find_best_section(
feature_description="product fetch popup modal",
repo_identifier="jolly-commerce/jolly-sections"
)Real Response:
{
"found_match": true,
"best_match": "src/templates/components/g-modal.js",
"best_match_name": "FetchModalProductPopUp",
"confidence": "high",
"score": 0.69,
"reasoning": "The FetchModalProductPopUp class is specifically designed to handle product fetching in a modal context, which aligns perfectly with the user's request...",
"usage_advice": "To use this section, instantiate the FetchModalProductPopUp class and call the onTrigger method with the appropriate event and trigger element...",
"alternatives": ["DynamicModal", "GModal"],
"code_snippet": "class FetchModalProductPopUp extends FetchModal { ... }"
}3. Search for Specific Code Patterns
User: Find cart drawer components in jolly-commerce/jolly-sections
AI uses: search_code_sections(
query="cart drawer shopping cart sidebar",
repo_identifier="jolly-commerce/jolly-sections",
limit=10
)Real Response:
{
"success": true,
"results_count": 3,
"results": [
{
"file": "src/templates/components/g-cart.js",
"name": "CartDrawer",
"type": "class",
"score": 0.72,
"code": "class CartDrawer extends Cart { ... }"
},
{
"file": "src/templates/components/g-cart.js",
"name": "CartDrawerItem",
"type": "class",
"score": 0.70
}
]
}4. Get Repository Structure
User: What sections are available in jolly-sections?
Tool: get_repository_structure("jolly-sections/jolly-sections")5. List All Analyzed Repositories
User: What repositories have been analyzed?
Tool: list_analyzed_repositories()π οΈ Available MCP Tools
Tool | Description | Example |
| Index a GitHub repository |
|
| Get AI recommendation for feature |
|
| Semantic code search |
|
| View indexed sections |
|
| List all indexed repos |
|
| Clear cached data |
|
ποΈ Architecture
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Cursor IDE β
β (MCP Client) β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β MCP Protocol (SSE/STDIO)
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β MCP Server (FastMCP) β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Repository Fetcher β β
β β β’ Clone GitHub repos β β
β β β’ Cache locally β β
β β β’ Handle authentication β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Code Parser β β
β β β’ Parse JS/TS/Python/etc. β β
β β β’ Extract functions/classes/components β β
β β β’ Generate metadata β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Embedding System β β
β β β’ Generate embeddings (OpenAI/Ollama) β β
β β β’ ChromaDB vector database β β
β β β’ Semantic search β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Recommendation System β β
β β β’ LLM analysis (GPT-4/Ollama) β β
β β β’ Context-aware suggestions β β
β β β’ Implementation advice β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β β
β β β
repo_cache/ chroma_db/ GitHub APIπ Project Structure
mcp-codebase-analyser/
βββ src/
β βββ main.py # MCP server & tools
β βββ repo_fetcher.py # GitHub repository fetching
β βββ code_parser.py # Code parsing & extraction
β βββ embedding_system.py # Vector embeddings & search
β βββ recommendation_system.py # AI recommendations
β βββ utils.py # Utility functions
βββ repo_cache/ # Cached repositories
βββ chroma_db/ # Vector database
βββ Dockerfile # Docker image
βββ docker-compose.yml # Docker compose config
βββ pyproject.toml # Python dependencies
βββ env.example # Environment variables template
βββ README.md # This fileπ Environment Variables
Variable | Description | Default | Required |
| Server host |
| No |
| Server port |
| No |
| Transport type ( |
| No |
| LLM provider ( |
| Yes |
| API key for LLM | - | Yes (OpenAI) |
| Model name |
| No |
| Embedding model |
| No |
| GitHub personal access token | - | No |
| Repository cache directory |
| No |
| ChromaDB directory |
| No |
| Max file size to parse |
| No |
| File extensions to parse |
| No |
Note: The system automatically skips:
Minified files (
.min.js)Bundle files (
.chunk.js,bundle-*.js)Assets directory compiled code
This ensures only source code is indexed for better quality results
π§ͺ Testing
Test the server with the production-tested repository:
# 1. Start the server
docker-compose up -d
# 2. Check logs for success messages
docker-compose logs -f
# Look for: "Initialized embedding system with openai provider"
# Look for: "All components initialized successfully"
# 3. In Cursor, try these verified examples:Test 1: Analyze Repository (2-3 minutes)
Analyze the repository jolly-commerce/jolly-sectionsExpected: 152 sections indexed, 0 errors
Test 2: Find Specific Component (10-15 seconds)
I need to create a product fetch popup modal. Find the best section.Expected: FetchModalProductPopUp class with high confidence (0.69+)
Test 3: Search Components (5-10 seconds)
Find cart drawer components in jolly-commerce/jolly-sectionsExpected: CartDrawer, CartDrawerItem with relevance scores
π Troubleshooting
Server won't start
Check Docker Desktop is running
Verify
.envfile exists and has correct valuesCheck logs:
docker-compose logs -f
Can't clone private repositories
Add
GITHUB_TOKENto.envEnsure token has
reposcope
Out of memory / slow indexing
Reduce
MAX_FILE_SIZE_KBin.envLimit
SUPPORTED_EXTENSIONSto only needed typesIncrease Docker memory limits
Embeddings API errors
Verify
LLM_API_KEYis correctCheck OpenAI account has credits
Try with Ollama for local embeddings
π Using with Ollama (Local LLM)
For completely local setup:
Install Ollama: https://ollama.ai
Pull models:
ollama pull qwen2.5-coder:7b ollama pull nomic-embed-textUpdate
.env:LLM_PROVIDER=ollama LLM_MODEL=qwen2.5-coder:7b LLM_BASE_URL=http://host.docker.internal:11434 EMBEDDING_MODEL=nomic-embed-textRestart server:
docker-compose restart
π Development
Adding New File Type Support
Edit src/code_parser.py and add patterns for your language:
PATTERNS = {
"your_language": [
r"pattern_to_match_functions",
r"pattern_to_match_classes",
]
}Customizing Recommendations
Edit the system prompt in src/recommendation_system.py:
def _get_system_prompt(self) -> str:
return """Your custom prompt here..."""π€ Contributing
Contributions welcome! Please feel free to submit issues and pull requests.
π Performance Stats
Production Tested on jolly-commerce/jolly-sections:
β 152 sections indexed (100% success rate)
β 0 errors during indexing
β 43 source files analyzed
β Average search score: 0.7+ (high relevance)
β No minified files indexed (smart filtering)
β Query time: 5-15 seconds
β Initial indexing: 2-3 minutes
Code Quality:
Only source files indexed (src/templates/)
Full code content extracted (not just names)
Semantic search with high accuracy
AI recommendations with reasoning
π License
MIT License - see LICENSE file for details
π Acknowledgments
Built with FastMCP
Powered by ChromaDB
Uses OpenAI Embeddings or Ollama
Production tested on jolly-commerce/jolly-sections
π Support
For issues and questions, please open a GitHub issue.
Happy Coding! π
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
This server cannot be deployed
Maintenance
Related MCP Connectors
Code intelligence for coding agents: semantic, AST, graph, and full-text search. 279+ languages.
Code intelligence for LLMs. Analyze, search, and retrieve code from any public git repository.
Connect AI assistants to GitHub - manage repos, issues, PRs, and workflows through natural language.
Connect AI assistants to your GitHub-hosted Obsidian vault to seamlessly access, search, and analyβ¦
Related MCP Servers
- AlicenseAqualityDmaintenanceAI-powered code assistant that provides advanced search and discovery capabilities across GitHub and NPM ecosystems, helping users understand code patterns, implementations, and connections between repositories.13966TypeScriptMIT
- AlicenseNot gradedqualityDmaintenanceEnables semantic code search across projects using AI embeddings to find code by meaning rather than just text matching. Provides fast intelligent search, symbol analysis, and code similarity detection with multi-language support.MIT
- AlicenseNot gradedqualityDmaintenanceEnables semantic code search across multiple repositories using natural language queries. Provides intelligent code discovery, symbol lookups, and cross-repo dependency analysis for AI coding agents.MIT
- AlicenseAqualityDmaintenanceProvides code repository indexing and semantic search capabilities, allowing natural language queries to find relevant code snippets with automatic incremental indexing and multi-language support.1360ISC