.NET程序集检查工具

HandMirror是一个用于.NET程序集和NuGet包检查的模型上下文协议(MCP)服务器,帮助AI编程助手准确理解.NET API并解决构建错误。

  • by askmirror
  • C#
  • 本地部署
  • 13 星标
  • 更新于
在 GitHub 查看 rkttu/HandMirrorMcp

使用说明

HandMirror MCP服务器

用于的模型上下文协议(MCP)服务器。NET程序集和NuGet包检查。HandMirror帮助AI编码代理理解。NET API,并通过提供对程序集元数据和NuGet包信息的直接访问来解决构建错误。

🎯 目的

人工智能编码助手经常产生幻觉或猜测API细节,导致构建错误和浪费开发迭代。HandMirror通过以下方式解决了这个问题:

  • 提供 准确的、版本特定的API信息 直接来自组件
  • 启用 方法签名、类型和命名空间的验证 编写代码之前
  • 帮助 诊断和修复。NET构建错误 快速
  • 支持分析 本机互操作 (P/Invoke、COM)依赖关系

✨ 特性

装配检验

  • inspect_assembly -使用XML文档对所有公共类型、成员和属性进行全面分析
  • list_namespaces -列出程序集中的所有命名空间
  • get_type_info -获取特定类型的详细信息

NuGet包探索

  • search_nuget_packages -按关键字搜索包裹
  • get_nuget_package_info -获取包元数据和依赖关系
  • get_nuget_package_versions -列出所有可用版本
  • inspect_nuget_package -分析包中的程序集
  • inspect_nuget_package_type -从包中获取详细的类型信息
  • list_nuget_sources -列出已配置的NuGet包源
  • clear_nuget_cache -清除本地NuGet包缓存
  • get_nuget_vulnerabilities -检查已知的安全漏洞
  • inspect_nupkg_contents -检查.nupkg文件的内容
  • extract_nupkg_file -从.nupkg中提取特定文件

本地互操作性分析

  • inspect_native_dependencies -在程序集中查找P/Invoke(DllImport/LibraryImport)和COM类型

项目分析

  • analyze_csproj -分析。NET项目文件并识别问题
  • analyze_solution -分析解决方案文件
  • explain_build_error -获取常见构建错误的解释
  • analyze_file_based_app -分析基于文件的应用程序
  • analyze_config_file -分析配置文件
  • analyze_packages_config -分析packages.config文件

系统信息

  • get_system_info -获取系统信息(操作系统、.NET运行时、硬件)
  • get_dotnet_info -获取详细信息。NET安装信息

📋 先决条件

  • .NET 8.0 SDK 或以后
  • MCP兼容客户端(例如,Claude Desktop、带副本的VS Code)

🚀 安装

从源代码构建

git clone https://github.com/rkttu/HandMirrorMcp.git
cd HandMirrorMcp
dotnet build

运行服务器

dotnet run --project HandMirrorMcp

⚙️ 配置

克劳德桌面版

将以下内容添加到您的Claude Desktop配置文件中:

窗户: %APPDATA%\Claude\claude_desktop_config.json macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "handmirror": {
      "command": "dotnet",
      "args": ["run", "--project", "C:\\path\\to\\HandMirrorMcp"]
    }
  }
}

或者,如果您已经构建了该项目:

{
  "mcpServers": {
    "handmirror": {
      "command": "C:\\path\\to\\HandMirrorMcp\\bin\\Debug\\net8.0\\HandMirrorMcp.exe"
    }
  }
}

VS代码与GitHub Copilot

添加到您的VS代码设置或工作区设置中:

{
  "servers": {
    "handmirror": {
      "command": "dotnet",
      "args": ["run", "--project", "/path/to/HandMirrorMcp"]
    }
  }
}

📖 使用示例

编写代码前验证API

当你需要使用一个陌生的。NET API:

Use inspect_nuget_package_type to show me the HttpClient class from System.Net.Http

诊断构建错误

当您遇到以下错误时 CS0246, CS1061,或 CS7036:

I'm getting CS1061 error. Use inspect_nuget_package to check the Newtonsoft.Json package 
and show me the available methods on JObject

探索NuGet包

Search for packages related to "json serialization" and show me the top results

检查软件包漏洞

Check if there are any known vulnerabilities in System.Text.Json version 6.0.0

分析项目问题

Analyze my .csproj file at C:\MyProject\MyProject.csproj and identify any issues

🏗️ 建筑

HandMirrorMcp/
├── Constants/
│   └── Emoji.cs              # Unicode emoji constants for output formatting
├── Prompts/
│   ├── AssemblyInspectorPrompts.cs
│   └── NuGetInspectorPrompts.cs
├── Services/
│   ├── NuGetService.cs       # NuGet package operations
│   ├── PeAnalyzerService.cs  # PE file analysis
│   ├── RepositoryService.cs  # Repository operations
│   └── XmlDocService.cs      # XML documentation parsing
├── Tools/
│   ├── AssemblyInspectorTool.cs
│   ├── InteropInspectorTool.cs
│   ├── NuGetInspectorTool.cs
│   ├── ProjectAnalyzerTool.cs
│   └── SystemInfoTool.cs
└── Program.cs

🧪 测试

运行测试套件:

dotnet test

测试使用MSTest并连接到实际的MCP服务器进行集成测试。

📦 依赖项

🤝 贡献

欢迎投稿!请随时提交拉取请求。

  1. 克隆该仓库
  2. 创建功能分支(git checkout -b feature/AmazingFeature)
  3. 提交您的更改(git commit -m 'Add some AmazingFeature')
  4. 推到分支(git push origin feature/AmazingFeature)
  5. 打开拉取请求

📄 许可证

此项目根据Apache许可证2.0获得许可-请参阅 许可证 文件以获取详细信息。

🙏 致谢

💖 支持这个项目

如果您发现HandMirror对您的开发工作流程有帮助,请考虑支持该项目!

您的赞助有助于维护和改进此项目,添加新功能,并使其对所有人免费。每一份贡献,无论多么微小,我们都深表感激! ⭐


手持镜子 - 编写代码前先查看 🪞