Code Analysis MCP Server
该服务器通过经济高效且简单的设置,促进自然语言交互,以探索和理解代码库,提供对数据模型和系统架构的深入了解,并支持现有的 Claude Pro 订阅。
Tools
initialize_repository
Initialize the repository path for future code analysis operations. Args: path: Path to the repository root directory that contains the code to analyze
get_repo_info
Get information about the currently initialized code repository.
get_repo_structure
Get the structure of files and directories in the repository. Args: sub_path: Optional subdirectory path relative to repository root depth: Optional maximum depth to traverse (default is 3)
read_file
Read and display the contents of a file from the repository. Args: file_path: Path to the file relative to repository root
README
代码分析 MCP 服务器
一个模型上下文协议 (MCP) 服务器,使 AI 模型能够通过自然语言对话理解和分析代码库。
✨ 亮点
-
自然代码探索:提出关于代码库的高级问题
"系统中集成了哪些不同的支付提供商?" -
深度代码理解:提取关于数据模型和系统架构的见解
"用户身份验证流程如何从前端到数据库工作?" -
动态分析:跟踪数据流并理解系统关系
"告诉我所有计算交易费用的地方"
局限性
此工具是更复杂的代码分析工具/copilot(如 Aider)的更简单替代方案。虽然它缺乏像 Aider 这样的工具的高级代码分析能力和稳健性,但如果您已经拥有 Claude Pro 订阅,它可以为代码库探索提供一个轻量级的解决方案。 主要优点是:
- 经济高效:使用您现有的 Claude Pro 订阅意味着无需额外的 API 成本,这与分析大型代码库时可能变得昂贵的工具不同
- 设置简单:快速上手,配置最少
- 基本分析:适用于高级代码理解和探索
请注意,由于其更简单的代码分析方法,与更专业的工具相比,它可能会产生更多错误或提供不太详细的见解。
🚀 快速开始
- 安装服务器:
git clone https://github.com/saiprashanths/code-analysis-mcp.git
cd code-analysis-mcp
-
安装 Claude 桌面应用程序。 有关使用 Claude 桌面应用程序设置 MCP 服务器的更多说明,请参阅文档
-
在 Claude 桌面的配置文件中配置服务器:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"code-analysis": {
"command": "uv",
"args": [
"--directory",
"/PATH/TO/YOUR/REPO",
"run",
"code_analysis.py"
]
}
}
}
-
重新启动 Claude 桌面并开始分析您的代码!
-
确保工具已正确设置
-
单击工具图标应显示
code-analysis工具 <img src="./docs/images/tools.png" width="500"> <img src="./docs/images/mcptools.png" width="500"> -
单击集成按钮应显示
analyze_code_repository提示 <img src="./docs/images/integrations.png" width="500"> <img src="./docs/images/prompt.png" width="500">
💡 使用示例
以下是如何使用该工具来理解复杂的代码库:
首先单击下面显示的 analyze_code_repository 提示。 这将指导您完成初始化存储库并开始使用的过程。
<img src="./docs/images/prompt.png" width="500">
你:此系统中的事务处理如何工作?
Claude:让我分析一下交易的数据流。
查看代码库,我可以看到事务处理通过几个关键组件进行:
1. 原始交易数据在 `TransactionEvent` 模型中捕获,其中包含以下字段:
- 付款状态
- 金额
- 费用计算
- 处理时间戳
2. 然后,此数据通过 PaymentSummary 模型进行处理,该模型:
- 验证支付提供商的响应
- 计算处理费用
- 记录交易状态
您想让我更详细地解释这部分的任何内容吗?
你:涉及哪些关键数据库表?
Claude:事务处理管道中的主要表是:
1. transaction_events:存储原始支付事件
2. payment_summary:已处理的交易记录
3. payment_providers:提供商配置
4. merchant_accounts:特定于帐户的设置
如果您想查看其中任何一个表的架构,请告诉我!
🔧 可用工具
initialize_repository
初始化用于分析的代码存储库:
initialize_repository("/path/to/repo")
# Output: Successfully initialized code repository at: /path/to/repo
get_repo_info
检索有关已初始化存储库的信息:
get_repo_info()
# Output:
# Code Repository Information:
# Path: /path/to/repo
# Exists: True
# Is Directory: True
# Found .gitignore file
get_repo_structure
检查存储库文件结构:
get_repo_structure(depth=2)
# Output:
# 📁 src/
# 📁 api/
# 📄 routes.py
# 📄 models.py
# 📁 utils/
# 📄 helpers.py
# 📄 main.py
read_file
读取和分析特定文件:
read_file("src/api/models.py")
# Output:
# File: src/api/models.py
# Language: python
# Size: 2.3 KB
#
# [File contents...]
⚙️ 技术细节
- 默认扫描深度:3 级
- 最大文件大小:1MB
- 每个文件的最大行数:1000
- 忽略 .gitignore 中列出的路径
- 仅限本地文件系统访问
- 验证文件路径以防止目录遍历
📝 许可证
该项目已获得 MIT 许可证的许可 - 有关详细信息,请参阅 LICENSE 文件。
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。