Skip to main content
Glama
code-index-mcp

code-index-mcp

by johnhuang316

代码索引 MCP

MCP 服务器 Python执照

用于代码索引、搜索和分析的模型上下文协议服务器。

什么是代码索引 MCP?

代码索引 MCP 是一款专用的 MCP 服务器,提供智能代码索引和分析功能。它支持大型语言模型与您的代码存储库进行交互,从而提供实时洞察并导航复杂的代码库。

该服务器与模型上下文协议(MCP) 集成,这是 AI 模型与外部工具和数据源交互的标准化方式。

Related MCP server: @lex-tools/codebase-context-dumper

主要特点

  • 项目索引:递归扫描目录以构建可搜索的代码文件索引

  • 代码搜索:查找代码库中的模式、函数定义和引用

  • 文件分析:获取有关文件结构、导入和复杂性的详细信息

  • 智能过滤:自动忽略构建目录、依赖项和非代码文件

  • 持久存储:缓存索引以提高跨会话的性能

支持的文件类型

该服务器支持多种编程语言和文件扩展名,包括:

  • Python(.py)

  • JavaScript/TypeScript(.js、.ts、.jsx、.tsx)

  • Java(.java)

  • C/C++(.c、.cpp、.h、.hpp)

  • C#(.cs)

  • 前往(.go)

  • Ruby(.rb)

  • PHP(.php)

  • Swift(.swift)

  • Kotlin (.kt)

  • Rust(.rs)

  • Scala(.scala)

  • Shell 脚本(.sh、.bash)

  • Web 文件(.html、.css、.scss)

  • 文档/配置(.md、.json、.xml、.yml、.yaml)

安装

先决条件

  • Python 3.8 或更高版本

  • uv包管理器(推荐)

使用 uvx(推荐)

安装和使用 code-index-mcp 最简单的方法是使用 uvx:

uvx code-index-mcp

使用 pip

或者,您可以通过 pip 安装:

pip install code-index-mcp

安装后,您可以将其作为模块运行:

python -m code_index_mcp

与 Claude Desktop 集成

将其添加到您的 Claude 设置( ~/Library/Application Support/Claude/claude_desktop_config.json ):

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

添加配置后,重新启动 Claude Desktop,Code Index MCP 工具即可使用。

可用工具

核心工具

  • set_project_path :设置索引的基本项目路径。

  • search_code :在索引文件中搜索代码匹配。

  • find_files :在项目中查找与给定模式匹配的文件。

  • get_file_summary :获取特定文件的摘要,包括行数、函数、导入等。

  • refresh_index :刷新项目索引。

  • get_settings_info :获取有关项目设置的信息。

实用工具

  • create_temp_directory :创建用于存储索引数据的临时目录。

  • check_temp_directory :检查用于存储索引数据的临时目录。

  • clear_settings :清除所有设置和缓存数据。

Claude 的示例用法

以下是一些如何使用 Claude 代码索引 MCP 的示例:

设置项目路径

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

搜索代码模式

Search the code for all occurrences of "def process_data" in Python files

获取文件摘要

Give me a summary of the main.py file in the project

查找特定类型的所有文件

Find all JavaScript files in the project

发展

从源代码构建

  1. 克隆存储库:

git clone https://github.com/username/code-index-mcp.git
cd code-index-mcp
  1. 安装依赖项:

uv sync
  1. 在本地运行服务器:

uv run code_index_mcp

调试

您可以使用 MCP 检查器来调试服务器:

npx @modelcontextprotocol/inspector uvx code-index-mcp

执照

MIT 许可证

贡献

欢迎贡献代码!欢迎提交 Pull 请求。

语言

Available Tools

14 tools
build_deep_indexA
Build the deep index (full symbol extraction) for the current project.

This performs a complete re-index and loads it into memory.
Uses parallel processing by default. For large codebases (3000+ files),
tuning max_workers can significantly improve build times.

Args:
    max_workers: Maximum number of parallel workers for file processing.
        Defaults to min(4, cpu_count) when not specified.
        Increase for I/O-bound workloads on machines with many cores.
    timeout: Parallel build timeout in seconds. When not specified,
        scales dynamically based on file count (0.5s per file,
        min 30s, max 600s).

Inputs: max_workers, timeout. Returns: result

check_temp_directoryA

Check the temporary directory used for storing index data.

Inputs: no named parameters. Returns: object

clear_settingsB

Clear all settings and cached data.

Inputs: no named parameters. Returns: result

configure_file_watcherA

Configure file watcher service settings.

Args:
    enabled: Whether to enable file watcher
    debounce_seconds: Debounce time in seconds before triggering rebuild
    additional_exclude_patterns: Additional directory/file patterns to exclude
    observer_type: Observer backend to use. Options:
        - "auto" (default): platform default observer
        - "kqueue": Force kqueue observer (macOS/BSD)
        - "fsevents": Force FSEvents observer (macOS only, has known reliability issues)
        - "polling": Cross-platform polling fallback (slower but most compatible)

Inputs: enabled, debounce_seconds, additional_exclude_patterns, observer_type. Returns: result

create_temp_directoryA

Create the temporary directory used for storing index data.

Inputs: no named parameters. Returns: object

find_filesA

Find files matching glob pattern using in-memory index. Supports path patterns (.py, test_.js) and filename-only matching (README.md).

Inputs: pattern (required). Returns: result

get_file_summaryB
Get a summary of a specific file, including:
- Line count
- Function/class definitions (for supported languages)
- Import statements
- Basic complexity metrics

Inputs: file_path (required). Returns: object

get_file_watcher_statusA

Get file watcher service status and statistics.

Inputs: no named parameters. Returns: object

get_settings_infoB

Get information about the project settings.

Inputs: no named parameters. Returns: object

get_symbol_bodyA
Get the source code body of a specific symbol (function, method, or class).

This tool retrieves only the code for the specified symbol, enabling efficient
context usage by avoiding loading entire files.

Args:
    file_path: Path to the file containing the symbol
    symbol_name: Name of the symbol to retrieve (e.g., "process_data", "MyClass.my_method")

Returns:
    Dictionary containing:
    - status: "success" or "error"
    - symbol_name: Name of the symbol
    - type: Type of symbol (function, method, class)
    - line: Start line number
    - end_line: End line number
    - code: The actual source code
    - signature: Function/method signature (if available)
    - docstring: Documentation string (if available)
    - called_by: List of symbols that call this symbol

Inputs: file_path (required), symbol_name (required). Returns: object

refresh_indexA

Manually rebuild the project file index. Use after git operations or when index seems stale.

Inputs: no named parameters. Returns: result

refresh_search_toolsA

Manually re-detect the available command-line search tools on the system. This is useful if you have installed a new tool (like ripgrep) after starting the server.

Inputs: no named parameters. Returns: result

search_code_advancedA

Search for code pattern with pagination. Auto-selects best search tool (ugrep/ripgrep/ag/grep). Supports glob file_pattern (e.g., "*.py"), explicit regex mode, and fuzzy matching (ugrep only). Regex matching requires passing regex=True and may require an external search tool.

Inputs: pattern (required), case_sensitive, context_lines, file_pattern, +4 more. Returns: object

set_project_pathC

Set the base project path for indexing.

Inputs: path (required). Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 14 tools

    Disambiguation5/5

    Each tool targets a distinct action: index building, file watching, settings management, searching, etc. Overlap is minimal and descriptions clarify the differences.

    Naming Consistency5/5

    All tool names use a consistent verb_noun snake_case pattern (e.g., build_deep_index, check_temp_directory, get_file_summary). No mixing of conventions.

    Tool Count5/5

    14 tools cover indexing, searching, file details, symbol retrieval, settings, and utilities. This is well-scoped for a code index server, neither sparse nor excessive.

    Completeness4/5

    Covers core operations: index build/refresh, file and code search, symbol body retrieval, settings, file watcher. Minor gaps like listing symbols or index statistics exist but do not hinder primary use.

    Maintenance

    ActivityInactive
    ResponsivenessLimited data

    Related MCP Connectors

    Related MCP Servers