pardeike/DecompilerServer
If you are the rightful owner of DecompilerServer and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
DecompilerServer is a powerful MCP server designed for decompiling and analyzing .NET assemblies, with specialized features for Unity's Assembly-CSharp.dll files.
DecompilerServer
A powerful MCP (Model Context Protocol) server for decompiling and analyzing .NET assemblies. DecompilerServer provides comprehensive decompilation, search, and code analysis capabilities for any .NET DLL, with specialized convenience features for Unity's Assembly-CSharp.dll files.
⨠Features
- š Comprehensive Analysis: 39 specialized MCP tools for deep assembly inspection
- ā” High Performance: Optimized decompilation with intelligent caching and lazy loading
- š ļø Universal Support: Works with any .NET assembly (.dll, .exe)
- š® Unity-Optimized: Specialized convenience features for Unity Assembly-CSharp.dll files
- š§ Code Generation: Generate Harmony patches, detour stubs, and extension method wrappers
- š Advanced Search: Search types, members, attributes, string literals, and usage patterns
- 𧬠Relationship Analysis: Inheritance tracking, usage analysis, and implementation discovery
- š Source Management: Line-precise source slicing and batch decompilation
- š ļø Developer Tools: IL analysis, AST outlining, and transpiler target suggestions
š Quick Start
Prerequisites
- .NET 8.0 SDK or later
- Windows, macOS, or Linux
Installation
-
Clone the repository:
git clone https://github.com/pardeike/DecompilerServer.git cd DecompilerServer
-
Build the project:
dotnet build DecompilerServer.sln
-
Run tests (optional):
dotnet test
š” Tip: See š¤ AI Tool Integration to configure with AI assistants.
š¤ AI Tool Integration
Configure with AI assistants via MCP (Model Context Protocol):
Codex (.codex/config.toml
):
[mcp_servers.decompiler]
command = "path_to_DecompilerServer.exe"
args = []
GitHub Copilot (.copilot/config.yaml
):
servers:
decompiler:
command: "path_to_DecompilerServer.exe"
args: []
Claude Desktop (claude_desktop_config.json
):
{
"mcpServers": {
"decompiler": {
"command": "path_to_DecompilerServer.exe",
"args": []
}
}
}
VS Code MCP Extension (.vscode/settings.json
):
{
"mcp.servers": [{
"name": "decompiler",
"command": "path_to_DecompilerServer.exe",
"args": []
}]
}
Basic Usage
-
Start the server:
dotnet run --project DecompilerServer
-
Load any .NET assembly (via MCP client):
{ "tool": "LoadAssembly", "arguments": { "assemblyPath": "/path/to/YourAssembly.dll" } }
OR for Unity projects:
{ "tool": "LoadAssembly", "arguments": { "gameDir": "/path/to/unity/game" } }
-
Explore the assembly:
{ "tool": "ListNamespaces", "arguments": {} }
-
Search for types:
{ "tool": "SearchTypes", "arguments": { "query": "Player", "limit": 10 } }
-
Decompile source code:
{ "tool": "GetDecompiledSource", "arguments": { "memberId": "<member-id-from-search>" } }
šļø Architecture
DecompilerServer is built on a robust, modular architecture:
Core Services
- AssemblyContextManager: Assembly loading and context management
- MemberResolver: Member ID resolution and validation
- DecompilerService: C# decompilation with caching
- SearchServiceBase: Search and pagination framework
- UsageAnalyzer: Code usage analysis
- InheritanceAnalyzer: Inheritance relationship tracking
- ResponseFormatter: Standardized JSON response formatting
MCP Tools (38 endpoints)
- Core Operations: Status, LoadAssembly, Unload, WarmIndex
- Discovery: ListNamespaces, SearchTypes, SearchMembers, SearchAttributes
- Analysis: GetMemberDetails, GetDecompiledSource, GetSourceSlice, GetIL
- Relationships: FindUsages, FindCallers, FindCallees, GetOverrides
- Code Generation: GenerateHarmonyPatchSkeleton, GenerateDetourStub
- Advanced: BatchGetDecompiledSource, SuggestTranspilerTargets, PlanChunking
Member ID System
All members use a stable ID format: <mvid-32hex>:<token-8hex>:<kind-code>
- Kind Codes: T=Type, M=Method/Constructor, P=Property, F=Field, E=Event, N=Namespace
- IDs remain consistent across sessions for reliable automation
š Examples
Analyzing Any .NET Assembly
# 1. Load any .NET assembly directly
{
"tool": "LoadAssembly",
"arguments": {
"assemblyPath": "/path/to/MyLibrary.dll"
}
}
# 2. Find all public classes
{
"tool": "SearchTypes",
"arguments": {
"query": "",
"accessibility": "public"
}
}
# 3. Get detailed information about a specific type
{
"tool": "GetMemberDetails",
"arguments": {
"memberId": "abc123...def:12345678:T"
}
}
Analyzing a Unity Assembly
# 1. Load Unity's main assembly
{
"tool": "LoadAssembly",
"arguments": {
"assemblyPath": "Game_Data/Managed/Assembly-CSharp.dll"
}
}
# 2. Find all Player-related classes
{
"tool": "SearchTypes",
"arguments": {
"query": "Player",
"accessibility": "public"
}
}
# 3. Get detailed information about a specific type
{
"tool": "GetMemberDetails",
"arguments": {
"memberId": "abc123...def:12345678:T"
}
}
# 4. Generate a Harmony patch skeleton
{
"tool": "GenerateHarmonyPatchSkeleton",
"arguments": {
"memberId": "abc123...def:87654321:M",
"patchType": "Prefix"
}
}
Batch Analysis Workflow
# 1. Search for methods containing specific string literals
{
"tool": "SearchStringLiterals",
"arguments": {
"query": "PlayerDied",
"caseSensitive": false
}
}
# 2. Batch decompile multiple members
{
"tool": "BatchGetDecompiledSource",
"arguments": {
"memberIds": ["id1", "id2", "id3"]
}
}
# 3. Analyze usage patterns
{
"tool": "FindUsages",
"arguments": {
"memberId": "target-member-id",
"includeReferences": true
}
}
š§ Development
Building
# Build entire solution
dotnet build DecompilerServer.sln
# Build specific project
dotnet build DecompilerServer.csproj
Testing
# Run all tests
dotnet test
# Run with verbose output
dotnet test --verbosity normal
# Run specific test class
dotnet test --filter "ClassName=CoreToolTests"
Code Formatting
# Format code before committing
dotnet format DecompilerServer.sln
Project Structure
DecompilerServer/
āāā Services/ # Core service implementations (7 services)
āāā Tools/ # MCP tool implementations (39 tools)
āāā Tests/ # Comprehensive xUnit test suite
āāā TestLibrary/ # Test assembly for validation
āāā Program.cs # Application entry point
āāā ServiceLocator.cs # Service locator for MCP tools
āāā *.md # Documentation files
š Documentation
- - Comprehensive guide to service helpers and implementation patterns
- - Complete testing framework documentation and best practices
- - Prioritized enhancement opportunities and development roadmap
- - Detailed project architecture and AI development guidelines
š¤ Contributing
We welcome contributions! Please see our development documentation for detailed guidelines:
- Read the documentation: Start with and
- Check the roadmap: Review for priority items
- Follow patterns: Study existing tools and services for consistency
- Test thoroughly: Use the comprehensive xUnit framework
- Format code: Run
dotnet format
before committing
Development Workflow
- Fork the repository
- Create a feature branch
- Make your changes following existing patterns
- Add tests for new functionality
- Run
dotnet test
to ensure all tests pass - Run
dotnet format
to maintain code style - Submit a pull request with a clear description
š”ļø Thread Safety & Performance
DecompilerServer is designed for high performance and thread safety:
- Thread-Safe Access: Uses
ReaderWriterLockSlim
for concurrent operations - Intelligent Caching: Decompiled source with line indexing for efficient slicing
- Lazy Loading: Minimal upfront computation, build indexes on demand
- Pagination: All search results paginated (default: 50, max: 500 items)
š MCP Integration
DecompilerServer implements the Model Context Protocol for seamless integration with AI development tools:
- Auto-Discovery: Tools automatically discovered via
[McpServerTool]
attributes - Standardized Responses: Consistent JSON formatting across all endpoints
- Error Handling: Structured error responses with detailed messages
- Type Safety: Strong typing for all tool parameters and responses
See š¤ AI Tool Integration for configuration examples.
š System Requirements
- .NET 8.0 or later
- Memory: Recommended 4GB+ for large assemblies
- Storage: Varies by assembly size (caching may require additional space)
- Platform: Windows, macOS, or Linux
š License
This project is open source. Please check the repository for license details.
š Acknowledgments
Built with:
- ICSharpCode.Decompiler - Core decompilation engine
- ModelContextProtocol - MCP server framework
- Microsoft.Extensions.Hosting - Application hosting and dependency injection
For detailed technical documentation and advanced usage scenarios, please refer to the comprehensive guides in the repository documentation.