代码索引 MCP
用于代码索引、搜索和分析的模型上下文协议服务器。
什么是代码索引 MCP?
代码索引 MCP 是一款专用的 MCP 服务器,提供智能代码索引和分析功能。它支持大型语言模型与您的代码存储库进行交互,从而提供实时洞察并导航复杂的代码库。
该服务器与模型上下文协议(MCP) 集成,这是 AI 模型与外部工具和数据源交互的标准化方式。
主要特点
- 项目索引:递归扫描目录以构建可搜索的代码文件索引
- 代码搜索:查找代码库中的模式、函数定义和引用
- 文件分析:获取有关文件结构、导入和复杂性的详细信息
- 智能过滤:自动忽略构建目录、依赖项和非代码文件
- 持久存储:缓存索引以提高跨会话的性能
支持的文件类型
该服务器支持多种编程语言和文件扩展名,包括:
- 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:
使用 pip
或者,您可以通过 pip 安装:
安装后,您可以将其作为模块运行:
与 Claude Desktop 集成
将其添加到您的 Claude 设置( ~/Library/Application Support/Claude/claude_desktop_config.json
):
添加配置后,重新启动 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 的示例:
设置项目路径
搜索代码模式
获取文件摘要
查找特定类型的所有文件
发展
从源代码构建
- 克隆存储库:
- 安装依赖项:
- 在本地运行服务器:
调试
您可以使用 MCP 检查器来调试服务器:
执照
贡献
欢迎贡献代码!欢迎提交 Pull 请求。
语言
This server cannot be installed
local-only server
The server can only run on the client's local machine because it depends on local resources.
模型上下文协议 (MCP) 服务器,可帮助大型语言模型以最少的设置索引、搜索和分析代码存储库
Related Resources
Related MCP Servers
- -securityAlicense-qualityA Model Context Protocol server that enables LLMs to read, search, and analyze code files with advanced caching and real-time file watching capabilities.Last updated -215JavaScriptMIT License
- -securityFlicense-qualityA smart code retrieval tool based on Model Context Protocol that provides efficient and accurate code repository search capabilities for large language models.Last updated -Python
- -securityAlicense-qualityA Model Context Protocol (MCP) compliant server that allows Large Language Models (LLMs) to search and retrieve content from microCMS APIs.Last updated -TypeScriptMIT License
- -securityAlicense-qualityA Model Context Protocol (MCP) server that scrapes, indexes, and searches documentation for third-party software libraries and packages, supporting versioning and hybrid search.Last updated -231129TypeScriptMIT License