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
  • Fuzzy Search: Native fuzzy matching with ugrep, or safe fuzzy patterns for other tools
  • File Analysis: Get detailed insights about file structure, imports, and complexity
  • 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)
  • 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.8+ 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: Enhanced search using external tools (ugrep/ripgrep/ag/grep) with 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 within Specific Files

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

(The assistant would use the search_code 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.1.tar.gz (25.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.1-py3-none-any.whl (29.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: code_index_mcp-0.4.1.tar.gz
  • Upload date:
  • Size: 25.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.1.tar.gz
Algorithm Hash digest
SHA256 33b92dbdc8e3e54dc3ac7a8761bd05a34cd10188a26b6a32e54daff708385b98
MD5 adbbe79e9af201fe91b8285b67b81e45
BLAKE2b-256 df5143c6f72ffbff19c3a7e5fdbf62879b99474c83b8691a705c18e76426bcb8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: code_index_mcp-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 29.1 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d9418724fea49c58e8e4700ace5b74364959c8b3cdd3a04390e09fbc69dda3cd
MD5 d7fb63de69b1655c4046e835e767d5bd
BLAKE2b-256 295d8cd83ee93e018a1cf1c08751038c02fba30254796d70f10c808940b080c6

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