kirkderp/rbinilspy
GitHub: kirkderp/rbinilspy
基于 ILSpy 的 MCP 服务器,让 AI 编程助手能够对 .NET 程序集进行结构化浏览、反编译和依赖分析。
Stars: 2 | Forks: 0
# rbinilspy
[](LICENSE)
[](rust-toolchain.toml)
[](https://dotnet.microsoft.com)
用于基于 ILSpy 的 .NET assembly 分析的 MCP server。
`rbinilspy` 通过内存中的 C# worker 进程管理持久化的 ILSpy session,
加载 .NET assembly 以进行分析,并通过 stdio 暴露 17 个工具,作为命名的
[Model Context Protocol](https://modelcontextprotocol.io) 工具。
## 工具
**Session 管理**
- `dn_open` / `dn_close` / `dn_sessions` -- 打开/关闭/列出持久化的 ILSpy session
- `dn_metadata` -- assembly 元数据:类型数量、命名空间数量
**发现与导航**
- `dn_namespaces` -- 列出命名空间及其类型数量,支持过滤和分页
- `dn_types` -- 列出类型,支持名称/命名空间过滤和分页
- `dn_search` -- 通过子字符串搜索类型或已缓存的成员名称
- `dn_type_info` -- 类型元数据:基类、接口、特性、修饰符
**反编译**
- `dn_decompile` -- 将类型完整反编译为 C#(带有结果缓存)
- `dn_decompile_method` -- 反编译单个方法(节省 token,无需转储完整类型)
- `dn_members` -- 列出方法/属性/字段(带有结果缓存)
- `dn_il` -- 原始 CIL 反汇编
- `dn_search_source` -- 在反编译后的 C# 源代码中 grep 指定模式
**Assembly 分析**
- `dn_references` -- 外部 assembly 依赖
- `dn_usages` -- 在所有反编译的类型中查找指定模式的使用情况
- `dn_resources` -- 列出嵌入的资源
- `dn_raw_cmd` -- 用于执行任意 ilspycmd 调用的直通通道
## 环境要求
- **.NET 10 SDK**(用于构建 worker)
- **ILSpy CLI** -- `dotnet tool install -g ilspycmd`
- **Rust stable** 工具链(用于构建 MCP server)
## 快速开始
```
# 构建 C# worker
cd ilspy-worker && dotnet publish -c Release -o bin/publish
# 构建并运行 MCP server
cd .. && cargo build --workspace
RBM_CACHE_DIR=./cache cargo run -p rbm-server
```
该 server 通过 stdio 通信 MCP 协议。请配置你的 MCP 客户端:
```
{
"mcpServers": {
"rbinilspy": {
"command": "/path/to/rbinilspy/target/debug/rbinilspy",
"args": []
}
}
}
```
## 配置
| 变量 | 默认值 | 描述 |
| --- | --- | --- |
| `RBM_CACHE_DIR` | `./rbinilspy-cache` | 缓存根目录 |
| `RBM_TOOL_TIMEOUT_SECS` | 30 | 单个工具超时时间(秒) |
| `RBM_ILSPY_WORKER` | 自动检测 | C# worker 的路径(二进制文件或项目目录) |
| `RBM_ILSPY_CMD` | `ilspycmd` | ILSpy CLI 可执行文件的路径 |
| `RBM_ILSPY_CMD_TIMEOUT_MS` | 60000 | ilspycmd 子进程超时时间(毫秒) |
## 架构
```
MCP Client
-> stdio JSON-RPC
-> rbinilspy server (Rust)
-> C# worker process (stdin/stdout JSON-RPC)
-> ilspycmd subprocess (per-decompilation)
```
Assembly 会被打开一次并缓存在 C# worker 的内存中。反编译的
输出和成员列表会在 session 生命周期内按类型进行缓存。
## 项目结构
```
crates/
rbm-core/ Cache paths, config, error types
rbm-server/ MCP server binary (rbinilspy)
ilspy-worker/ C# persistent worker for ilspycmd
```
## 许可证
MIT -- 请参阅 [LICENSE](LICENSE)。
标签:ILSpy, MCP Server, Rust, URL提取, 云安全监控, 反编译, 可视化界面, 网络流量审计, 静态分析