Skip to main content

Code indexing and analysis tools for LLMs using MCP

Project description

Code Index MCP

MCP Server Python License

A Model Context Protocol server for code indexing, searching, and analysis.

code-index-mcp MCP server

What is Code Index MCP?

Code Index MCP is a specialized MCP server that provides intelligent code indexing and analysis capabilities. It enables Large Language Models to interact with your code repositories, offering real-time insights and navigation through complex codebases.

This server integrates with the Model Context Protocol (MCP), a standardized way for AI models to interact with external tools and data sources.

Key Features

  • Project Indexing: Recursively scans directories to build a searchable index of code files
  • Advanced Search: Intelligent search with automatic detection of ugrep, ripgrep, ag, or grep for enhanced performance
  • Regex Search: Full regex pattern matching with safety validation to prevent ReDoS attacks
  • Fuzzy Search: Native fuzzy matching with ugrep, or word boundary patterns for other tools
  • File Analysis: Get detailed insights about file structure, imports, classes, methods, and complexity
  • Java Support: Comprehensive analysis including packages, classes, interfaces, enums, and methods
  • Objective-C Support: Full analysis including interfaces, implementations, methods, properties, protocols, and categories
  • Python/JavaScript Support: Functions, classes, and import analysis
  • Smart Filtering: Automatically ignores build directories, dependencies, and non-code files
  • Persistent Storage: Caches indexes for improved performance across sessions
  • Lazy Loading: Search tools are detected only when needed for optimal startup performance

Supported File Types

The server supports multiple programming languages and file extensions including:

  • Python (.py)
  • JavaScript/TypeScript (.js, .ts, .jsx, .tsx, .mjs, .cjs)
  • Frontend Frameworks (.vue, .svelte, .astro)
  • Java (.java)
  • C/C++ (.c, .cpp, .h, .hpp)
  • C# (.cs)
  • Go (.go)
  • Ruby (.rb)
  • PHP (.php)
  • Swift (.swift)
  • Kotlin (.kt)
  • Rust (.rs)
  • Scala (.scala)
  • Shell scripts (.sh, .bash)
  • Zig (.zig)
  • Objective-C/Objective-C++ (.m, .mm)
  • Web files (.html, .css, .scss, .less, .sass, .stylus, .styl)
  • Template engines (.hbs, .handlebars, .ejs, .pug)
  • Database & SQL:
    • SQL files (.sql, .ddl, .dml)
    • Database-specific (.mysql, .postgresql, .psql, .sqlite, .mssql, .oracle, .ora, .db2)
    • Database objects (.proc, .procedure, .func, .function, .view, .trigger, .index)
    • Migration & tools (.migration, .seed, .fixture, .schema, .liquibase, .flyway)
    • NoSQL & modern (.cql, .cypher, .sparql, .gql)
  • Documentation/Config (.md, .mdx, .json, .xml, .yml, .yaml)

Setup and Integration

There are several ways to set up and use Code Index MCP, depending on your needs.

For General Use with Host Applications (Recommended)

This is the easiest and most common way to use the server. It's designed for users who want to use Code Index MCP within an AI application like Claude Desktop.

  1. Prerequisite: Make sure you have Python 3.10+ and uv installed.

  2. Configure the Host App: Add the following to your host application's MCP configuration file.

    Claude Desktop -> claude_desktop_config.json

    Claude Code -> ~/.claude.json. There is one mcpServers for each project and one global

    {
      "mcpServers": {
        "code-index": {
          "command": "uvx",
          "args": [
            "code-index-mcp"
          ]
        }
      }
    }
    
  3. Restart the Host App: After adding the configuration, restart the application. The uvx command will automatically handle the installation and execution of the code-index-mcp server in the background.

For Local Development

If you want to contribute to the development of this project, follow these steps:

  1. Clone the repository:

    git clone https://github.com/johnhuang316/code-index-mcp.git
    cd code-index-mcp
    
  2. Install dependencies using uv:

    uv sync
    
  3. Configure Your Host App for Local Development: To make your host application (e.g., Claude Desktop) use your local source code, update its configuration file to execute the server via uv run. This ensures any changes you make to the code are reflected immediately when the host app starts the server.

    {
      "mcpServers": {
        "code-index": {
          "command": "uv",
          "args": [
            "run",
            "code_index_mcp"
          ]
        }
      }
    }
    
  4. Debug with the MCP Inspector: To debug your local server, you also need to tell the inspector to use uv run.

    npx @modelcontextprotocol/inspector uv run code_index_mcp
    

Manual Installation via pip (Alternative)

If you prefer to manage your Python packages manually with pip, you can install the server directly.

  1. Install the package:

    pip install code-index-mcp
    
  2. Configure the Host App: You will need to manually update your host application's MCP configuration to point to the installed script. Replace "command": "uvx" with "command": "code-index-mcp".

    {
      "mcpServers": {
        "code-index": {
          "command": "code-index-mcp",
          "args": []
        }
      }
    }
    

Available Tools

Core Tools

  • set_project_path: Sets the base project path for indexing.
  • search_code_advanced: Enhanced search using external tools (ugrep/ripgrep/ag/grep) with regex and fuzzy matching support.
  • find_files: Finds files in the project matching a given pattern.
  • get_file_summary: Gets a summary of a specific file, including line count, functions, imports, etc.
  • refresh_index: Refreshes the project index.
  • get_settings_info: Gets information about the project settings.

Utility Tools

  • create_temp_directory: Creates the temporary directory used for storing index data.
  • check_temp_directory: Checks the temporary directory used for storing index data.
  • clear_settings: Clears all settings and cached data.
  • refresh_search_tools: Manually re-detect available command-line search tools (e.g., ripgrep).

Common Workflows and Examples

Here’s a typical workflow for using Code Index MCP with an AI assistant like Claude.

1. Set Project Path & Initial Indexing

This is the first and most important step. When you set the project path, the server automatically creates a file index for the first time or loads a previously cached one.

Example Prompt:

Please set the project path to C:\Users\username\projects\my-react-app

2. Refresh the Index (When Needed)

If you make significant changes to your project files after the initial setup, you can manually refresh the index to ensure all tools are working with the latest information.

Example Prompt:

I've just added a few new components, please refresh the project index.

(The assistant would use the refresh_index tool)

3. Explore the Project Structure

Once the index is ready, you can find files using patterns (globs) to understand the codebase and locate relevant files.

Example Prompt:

Find all TypeScript component files in the 'src/components' directory.

(The assistant would use the find_files tool with a pattern like src/components/**/*.tsx)

4. Analyze a Specific File

Before diving into the full content of a file, you can get a quick summary of its structure, including functions, classes, and imports.

Example Prompt:

Can you give me a summary of the 'src/api/userService.ts' file?

(The assistant would use the get_file_summary tool)

5. Search for Code

With an up-to-date index, you can search for code snippets, function names, or any text pattern to find where specific logic is implemented.

Example: Simple Search

Search for all occurrences of the "processData" function.

Example: Search with Fuzzy Matching

I'm looking for a function related to user authentication, it might be named 'authUser', 'authenticateUser', or something similar. Can you do a fuzzy search for 'authUser'?

Example: Search with Regular Expressions

Search for all function calls that match the pattern "get.*Data" using regex.

Example: Search within Specific Files

Search for the string "API_ENDPOINT" only in Python files.

(The assistant would use the search_code_advanced tool with the file_pattern parameter set to *.py)

Development

Building from Source

  1. Clone the repository:
git clone https://github.com/username/code-index-mcp.git
cd code-index-mcp
  1. Install dependencies:
uv sync
  1. Run the server locally:
uv run code_index_mcp

Debugging

You can use the MCP inspector to debug the server:

npx @modelcontextprotocol/inspector uvx code-index-mcp

License

MIT License

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Languages

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

code_index_mcp-0.4.2.tar.gz (30.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

code_index_mcp-0.4.2-py3-none-any.whl (37.9 kB view details)

Uploaded Python 3

File details

Details for the file code_index_mcp-0.4.2.tar.gz.

File metadata

  • Download URL: code_index_mcp-0.4.2.tar.gz
  • Upload date:
  • Size: 30.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for code_index_mcp-0.4.2.tar.gz
Algorithm Hash digest
SHA256 97228d04e468013d851fc7463738f0cbc9b212671d38829844cd62e8d7508c0a
MD5 5c2e5f765cd05ebaf8066e488dbb4cf2
BLAKE2b-256 db6b3337aac574092420ea0efc8be165455a5ae2ca91c5e351b9f039c61e3e40

See more details on using hashes here.

File details

Details for the file code_index_mcp-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: code_index_mcp-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 37.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for code_index_mcp-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8222a0b71c76c5ff1a50532c9e53fcd28d693f92c1039cfe75f013618c9cf71f
MD5 ab68c0426e434577e68ee76cd2485d4c
BLAKE2b-256 5e2ab7c7d1d89852dc5424c6bd06a884c08083229e64f715b2a29139a72bb6ec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page