MCP server that tracks file descriptions across codebases, enabling AI agents to efficiently navigate and understand code through searchable summaries and token-aware overviews.
A production-ready Model Context Protocol (MCP) server that revolutionizes how AI agents navigate and understand codebases. Built for high-concurrency environments with advanced database resilience, the server provides instant access to intelligent descriptions, semantic search, and context-aware recommendations while maintaining 800+ writes/sec throughput.
The MCP Code Indexer solves a critical problem for AI agents working with large codebases: understanding code structure without repeatedly scanning files. Instead of reading every file, agents can:
Perfect for AI-powered code review, refactoring tools, documentation generation, and codebase analysis workflows.
Get started integrating MCP Code Indexer into your AI agent workflow:
# Install with Poetry
poetry add mcp-code-indexer
# Or with pip
pip install mcp-code-indexer
# Start the MCP server
mcp-code-indexer
# Connect your MCP client and start using tools
# See API Reference for complete tool documentation
Enable HTTP/REST API access for browser-based applications:
# Start HTTP server with authentication
mcp-code-indexer --http --auth-token "your-secret-token"
# Custom host and port
mcp-code-indexer --http --host 0.0.0.0 --port 8080
# CORS configuration for web apps
mcp-code-indexer --http --cors-origins "https://localhost:3000" "https://myapp.com"
π Complete HTTP API Reference β
Ask questions about your codebase using natural language:
# Set OpenRouter API key for Claude access
export OPENROUTER_API_KEY="your-openrouter-api-key"
# Simple questions about project architecture
mcp-code-indexer --ask "What does this project do?" my-project
# Enhanced analysis with file search
mcp-code-indexer --deepask "How is authentication implemented?" web-app
# JSON output for programmatic use
mcp-code-indexer --ask "List the main components" my-project --json
π€ Complete Q&A Interface Guide β
Deploy and configure the server for your team:
# Production deployment with custom settings
mcp-code-indexer \
--token-limit 64000 \
--db-path /data/mcp-index.db \
--cache-dir /var/cache/mcp \
--log-level INFO
# Check installation
mcp-code-indexer --version
New to MCP Code Indexer? Start here:
poetry add mcp-code-indexer
(or pip install mcp-code-indexer
)mcp-code-indexer --token-limit 32000
check_codebase_size
tool firstDevelopment Setup:
# Clone and setup for contributing
git clone https://github.com/fluffypony/mcp-code-indexer.git
cd mcp-code-indexer
# Install with Poetry (recommended)
poetry install
# Or install in development mode with pip
pip install -e .
# Run the server
mcp-code-indexer --token-limit 32000
π NEW Feature: Automated code indexing with AI-powered analysis! Keep your file descriptions synchronized automatically as your codebase evolves.
# Set your OpenRouter API key
export OPENROUTER_API_KEY="sk-or-v1-your-api-key-here"
# Test git hook functionality
mcp-code-indexer --githook
# Install post-commit hook
cp examples/git-hooks/post-commit .git/hooks/
chmod +x .git/hooks/post-commit
The git hook integration provides intelligent automation:
π‘ Zero Manual Work: Descriptions stay current without any effort
β‘ Performance: Only analyzes changed files, not entire codebase
π Reliability: Robust error handling ensures git operations never fail
ποΈ Configurable: Support for custom models and timeout settings
Learn More: See Git Hook Setup Guide for complete configuration options and troubleshooting.
Contributing to MCP Code Indexer? Follow these steps for a proper development environment:
# Setup development environment
git clone https://github.com/fluffypony/mcp-code-indexer.git
cd mcp-code-indexer
# Install with Poetry (recommended)
poetry install
# Or use pip with virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -e .[dev]
# Verify installation
python main.py --help
mcp-code-indexer --version
β οΈ Important: The editable install (pip install -e .
) is required for development. The project uses proper PyPI package structure with absolute imports like from mcp_code_indexer.database.database import DatabaseManager
. Without editable installation, you'll get ModuleNotFoundError
exceptions.
# Activate virtual environment
source venv/bin/activate
# Run the server directly
python main.py --token-limit 32000
# Or use the installed CLI command
mcp-code-indexer --token-limit 32000
# Run tests
python -m pytest tests/ -v
# Run with coverage
python -m pytest tests/ --cov=src --cov-report=html
# Format code
black src/ tests/
isort src/ tests/
# Type checking
mypy src/
The server provides 11 powerful MCP tools for intelligent codebase management. Whether you're an AI agent or human developer, these tools make navigating code effortless.
Tool | Purpose | When to Use |
---|---|---|
check_codebase_size | Get navigation recommendations | First tool to call for any project |
search_descriptions | Find files by functionality | When you need specific files |
get_codebase_overview | Project architectural summary | Understanding system design |
Tool | Purpose | Best For |
---|---|---|
get_file_description | Retrieve file summaries | Quick file understanding |
update_file_description | Store detailed file analysis | AI agents updating descriptions |
find_missing_descriptions | Scan for undocumented files | Maintenance and coverage |
Tool | Purpose | Use Case |
---|---|---|
get_all_descriptions | Complete project structure | Small-to-medium codebases |
get_word_frequency | Technical vocabulary analysis | Domain understanding |
update_codebase_overview | Create project documentation | Architecture documentation |
search_codebase_overview | Search in project overviews | Finding specific topics |
Tool | Purpose | For |
---|---|---|
check_database_health | Real-time performance monitoring | Production deployments |
π‘ Pro Tip: Always start with check_codebase_size
to get personalized recommendations for navigating your specific codebase.
π Complete API Documentation: View all 11 tools with examples β
Keep your codebase documentation automatically synchronized with automated analysis on every commit:
# Analyze current staged changes
mcp-code-indexer --githook
# Analyze a specific commit
mcp-code-indexer --githook abc123def
# Analyze using HEAD syntax
mcp-code-indexer --githook HEAD
mcp-code-indexer --githook HEAD~1
mcp-code-indexer --githook HEAD~3
# Analyze a commit range (perfect for rebases)
mcp-code-indexer --githook abc123 def456
mcp-code-indexer --githook HEAD~5 HEAD
π― Perfect for:
See the Git Hook Setup Guide for complete installation instructions including post-commit, post-merge, and post-rewrite hooks.
Comprehensive documentation organized by user journey and expertise level.
Guide | Purpose | Time Investment |
---|---|---|
Quick Start | Install and run your first server | 2 minutes |
API Reference | Master all 11 MCP tools | 15 minutes |
HTTP API Reference | REST API for web applications | 10 minutes |
Q&A Interface | AI-powered codebase analysis | 8 minutes |
Git Hook Setup | Automate your workflow | 5 minutes |
Guide | Focus | Best For |
---|---|---|
CLI Reference | Complete command documentation | All users |
Administrative Commands | Project & database management | System administrators |
Configuration Guide | Production setup & tuning | System administrators |
Performance Tuning | High-concurrency optimization | DevOps teams |
Monitoring & Diagnostics | Production monitoring | Operations teams |
Guide | Depth | For |
---|---|---|
Architecture Overview | System design deep dive | Developers & architects |
Database Resilience | Advanced error handling | Senior developers |
Contributing Guide | Development workflow | Contributors |
π Reading Paths:
Tested with codebases up to 10,000 files:
# Production setup with custom limits
mcp-code-indexer \
--token-limit 50000 \
--db-path /data/mcp-index.db \
--cache-dir /tmp/mcp-cache \
--log-level INFO
# Enable structured logging
export MCP_LOG_FORMAT=json
mcp-code-indexer
Configure advanced database resilience features for high-concurrency environments:
# High-performance production deployment
mcp-code-indexer \
--token-limit 64000 \
--db-path /data/mcp-index.db \
--cache-dir /var/cache/mcp \
--log-level INFO \
--db-pool-size 5 \
--db-retry-count 7 \
--db-timeout 15.0 \
--enable-wal-mode \
--health-check-interval 20.0
# Environment variable configuration
export DB_POOL_SIZE=5
export DB_RETRY_COUNT=7
export DB_TIMEOUT=15.0
export DB_WAL_MODE=true
export DB_HEALTH_CHECK_INTERVAL=20.0
mcp-code-indexer --token-limit 64000
Parameter | Default | Description | Use Case |
---|---|---|---|
--db-pool-size | 3 | Database connection pool size | Higher for more concurrent clients |
--db-retry-count | 5 | Max retry attempts for failed operations | Increase for unstable environments |
--db-timeout | 10.0 | Transaction timeout (seconds) | Increase for large operations |
--enable-wal-mode | true | Enable WAL mode for concurrency | Always enable for production |
--health-check-interval | 30.0 | Health monitoring interval (seconds) | Lower for faster issue detection |
π‘ Performance Tip: For environments with 10+ concurrent clients, use --db-pool-size 5
and --health-check-interval 15.0
for optimal throughput.
# Example: AI agent using MCP tools
async def analyze_codebase(project_path):
# Check if codebase is large
size_info = await mcp_client.call_tool("check_codebase_size", {
"projectName": "my-project",
"folderPath": project_path
})
if size_info["isLarge"]:
# Use search for large codebases
results = await mcp_client.call_tool("search_descriptions", {
"projectName": "my-project",
"folderPath": project_path,
"query": "authentication logic"
})
else:
# Get full overview for smaller projects
overview = await mcp_client.call_tool("get_codebase_overview", {
"projectName": "my-project",
"folderPath": project_path
})
# Example: GitHub Actions integration
- name: Update Code Descriptions
run: |
python -c "
import asyncio
from mcp_client import MCPClient
async def update_descriptions():
client = MCPClient('mcp-code-indexer')
# Find files without descriptions
missing = await client.call_tool('find_missing_descriptions', {
'projectName': '${{ github.repository }}',
'folderPath': '.'
})
# Process with AI and update...
asyncio.run(update_descriptions())
"
# Install with test dependencies using Poetry
poetry install --with test
# Or with pip
pip install mcp-code-indexer[test]
# Run full test suite
python -m pytest tests/ -v
# Run with coverage
python -m pytest tests/ --cov=src --cov-report=html
# Run performance tests
python -m pytest tests/ -m performance
# Run integration tests only
python -m pytest tests/integration/ -v
The server provides structured JSON logs for monitoring:
{
"timestamp": "2024-01-15T10:30:00Z",
"level": "INFO",
"message": "Tool search_descriptions completed",
"tool_usage": {
"tool_name": "search_descriptions",
"success": true,
"duration_seconds": 0.045,
"result_size": 1247
}
}
mcp-code-indexer [OPTIONS]
Options:
--token-limit INT Maximum tokens before recommending search (default: 32000)
--db-path PATH SQLite database path (default: ~/.mcp-code-index/tracker.db)
--cache-dir PATH Cache directory path (default: ~/.mcp-code-index/cache)
--log-level LEVEL Logging level: DEBUG|INFO|WARNING|ERROR|CRITICAL (default: INFO)
mcp-code-indexer --githook [OPTIONS]
# Automated analysis of git changes using OpenRouter API
# Requires: OPENROUTER_API_KEY environment variable
# Start HTTP/REST API server
mcp-code-indexer --http [OPTIONS]
# HTTP server with authentication
mcp-code-indexer --http --auth-token "your-secret-token"
# Custom host and port configuration
mcp-code-indexer --http --host 0.0.0.0 --port 8080
# Simple AI-powered questions (requires OPENROUTER_API_KEY)
mcp-code-indexer --ask "What does this project do?" PROJECT_NAME
# Enhanced analysis with file search
mcp-code-indexer --deepask "How is authentication implemented?" PROJECT_NAME
# JSON output for programmatic use
mcp-code-indexer --ask "Question" PROJECT_NAME --json
# List all projects
mcp-code-indexer --getprojects
# Execute MCP tool directly
mcp-code-indexer --runcommand '{"method": "tools/call", "params": {...}}'
# Export descriptions for a project
mcp-code-indexer --dumpdescriptions PROJECT_ID
# Create local database for a project
mcp-code-indexer --makelocal /path/to/project
# Generate project documentation map
mcp-code-indexer --map PROJECT_NAME
Common issues and instant solutions:
Issue | Quick Fix | Learn More |
---|---|---|
"No module named 'mcp_code_indexer'" | pip install -e . (for development) | Contributing Guide |
"OPENROUTER_API_KEY not found" | export OPENROUTER_API_KEY="your-key" | Git Hook Setup |
"Database is locked" | Enable WAL mode: --enable-wal-mode | CLI Reference |
"Large codebase - use search" | Normal for 200+ files. Use search_descriptions | API Reference |
HTTP authentication failed | Check --auth-token configuration | HTTP API Reference |
Q&A commands not working | Set OPENROUTER_API_KEY environment variable | Q&A Interface |
High memory usage | Reduce token limit: --token-limit 10000 | Configuration Guide |
π‘ Not finding your issue? Check the complete troubleshooting guides in our documentation.
Ready to supercharge your AI agents with intelligent codebase navigation?
π New to MCP Code Indexer?
π₯ Setting up for a team?
π§ Want to contribute?
π Learning Resources:
We welcome contributions! See our Contributing Guide for:
MIT License - see LICENSE for details.
Transform how your AI agents understand code! π
π― New User? Get started in 2 minutes
π¨βπ» Developer? Explore the complete API
π§ Production? Deploy with confidence
fluffypony/mcp-code-indexer
June 11, 2025
July 7, 2025
Python