Code Index MCP
A server for code indexing, searching, and analysis, enabling LLMs to interact with code repositories.
Code Index MCP
Intelligent code indexing and analysis for Large Language Models
Transform how AI understands your codebase with advanced search, analysis, and navigation capabilities.
Overview
Code Index MCP is a Model Context Protocol server that bridges the gap between AI models and complex codebases. It provides intelligent indexing, advanced search capabilities, and detailed code analysis to help AI assistants understand and navigate your projects effectively.
Perfect for: Code review, refactoring, documentation generation, debugging assistance, and architectural analysis.
Quick Start
π Recommended Setup (Most Users)
The easiest way to get started with any MCP-compatible application:
Prerequisites: Python 3.10+ and uv
-
Add to your MCP configuration (e.g.,
claude_desktop_config.jsonor~/.claude.json):{ "mcpServers": { "code-index": { "command": "uvx", "args": ["code-index-mcp"] } } }Optional: append
--project-path /absolute/path/to/repoto theargsarray so the server initializes with that repository automatically (equivalent to callingset_project_pathafter startup). -
Restart your application β
uvxautomatically handles installation and execution -
Start using (give these prompts to your AI assistant):
Set the project path to /Users/dev/my-react-app Find all TypeScript files in this project Search for "authentication" functions Analyze the main App.tsx fileIf you launch with
--project-path, you can skip the first command above - the server already knows the project location.
Codex CLI Configuration
If you are using Anthropic's Codex CLI, add the server to ~/.codex/config.toml.
On Windows the file lives at C:\Users\<you>\.codex\config.toml:
[mcp_servers.code-index]
type = "stdio"
command = "uvx"
args = ["code-index-mcp"]
You can append
--project-path C:/absolute/path/to/repoto theargslist to set the project automatically on startup (same effect as running theset_project_pathtool).
On Windows, uvx needs the standard profile directories to be present.
Keep the environment override in the same block so the MCP starts reliably:
env = {
HOME = "C:\\Users\\<you>",
APPDATA = "C:\\Users\\<you>\\AppData\\Roaming",
LOCALAPPDATA = "C:\\Users\\<you>\\AppData\\Local",
SystemRoot = "C:\\Windows"
}
Linux and macOS already expose the required XDG paths and HOME, so you can usually omit the env
table there.
Add overrides only if you run the CLI inside a restricted container.
FastMCP & Discovery Manifests
- Run
fastmcp run fastmcp.jsonto launch the server via FastMCP with the correct source entrypoint and dependency metadata. Pass--project-path(or call theset_project_pathtool after startup) so the index boots against the right repository. - Serve or copy
.well-known/mcp.jsonto share a standards-compliant MCP manifest. Clients that support the.well-knownconvention (e.g., Claude Desktop, Codex CLI) can import this file directly instead of crafting configs manually. - Publish
.well-known/mcp.llmfeed.jsonwhen you want to expose the richer LLM Feed metadata. It references the samecode-indexserver definition plus documentation/source links, which helps registries present descriptions, tags, and capabilities automatically.
When sharing the manifests, remind consumers to supply --project-path (or to call
set_project_path) so the server indexes the intended repository.
Typical Use Cases
Code Review: "Find all places using the old API"
Refactoring Help: "Where is this function called?"
Learning Projects: "Show me the main components of this React project"
Debugging: "Search for all error handling related code"
Key Features
π Intelligent Search & Analysis
- Dual-Strategy Architecture: Specialized tree-sitter parsing for 7 core languages, fallback strategy for 50+ file types
- Direct Tree-sitter Integration: No regex fallbacks for specialized languages - fail fast with clear errors
- Advanced Search: Auto-detects and uses the best available tool (ugrep, ripgrep, ag, or grep)
- Universal File Support: Comprehensive coverage from advanced AST parsing to basic file indexing
- File Analysis: Deep insights into structure, imports, classes, methods, and complexity metrics after running
build_deep_index
ποΈ Multi-Language Support
- 7 Languages with Tree-sitter AST Parsing: Python, JavaScript, TypeScript, Java, Go, Objective-C, Zig
- 50+ File Types with Fallback Strategy: C/C++, Rust, Ruby, PHP, and all other programming languages
- Document & Config Files: Markdown, JSON, YAML, XML with appropriate handling
- Web Frontend: Vue, React, Svelte, HTML, CSS, SCSS
- Java Web & Build: JSP/Tag files (
.jsp,.jspx,.jspf,.tag,.tagx), Grails/GSP (.gsp), Gradle & Groovy builds (.gradle,.groovy),.properties, and Protocol Buffers (.proto) - Database: SQL variants, NoSQL, stored procedures, migrations
- Configuration: JSON, YAML, XML, Markdown
- View complete list
β‘ Real-time Monitoring & Auto-refresh
- File Watcher: Automatic index updates when files change
- Cross-platform: Native OS file system monitoring
- Smart Processing: Batches rapid changes to prevent excessive rebuilds
- Shallow Index Refresh: Watches file changes and keeps the file list current; run a deep rebuild when you need symbol metadata
β‘ Performance & Efficiency
- Tree-sitter AST Parsing: Native syntax parsing for accurate symbol extraction
- Persistent Caching: Stores indexes for lightning-fast subsequent access
- Smart Filtering: Intelligent exclusion of build directories and temporary files
- Memory Efficient: Optimized for large codebases
- Direct Dependencies: No fallback mechanisms - fail fast with clear error messages
Supported File Types
Languages with Specialized Tree-sitter Strategies:
- Python (
.py,.pyw) - Full AST analysis with class/method extraction and call tracking - JavaScript (
.js,.jsx,.mjs,.cjs) - ES6+ class and function parsing with tree-sitter - TypeScript (
.ts,.tsx) - Complete type-aware symbol extraction with interfaces - Java (
.java) - Full class hierarchy, method signatures, and call relationships - Go (
.go) - Struct methods, receiver types, and function analysis - Objective-C (
.m,.mm) - Class/instance method distinction with +/- notation - Zig (
.zig,.zon) - Function and struct parsing with tree-sitter AST
All Other Programming Languages: All other programming languages use the FallbackParsingStrategy which provides basic file indexing and metadata extraction. This includes:
- System & Low-Level: C/C++ (
.c,.cpp,.h,.hpp), Rust (.rs) - Object-Oriented: C# (
.cs), Kotlin (.kt), Scala (.scala), Swift (.swift) - Scripting & Dynamic: Ruby (
.rb), PHP (.php), Shell (.sh,.bash) - And 40+ more file types - All handled through the fallback strategy for basic indexing
Frameworks & Libraries:
- Vue (
.vue) - Svelte (
.svelte) - Astro (
.astro)
Styling:
- CSS (
.css,.scss,.less,.sass,.stylus,.styl) - HTML (
.html)
Templates:
- Handlebars (
.hbs,.handlebars) - EJS (
.ejs) - Pug (
.pug) - FreeMarker (
.ftl) - Mustache (
.mustache) - Liquid (
.liquid) - ERB (
.erb)
SQL Variants:
- Standard SQL (
.sql,.ddl,.dml) - Database-specific (
.mysql,.postgresql,.psql,.sqlite,.mssql,.oracle,.ora,.db2)
Database Objects:
- Procedures & Functions (
.proc,.procedure,.func,.function) - Views & Triggers (
.view,.trigger,.index)
Migration & Tools:
- Migration files (
.migration,.seed,.fixture,.schema) - Tool-specific (
.liquibase,.flyway)
NoSQL & Modern:
- Graph & Query (
.cql,.cypher,.sparql,.gql)
- Markdown (
.md,.mdx) - Configuration (
.json,.xml,.yml,.yaml,.properties)
π οΈ Development Setup
For contributing or local development:
-
Clone and install:
git clone https://github.com/johnhuang316/code-index-mcp.git cd code-index-mcp uv sync -
Configure for local development:
{ "mcpServers": { "code-index": { "command": "uv", "args": ["run", "code-index-mcp"] } } } -
Debug with MCP Inspector:
npx @modelcontextprotocol/inspector uv run code-index-mcp
If you prefer traditional pip management:
pip install code-index-mcp
Then configure:
{
"mcpServers": {
"code-index": {
"command": "code-index-mcp",
"args": []
}
}
}
Available Tools
ποΈ Project Management
| Tool | Description |
|---|---|
set_project_path | Initialize indexing for a project directory |
refresh_index | Rebuild the shallow file index after file changes |
build_deep_index | Generate the full symbol index used by deep analysis |
get_settings_info | View current project configuration and status |
Run build_deep_index when you need symbol-level data; the default shallow index powers quick file discovery.
π Search & Discovery
| Tool | Description |
|---|---|
search_code_advanced | Smart search with regex, fuzzy matching, file filtering, and paginated results (10 per page by default) |
find_files | Locate files using glob patterns (e.g., **/*.py) |
get_file_summary | Analyze file structure, functions, imports, and complexity (requires deep index) |
π Monitoring & Auto-refresh
| Tool | Description |
|---|---|
get_file_watcher_status | Check file watcher status and configuration |
configure_file_watcher | Enable/disable auto-refresh and configure settings |
π οΈ System & Maintenance
| Tool | Description |
|---|---|
create_temp_directory | Set up storage directory for index data |
check_temp_directory | Verify index storage location and permissions |
clear_settings | Reset all cached data and configurations |
refresh_search_tools | Re-detect available search tools (ugrep, ripgrep, etc.) |
Usage Examples
π― Quick Start Workflow
1. Initialize Your Project
Set the project path to /Users/dev/my-react-app
Automatically indexes your codebase and creates searchable cache
2. Explore Project Structure
Find all TypeScript component files in src/components
Uses: find_files with pattern src/components/**/*.tsx
3. Analyze Key Files
Give me a summary of src/api/userService.ts
Uses: get_file_summary to show functions, imports, and complexity
Tip: run build_deep_index first if you get a needs_deep_index response.
π Advanced Search Examples
Search for all function calls matching "get.*Data" using regex
Finds: getData(), getUserData(), getFormData(), etc.
Find authentication-related functions with fuzzy search for 'authUser'
Matches: authenticateUser, authUserToken, userAuthCheck, etc.
Search for "API_ENDPOINT" only in Python files
Uses: search_code_advanced with file_pattern: "*.py" (defaults to 10 matches; use max_results to expand or start_index to page)
Configure automatic index updates when files change
Uses: configure_file_watcher to enable/disable monitoring and set debounce timing
I added new components, please refresh the project index
Uses: refresh_index to update the searchable cache
Troubleshooting
π Auto-refresh Not Working
If automatic index updates aren't working when files change, try:
pip install watchdog(may resolve environment isolation issues)- Use manual refresh: Call the
refresh_indextool after making file changes - Check file watcher status: Use
get_file_watcher_statusto verify monitoring is active
Development & Contributing
π§ Building from Source
git clone https://github.com/johnhuang316/code-index-mcp.git
cd code-index-mcp
uv sync
uv run code-index-mcp
π Debugging
npx @modelcontextprotocol/inspector uvx code-index-mcp
π€ Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
π License
π Translations
Related Servers
Shallow Research Code Assistant
A multi-agent AI-powered research and code assistant. Requires external API keys for LLM providers, web search, and secure code execution.
Gemini MCP Tool
A server for integrating with the Google Gemini CLI to perform AI-powered tasks.
MCP Yeoman Server
Search for and run Yeoman generator templates programmatically.
MCP Router
A unified gateway for routing requests to multiple Model Context Protocol servers.
kintone
An MCP server for integrating with the kintone REST API. Supports CRUD operations, file management, comments, and status updates.
Swagger/Postman MCP Server
Ingests and serves Swagger/OpenAPI specifications and Postman collections as MCP tools. Requires a config.json for API and authentication setup.
vHAL MCP Server
Search Android Vehicle Hardware Abstraction Layer (vHAL) documentation and source code from a local repository clone.
MockLoop
An AI-native API testing platform for generating scenarios, executing tests, and analyzing results.
AvaloniaUI
Tools, resources, and guidance for building cross-platform applications with AvaloniaUI.
Remote MCP Server (Authless)
A remote MCP server deployable on Cloudflare Workers without authentication.