代码索引搜索服务

一个用于代码索引和搜索的MCP服务器,支持结构化和语义化两种管道处理方式,提供混合搜索功能。

  • by Avik-creator
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 Avik-creator/code-index-mcp

使用说明

代码索引器MCP服务器

MCP服务器,用于索引和搜索代码,有两个管道:

  • 结构管道:AST->符号/引用/调用图
  • 语义流水线:块->嵌入->向量搜索

建筑

Git Repository
  -> File Discovery + Filters
  -> AST Pipeline (structure) -> Symbol Graph (SQLite)
  -> Semantic Pipeline (meaning) -> Embeddings (Chroma)
  -> Query Engine
  -> MCP Server

关键行为

  • 混合搜索:
    • 语义搜索优先
    • 回退到CLI文本搜索(rg -> ug -> grep)
    • 回退到SQLite块关键字搜索
  • 存储库标识符支持:
    • 工具接受散列 repo_id 和存储库 name
  • 观察者控制:
    • 通过MCP工具运行时状态/配置
  • 默认忽略规则跳过生成/供应商/构建/缓存工件(node_modules, .git, .next、锁文件等)

安装

pip install -e .

MCP配置(推荐)

使用命令名 code-index-mcp.

已发布/安装的软件包:

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

本地仓库(不发布):

{
  "mcpServers": {
    "code-index": {
      "command": "uvx",
      "args": ["--from", "/absolute/path/to/code-indexer", "code-index-mcp"]
    }
  }
}

可用工具

  • index_repository(path, name?)
  • search_code(query, repo_id?, top_k?)
  • find_symbol(name, repo_id?)
  • find_references(symbol_id)
  • get_call_graph(symbol_id, depth?)
  • get_dependencies(file_path, repo_id?)
  • get_file_context(file_path, repo_id?)
  • list_repositories()
  • delete_repository(repo_id)
  • get_file_watcher_status()
  • configure_file_watcher(enabled?, debounce_ms?)

使用说明

  • 对于 repo_id,您可以通过:
    • 实际哈希ID(例如 3c434d2a8c50801a)
    • 存储库名称(例如 mcp-memory-cloudflare)
  • 对于语义搜索缺失的文本密集型查询, search_code 现在返回grep风格的回退匹配。

发展

pip install -e ".[dev]"
pytest

许可证

麻省理工学院