code index mcp
A Model Context Protocol (MCP) server that helps large language models index, search, and analyze code repositories with minimal setup
A Model Context Protocol (MCP) server that helps large language models index, search, and analyze code repositories with minimal setup
Code Index MCP is a Model Context Protocol server that enables large language models (LLMs) to index, search, and analyze code in project directories.
This project uses uv for environment management and dependency installation.
# Windows
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
# macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
3. Getting the code:
# Clone the repository
git clone https://github.com/your-username/code-index-mcp.git
# Run directly with uv - no additional dependency installation needed
uv run run.py
UV will automatically handle all dependency installations based on the project's configuration.
You can easily integrate Code Index MCP with Claude Desktop:
Find or create the Claude Desktop configuration file:
Windows: %APPDATA%Claudeclaude_desktop_config.json
~/Library/Application Support/Claude/claude_desktop_config.json
For Windows:
{
"mcpServers": {
"code-indexer": {
"command": "uv",
"args": [
"--directory",
"C:Usersusernamepathtocode-index-mcp",
"run",
"run.py"
]
}
}
}
For macOS/Linux:
{
"mcpServers": {
"code-indexer": {
"command": "uv",
"args": [
"--directory",
"/home/username/path/to/code-index-mcp",
"run",
"run.py"
]
}
}
}
Note: The --directory
option is important as it ensures uv runs in the correct project directory and can properly load all dependencies.
4. Restart Claude Desktop to use Code Indexer for analyzing code projects
No manual dependency installation is required - UV will automatically handle all dependencies when running the server.
Set Project Path (required first step):
When using for the first time, you must set the project path to analyze
Code Search:
Search for specific keywords or patterns: "Search for 'function name' in the project"
File Analysis:
Analyze specific files: "Analyze the file src/main.py"
Project Navigation:
View project structure: "Show me the structure of this project"
All index and settings data are stored in the .code_indexer
folder within the project directory:
config.json
: Project configuration informationfile_index.pickle
: File index datacontent_cache.pickle
: File content cacheThis ensures that the entire project does not need to be re-indexed each time it's used.
Code Index MCP uses UV for dependency management, which provides several advantages:
The following file types are currently supported for indexing and analysis:
.code_indexer
folder includes a .gitignore
file to prevent indexing data from being committedContributions via issues or pull requests to add new features or fix bugs are welcome.
For documentation in Chinese, please see README_zh.md.