使用说明
ILSpy MCP服务器
一 主控程序 使用的服务器 ICSharpCode。反编译器 提供。NET程序集检查工具。允许LLM列出类型、反编译C#,并从编译的程序集中查看IL反汇编。
先决条件
构建
dotnet build
用法
服务器使用MCP协议通过stdio进行通信。
dotnet run [options]
选项
| 选项 | 描述 |
|---|---|
--reference-path <path> |
添加程序集引用目录(可重复) |
-v, --verbose |
启用调试级别日志记录到stderr |
工具
list_types
列出中的所有类型(类、接口、结构、委托、枚举)。NET程序集,按命名空间分组。
| 参数 | 必填 | 说明 |
|---|---|---|
assemblyPath |
yes | .dll或.exe的路径 |
pattern |
没有用于筛选类型名称的正则表达式 |
list_members
将类型分解为C#并列出其成员和嵌套类型。
| 参数 | 必填 | 说明 |
|---|---|---|
assemblyPath |
yes | .dll或.exe的路径 |
typeName |
yes | 完全限定的类型名称(例如。 Namespace.ClassName) |
decompile
将类型分解为C#源代码。
| 参数 | 必填 | 说明 |
|---|---|---|
assemblyPath |
yes | .dll或.exe的路径 |
typeName |
yes | 完全限定的类型名称 |
disassemble
将类型反汇编为IL(中间语言)代码。
| 参数 | 必填 | 说明 |
|---|---|---|
assemblyPath |
yes | .dll或.exe的路径 |
typeName |
yes | 完全限定的类型名称 |
MCP客户端配置
克劳德代码
添加到MCP设置中:
{
"mcpServers": {
"ilspy": {
"command": "dotnet",
"args": ["run", "--project", "/path/to/ILSpyMCP"]
}
}
}
克劳德桌面版
增添 claude_desktop_config.json:
{
"mcpServers": {
"ilspy": {
"command": "dotnet",
"args": ["run", "--project", "/path/to/ILSpyMCP"]
}
}
}
要传递其他选项(例如框架部件的引用路径):
{
"mcpServers": {
"ilspy": {
"command": "dotnet",
"args": [
"run", "--project", "/path/to/ILSpyMCP",
"--",
"--reference-path", "/path/to/framework/assemblies"
]
}
}
}
