ILSpy MCP服务器
一种模型上下文协议(MCP)服务器,提供。NET程序集反编译和分析功能。
这是什么?
ILSpy MCP Server使AI助手(如Claude Code、Cursor)能够反编译和分析。NET程序集直接通过自然语言命令。它集成了 ILSpy 提供强大的逆向工程能力。
快速开始
先决条件
- .NET 9.0 SDK或更高版本
- MCP兼容客户端(克劳德代码、光标、克劳德桌面等)
安装
从NuGet安装为全局.NET工具:
dotnet tool install -g ILSpyMcp.Server要更新到最新版本:
dotnet tool update -g ILSpyMcp.Server配置MCP客户端
对于 克劳德代码,注册MCP服务器:
claude mcp add ilspy-mcp --command "ilspy-mcp" --scope user或创建/更新 .mcp.json 在项目根目录中:
{
"mcpServers": {
"ilspy-mcp": {
"type": "stdio",
"command": "ilspy-mcp",
"args": []
}
}
}对于 光标,添加到MCP设置中:
{
"mcpServers": {
"ilspy-mcp": {
"command": "ilspy-mcp",
"args": []
}
}
}对于 克劳德桌面,添加到 claude_desktop_config.json:
{
"mcpServers": {
"ilspy-mcp": {
"command": "ilspy-mcp",
"args": []
}
}
}用法示例
分解类型
Decompile the String class from /path/to/System.Runtime.dll列出所有类型
List all types in the assembly /path/to/MyLibrary.dll找到一种特定的方法
Find the CalculateTotal method in /path/to/Calculator.dll分析类型层次结构
Show me the type hierarchy for ProductService in /path/to/ECommerce.dll搜索成员
Search for members containing "Authenticate" in /path/to/Auth.dll可用工具
| 工具 | 说明 |
|---|---|
decompile_type | 分解并分析a。NET类型从DLL |
decompile_method | 分解并分析特定方法 |
list_assembly_types | 列出程序集中的所有类型 |
analyze_assembly | 获取部件的架构概述 |
get_type_members | 获取类型的完整API曲面 |
find_type_hierarchy | 查找继承关系 |
search_members_by_name | 按姓名搜索成员 |
find_extension_methods | 查找类型的扩展方法 |
配置
服务器可以通过环境变量进行配置:
ILSpy__MaxDecompilationSize:反编译代码的最大大小(以字节为单位)(默认值:1048576=1 MB)ILSpy__DefaultTimeoutSeconds:操作的默认超时时间(秒)(默认值:30)ILSpy__MaxConcurrentOperations:最大并发操作数(默认值:10)
建筑
此服务器遵循一个干净的架构,具有明确的关注点分离:
- 领域:核心业务逻辑和实体
- 应用:用例和应用程序服务
- 基础设施:外部系统适配器(ILSpy、文件系统)
- 运输:MCP协议层
安全
- 所有操作都是只读的(不修改文件)
- 装配路径验证
- 超时和取消支持
- 请求上下文传播
许可证
麻省理工学院——见 许可证 了解详情。
