DLL解压缩器MCP服务器
一种反编译的模型上下文协议(MCP)服务器。NET DLL程序集使用ICSharpCode。反编译器(ILSpy的库),并将反编译后的代码暴露给AI工具。
特性
- 反编译:分解。NET DLL转换为C#源代码
- 缓存:使用SHA256哈希进行基于文件的持久缓存以提高速度
- 搜索:搜索所有反编译代码
- 资源:将反编译的文件作为MCP资源公开
- 工具:为反编译和搜索操作提供MCP工具
安装
先决条件
- .NET 9.0 SDK或更高版本
- Windows、Linux或macOS
构建
cd c:\development\mcpeek\McPeek
dotnet build用法
运行服务器
dotnet run服务器通过stdio进行通信,并遵循MCP协议。
MCP工具
服务器公开了以下工具:
1.分解文件夹
全部分解。NET DLL文件在指定文件夹中。
参数:
folderPath(string):包含DLL文件的文件夹的绝对路径
退货:
{
"Success": true,
"Message": "Successfully decompiled 5 assemblies",
"AssemblyNames": ["Assembly1", "Assembly2", ...],
"TotalFiles": 150
}2.分解Dll
分解特定的DLL文件。
参数:
dllPath(string):DLL文件的绝对路径
退货:
{
"Success": true,
"Message": "Successfully decompiled MyAssembly",
"AssemblyNames": ["MyAssembly"],
"TotalFiles": 30
}3.搜索代码
在所有反编译的C#代码中搜索文本模式。
参数:
query(string):要搜索的文本caseSensitive(bool,可选):搜索是否应区分大小写(默认值:false)maxResults(int,可选):返回的最大结果数(默认值:50)
退货:
{
"Success": true,
"Query": "MyClass",
"TotalMatches": 10,
"Results": [
{
"AssemblyName": "MyAssembly",
"FilePath": "MyNamespace/MyClass.cs",
"LineNumber": 42,
"LineContent": "public class MyClass",
"Context": "..."
}
]
}4.已加载的程序集列表
列出已反编译且当前已加载的所有程序集。
退货:
{
"Success": true,
"TotalAssemblies": 5,
"Assemblies": [
{
"Name": "MyAssembly",
"Path": "C:\\path\\to\\MyAssembly.dll",
"FileCount": 30,
"DecompiledAt": "2025-10-24T12:00:00Z"
}
]
}5.GetCacheStatistics
获取有关反编译缓存的统计信息。
退货:
{
"Success": true,
"TotalCachedAssemblies": 10,
"CacheDirectory": "C:\\Users\\...\\Temp\\McPeek\\cache",
"CacheSizeMB": 15.5
}6.ClearCache
清除所有缓存的反编译结果。
退货:
{
"Success": true,
"Message": "Cache cleared successfully"
}MCP资源
分解后的文件以URI的形式作为资源公开,格式如下:
decompiled://AssemblyName/Namespace/TypeName.cs例如:
decompiled://MyAssembly/MyNamespace/MyClass.cs资源操作
列表资源
列出所有可用的反编译文件。
退货:
[
{
"Uri": "decompiled://MyAssembly/MyNamespace/MyClass.cs",
"Name": "MyAssembly/MyNamespace/MyClass.cs",
"Description": "Decompiled source for MyNamespace.MyClass",
"MimeType": "text/x-csharp"
}
]GetResource
检索特定文件的反编译C#源代码。
参数:
uri(string):资源URI
退货:
{
"Uri": "decompiled://MyAssembly/MyNamespace/MyClass.cs",
"Content": "using System;\n\nnamespace MyNamespace\n{\n public class MyClass\n {\n ...\n }\n}",
"MimeType": "text/x-csharp"
}GetAssembly概述
获取反编译程序集的概述。
参数:
assemblyName(string):程序集的名称
退货:
{
"AssemblyName": "MyAssembly",
"AssemblyPath": "C:\\path\\to\\MyAssembly.dll",
"TotalFiles": 30,
"DecompiledAt": "2025-10-24T12:00:00Z",
"Namespaces": [
{
"Name": "MyNamespace",
"Types": [
{
"Name": "MyNamespace.MyClass",
"FilePath": "MyNamespace/MyClass.cs",
"IsPublic": true
}
]
}
]
}缓存
服务器使用存储在系统临时目录中的基于持久文件的缓存:
%TEMP%\McPeek\cache\缓存使用SHA256哈希来检测DLL何时更改。如果DLL没有更改,则立即返回缓存的反编译。
配置
VS代码/临床集成
要将此MCP服务器与VS Code或Cline一起使用,请将其添加到您的MCP设置中:
{
"mcpServers": {
"mcpeek": {
"command": "dotnet",
"args": [
"run",
"--project",
"c:\\development\\mcpeek\\McPeek\\McPeek.csproj"
]
}
}
}建筑
组件
- 反编译CacheManager:使用SHA256哈希管理基于文件的持久缓存
- 解压缩服务:使用ICSharpCode的核心反编译服务。反编译器
- 反编译工具:用于反编译和搜索操作的MCP工具
- 分解器资源:用于访问反编译内容的MCP资源
- 程序cs:MCP服务器主机设置
技术
- ICSharpCode。反编译器:ILSpy的反编译库
- 微软。扩展。人工智能:MCP服务器实现
- 微软。扩展。托管:托管基础设施
- .NET 9.0:运行时平台
示例工作流程
- 解压缩DLL文件夹:
Tool: DecompileFolder
folderPath: "C:\\MyProject\\bin\\Debug"- 搜索特定类别:
Tool: SearchCode
query: "MyImportantClass"- 访问反编译源代码:
Resource: decompiled://MyAssembly/MyNamespace/MyImportantClass.cs- 获取装配概述:
Resource Operation: GetAssemblyOverview
assemblyName: "MyAssembly"许可证
本项目使用ICSharpCode。根据MIT许可证授权的反编译器。
贡献
欢迎投稿!请确保所有更改都遵循对象健美操和常规承诺指南。
