bivex/ILSpy-Mcp
GitHub: bivex/ILSpy-Mcp
将 ILSpy 的 .NET 程序集反编译能力封装为 MCP 服务器,让 AI 助手能够通过自然语言直接反编译和分析 .NET 代码。
Stars: 46 | Forks: 6
# ILSpy MCP Server
一个提供 .NET 程序集反编译和分析功能的 Model Context Protocol (MCP) 服务器。
## 这是什么?
ILSpy MCP Server 使 AI 助手(如 Claude Code、Cursor)能够直接通过自然语言指令来反编译和分析 .NET 程序集。它集成了 [ILSpy](https://github.com/icsharpcode/ILSpy) 以提供强大的逆向工程能力。
## 快速开始
### 前置条件
- .NET 9.0 SDK 或更高版本
- 兼容 MCP 的客户端(Claude Code、Cursor、Claude Desktop 等)
### 安装
从 NuGet 作为全局 dotnet 工具安装:
```
dotnet tool install -g ILSpyMcp.Server
```
更新到最新版本:
```
dotnet tool update -g ILSpyMcp.Server
```
### 配置 MCP Client
对于 **Claude Code**,注册 MCP 服务器:
```
claude mcp add ilspy-mcp --command "ilspy-mcp" --scope user
```
或者在您的项目根目录中创建/更新 `.mcp.json`:
```
{
"mcpServers": {
"ilspy-mcp": {
"type": "stdio",
"command": "ilspy-mcp",
"args": []
}
}
}
```
对于 **Cursor**,添加到您的 MCP 设置中:
```
{
"mcpServers": {
"ilspy-mcp": {
"command": "ilspy-mcp",
"args": []
}
}
}
```
对于 **Claude Desktop**,添加到 `claude_desktop_config.json`:
```
{
"mcpServers": {
"ilspy-mcp": {
"command": "ilspy-mcp",
"args": []
}
}
}
```
## 使用示例
### 反编译 Type
```
Decompile the String class from /path/to/System.Runtime.dll
```
### 列出所有 Types
```
List all types in the assembly /path/to/MyLibrary.dll
```
### 查找特定 Method
```
Find the CalculateTotal method in /path/to/Calculator.dll
```
### 分析 Type 层级
```
Show me the type hierarchy for ProductService in /path/to/ECommerce.dll
```
### 搜索 Members
```
Search for members containing "Authenticate" in /path/to/Auth.dll
```
## 可用工具
| 工具 | 描述 |
|------|-------------|
| `decompile_type` | 从 DLL 反编译并分析 .NET type |
| `decompile_method` | 反编译并分析特定的 method |
| `list_assembly_types` | 列出程序集中的所有 types |
| `analyze_assembly` | 获取程序集的架构概览 |
| `get_type_members` | 获取 type 的完整 API 表面 |
| `find_type_hierarchy` | 查找继承关系 |
| `search_members_by_name` | 按名称搜索 members |
| `find_extension_methods` | 查找某个 type 的扩展方法 |
## 配置
可以通过环境变量配置服务器:
- `ILSpy__MaxDecompilationSize`:反编译代码的最大大小(以字节为单位)(默认:1048576 = 1 MB)
- `ILSpy__DefaultTimeoutSeconds`:操作的默认超时时间(以秒为单位)(默认:30)
- `ILSpy__MaxConcurrentOperations`:最大并发操作数(默认:10)
## 架构
该服务器遵循清晰的架构,实现了关注点分离:
- **Domain**:核心业务逻辑和实体
- **Application**:用例和应用服务
- **Infrastructure**:外部系统适配器(ILSpy、文件系统)
- **Transport**:MCP 协议层
## 安全
- 所有操作均为只读(无文件修改)
- 程序集路径验证
- 支持超时和取消
- 请求上下文传递
## 许可证
MIT — 详情请参阅 [LICENSE](LICENSE)。
标签:AI辅助分析, MCP, SOC Prime, URL提取, 云资产清单, 反编译, 开发工具, 逆向工程