Python Codebase Analysis RAG System
Used to run Weaviate, a vector database for storing code analysis data via Docker Compose
Uses .env files for configuration including API keys, LLM settings, and database connection details
Leverages Google's Gemini models for generating embeddings and natural language descriptions/answers about code
Generates MermaidJS call graphs based on relationships between code elements in the analyzed codebase
Analyzes Python codebases using Abstract Syntax Trees to extract functions, classes, and other code elements
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Python Codebase Analysis RAG Systemfind all functions that handle user authentication"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
CodebaseMCP
MCP server that scans Python codebases with AST, stores them in Weaviate, and answers questions via pluggable LLM providers (Gemini, OpenAI).
Quickstart
docker-compose up -d
pip install -r requirements.txt
echo "LLM_API_KEY=your_key" >> .env
echo "GENERATE_LLM_DESCRIPTIONS=true" >> .env
python src/code_analysis_mcp/mcp_server.pyCall scan_codebase from any MCP client with a project path.
Related MCP server: code2prompt-mcp
Features
AST scanning — functions, classes, imports, calls, variables, decorators, signatures, docstrings, cross-references.
Hybrid search — Weaviate vector + BM25 keyword search. Unenriched elements are still findable by name/code content.
DAG-ordered enrichment — callees enriched before callers, so refinement sees real callee descriptions.
RAG Q&A —
ask_questionretrieves relevant code via hybrid search and synthesises answers with an LLM.File watching — rescans and re-enriches on file changes, DAG-ordered.
Worker pool — enrichment uses
LLM_CONCURRENCYworkers with a queue instead of N asyncio tasks.Codebase dependencies — relationships between codebases; queries span dependencies in parallel.
Call graph visualization — MermaidJS from stored cross-references.
Configuration
LLM_PROVIDER=gemini # or "openai"
LLM_API_KEY= # generic key for any provider
GENERATE_LLM_DESCRIPTIONS=true # enables enrichment, refinement, RAG
LLM_CONCURRENCY=5 # worker pool size
GENERATION_MODEL_NAME=models/gemini-3.1-flash-lite-preview
EMBEDDING_MODEL_NAME=models/gemini-embedding-2
WEAVIATE_HOST=localhost # these 3 env vars are now functional
WEAVIATE_PORT=8080
WEAVIATE_GRPC_PORT=50051
SEMANTIC_SEARCH_LIMIT=10
SEMANTIC_SEARCH_DISTANCE=0.7
WATCHER_POLLING_INTERVAL=5Architecture
src/code_analysis_mcp/
├── llm/ # Pluggable LLM providers
│ ├── base.py # ABC: implement generate() + embed()
│ ├── gemini.py # GeminiProvider
│ ├── openai.py # OpenAIProvider
│ └── factory.py # Factory + singleton, reads LLM_PROVIDER
├── code_scanner.py # AST parsing, element extraction, upload
├── weaviate_client.py # Schema, CRUD, hybrid search
├── rag.py # RAG Q&A, description refinement, summaries
├── tasks.py # Enrichment workers, DAG sort, summary (extracted from mcp_server)
├── mcp_server.py # FastMCP server, tools, watcher, lifespan
├── visualization.py # MermaidJS call graphs
└── utils.py # Shared helpersLLM provider system
New providers implement the LLMProvider ABC in llm/base.py and register in llm/factory.py. Key selected via LLM_API_KEY (generic) or GEMINI_API_KEY / OPENAI_API_KEY (fallback).
Data model
CodeFile (multi-tenant) — file paths, modification times.
CodeElement (multi-tenant) — every parsed element with optional vector.
CodebaseRegistry (global) — codebase metadata, status, dependencies.
Tenant ID = codebase name. Cross-codebase queries fan out across dependency tenants.
MCP Tools
Tool | Description |
| Scan, upload, DAG-enrich, summarise, start watcher |
| Registered codebases with status |
| Set active context (stops prior watcher) |
| Remove codebase + tenant + registry entry |
| Search by name, file, type across active + dependencies |
| Full properties for a UUID |
| Find elements related to a code snippet |
| RAG (with optional |
| Queue enrichment (DAG-ordered, worker pool) |
| Re-run summary without rescanning |
| Manual watcher control |
| Dependency graph management |
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Appeared in Searches
Latest Blog Posts
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/shervinemp/CodebaseMCP'
If you have feedback or need assistance with the MCP directory API, please join our Discord server