DnSpy.Extension.MCP
MCP extension for dnSpy.
Install / Use
/learn @KernelErr/DnSpy.Extension.MCPQuality Score
Category
Development & EngineeringSupported Platforms
README
dnSpy MCP Extension
A Model Context Protocol (MCP) extension for dnSpyEx that exposes .NET assembly analysis tools to AI assistants like Claude.
Features
MCP Tools (10 total)
The extension provides 10 powerful tools for analyzing .NET assemblies:
- list_assemblies - List all loaded assemblies with metadata
- get_assembly_info - Get detailed information about a specific assembly
- list_types - List all types in an assembly with filtering options
- get_type_info - Get comprehensive type information (fields, properties, methods, events)
- get_type_fields - Filter fields by wildcard pattern (e.g.,
*Bonus*) - get_type_property - Get detailed property information including getters/setters
- find_path_to_type - Find property/field chains connecting two types (BFS algorithm)
- get_method_signature - Get detailed method signature information
- decompile_method - Decompile method to C# source code
- search_types - Search for types by name pattern across all assemblies
MCP Resources (6 total)
Comprehensive embedded BepInEx plugin development documentation:
- plugin-structure - Basic plugin setup and metadata
- harmony-patching - HarmonyX patching guide (Prefix/Postfix/Transpiler)
- configuration - Configuration system usage
- common-scenarios - 8 common plugin development patterns
- il2cpp-guide - Complete IL2CPP development guide
- mono-vs-il2cpp - Side-by-side comparison and migration guide
All documentation is self-contained within the extension DLL - no internet connection required.
Installation
From Release (Recommended)
- Download the latest release from the Releases page
- Choose the appropriate DLL for your dnSpy version:
- dnSpy.Extension.MCP-net48.dll - For dnSpy .NET Framework 4.8
- dnSpy.Extension.MCP-net8.0.dll - For dnSpy .NET 8.0
- Rename the file to
dnSpy.Extension.MCP.x.dll - Copy to
<dnSpy-Install-Path>\bin\Extensions\dnSpy.Extension.MCP\ - Restart dnSpy
From Source
# Clone dnSpyEx repository
git clone https://github.com/dnSpyEx/dnSpy.git
cd dnSpy
# Clone this extension into Extensions folder
cd Extensions
git clone https://github.com/KernelErr/dnSpy.Extension.MCP.git
# Build the extension
cd dnSpy.Extension.MCP
dotnet build -c Release
# Copy to dnSpy installation
copy bin\Release\net48\dnSpy.Extension.MCP.x.dll <dnSpy-Install-Path>\bin\Extensions\dnSpy.Extension.MCP\
Configuration
Access settings in dnSpy: Edit → Settings → MCP Server
Available settings:
- Enable Server - Start/stop the MCP server
- Port - HTTP server port (default: 3000)
- Host - Bind address (default: localhost for .NET Framework)
Usage
With Claude Desktop
Add to your Claude Desktop configuration (claude_desktop_config.json):
{
"mcpServers": {
"dnspy": {
"command": "http",
"args": ["http://localhost:3000"]
}
}
}
Testing the Server
Check server health:
curl http://localhost:3000/health
Expected response:
{"status":"ok","service":"dnSpy MCP Server"}
Development
Building
# Build for .NET Framework 4.8
dotnet build -c Release -f net48
# Build for .NET 8.0
dotnet build -c Release -f net8.0-windows
Project Structure
dnSpy.Extension.MCP/
├── .github/workflows/ # GitHub Actions (build, release)
├── McpServer.cs # HTTP server (Kestrel/.NET, HttpListener/.NET Framework)
├── McpProtocol.cs # JSON-RPC 2.0 protocol models
├── McpTools.cs # 10 MCP tools implementation
├── McpSettings.cs # Settings UI and persistence
├── BepInExResources.cs # Embedded documentation (6 resources)
└── dnSpy.Extension.MCP.csproj
Architecture
- Multi-framework support: Targets both
net48andnet8.0-windows - Server implementation:
- .NET 8.0: ASP.NET Core Kestrel (high performance)
- .NET Framework: HttpListener (compatibility)
- MEF integration: Uses dnSpy's Managed Extensibility Framework
- Protocol: JSON-RPC 2.0 over HTTP
- CORS enabled: Allows cross-origin requests
Protocol
The extension implements Model Context Protocol (MCP) specification version 2024-11-05.
Supported methods:
initialize- Server initializationping- Keepalivetools/list- List available toolstools/call- Execute a toolresources/list- List documentation resourcesresources/read- Read documentation contentnotifications/*- Handle client notifications
CI/CD
GitHub Actions Workflows
-
Build Workflow (
.github/workflows/build.yml)- Triggers: Push to master/main, Pull Requests
- Builds both net48 and net8.0-windows
- Runs on Debug and Release configurations
- Uploads artifacts for Release builds
-
Release Workflow (
.github/workflows/release.yml)- Triggers: Push tags (
v*.*.*) or manual dispatch - Builds release DLLs
- Creates GitHub release with assets
- Auto-generates release notes
- Triggers: Push tags (
Creating a Release
# Tag the release
git tag v1.0.0
git push origin v1.0.0
# GitHub Actions will automatically:
# 1. Build both net48 and net8.0 DLLs
# 2. Create a GitHub release
# 3. Upload DLLs and README as assets
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
GitHub Actions will automatically build and test your PR.
Technical Details
Dependencies
- dnSpy.Contracts.DnSpy - dnSpy API contracts
- dnSpy.Contracts.Logic - Core logic contracts
- dnlib - .NET metadata library
- System.Text.Json - JSON serialization
- ASP.NET Core (net8.0 only) - Kestrel HTTP server
BFS Path Finding
The find_path_to_type tool uses breadth-first search to find navigation paths between types:
// Example: Find path from PlayerController to HealthBonus
// Result: PlayerController -> PlayerState -> Bonuses -> HealthBonus
Decompilation
Uses dnSpy's built-in decompiler with configurable options:
- Language: C#
- Indentation: Tabs
- Comment verbosity: Configurable
License
This extension follows the same license as dnSpyEx. Please see the dnSpyEx repository for license information.
Acknowledgments
- dnSpyEx - The .NET debugger and assembly editor (continuation of dnSpy)
- Model Context Protocol - Anthropic's MCP specification
- BepInEx - Unity game modding framework
Troubleshooting
Extension not loading
- Check dnSpy console for error messages
- Verify DLL is in correct location
- Ensure file is named
dnSpy.Extension.MCP.x.dll
Server not starting
- Check port is not already in use
- Review dnSpy console logs
- Try changing port in settings
Build errors
- Ensure dnSpy repository is cloned in parent directory
- Run
dotnet restorein dnSpy root - Check .NET SDK version (requires .NET 8.0 SDK)
Support
For issues, questions, or feature requests, please open an issue on the GitHub repository.
