ILSpy MCP Server
A Model Context Protocol (MCP) server that provides .NET assembly decompilation capabilities using ILSpy.
Features
- Decompile Assemblies: Convert .NET assemblies back to readable C# source code
- List Types: Enumerate classes, interfaces, structs, delegates, and enums in assemblies
- Generate Diagrammer: Create interactive HTML visualizations of assembly structure
- Assembly Information: Get metadata about .NET assemblies
Prerequisites
-
ILSpy Command Line Tool: Install the global dotnet tool:
dotnet tool install --global ilspycmd
-
Python 3.8+: Required for running the MCP server
Installation
Install from PyPI:
pip install ilspy-mcp-server
Or for development:
git clone https://github.com/Borealin/ilspy-mcp-server.git
cd ilspy-mcp-server
pip install -e .
Usage
MCP Client Configuration
Configure your MCP client (e.g., Claude Desktop) to use the server:
{
"mcpServers": {
"ilspy": {
"command": "python",
"args": ["-m", "ilspy_mcp_server.server"]
}
}
}
Available Tools
1. decompile_assembly
Decompile a .NET assembly to C# source code.
Parameters:
assembly_path(required): Path to the .NET assembly fileoutput_dir(optional): Output directory for decompiled filestype_name(optional): Specific type to decompilelanguage_version(optional): C# language version (default: "Latest")create_project(optional): Create a compilable project structureshow_il_code(optional): Show IL code instead of C#remove_dead_code(optional): Remove dead code during decompilationnested_directories(optional): Use nested directories for namespaces
Example:
{
"name": "decompile_assembly",
"arguments": {
"assembly_path": "/path/to/MyAssembly.dll",
"type_name": "MyNamespace.MyClass",
"language_version": "CSharp10_0"
}
}
2. list_types
List types in a .NET assembly.
Parameters:
assembly_path(required): Path to the .NET assembly fileentity_types(optional): Array of entity types to list ("c", "i", "s", "d", "e")
Example:
{
"name": "list_types",
"arguments": {
"assembly_path": "/path/to/MyAssembly.dll",
"entity_types": ["c", "i"]
}
}
3. generate_diagrammer
Generate an interactive HTML diagrammer.
Parameters:
assembly_path(required): Path to the .NET assembly fileoutput_dir(optional): Output directory for the diagrammerinclude_pattern(optional): Regex pattern for types to includeexclude_pattern(optional): Regex pattern for types to exclude
4. get_assembly_info
Get basic information about an assembly.
Parameters:
assembly_path(required): Path to the .NET assembly file
Available Prompts
1. analyze_assembly
Analyze a .NET assembly and provide insights about its structure.
2. decompile_and_explain
Decompile a specific type and provide explanation of its functionality.
Supported Assembly Types
- .NET Framework assemblies (.dll, .exe)
- .NET Core/.NET 5+ assemblies
- Portable Executable (PE) files with .NET metadata
Supported C# Language Versions
- CSharp1 through CSharp12_0
- Preview
- Latest (default)
Quick Start
-
Install the package:
pip install ilspy-mcp-server
-
Configure your MCP client (Claude Desktop example):
{ "mcpServers": { "ilspy": { "command": "python", "args": ["-m", "ilspy_mcp_server.server"] } } }
-
Use the tools in your MCP client:
- Ask to decompile a .NET assembly
- List types in an assembly
- Generate interactive diagrams
- Get assembly information
Error Handling
The server provides detailed error messages for common issues:
- Assembly file not found
- Invalid assembly format
- ILSpyCmd not installed or not in PATH
- Permission issues
- Decompilation failures
Configuration
Environment Variables
LOGLEVEL: Set logging level (DEBUG, INFO, WARNING, ERROR). Default: INFO
MCP Client Examples
Claude Desktop (config.json):
{
"mcpServers": {
"ilspy": {
"command": "python",
"args": ["-m", "ilspy_mcp_server.server"],
"env": {
"LOGLEVEL": "INFO"
}
}
}
}
Development/Testing:
{
"mcpServers": {
"ilspy": {
"command": "python",
"args": ["-m", "ilspy_mcp_server.server"],
"env": {
"LOGLEVEL": "DEBUG"
}
}
}
}
Troubleshooting
Common Issues
-
"ILSpyCmd not found":
dotnet tool install --global ilspycmd
-
"Assembly file not found":
- Check the file path is correct
- Ensure the file has .dll or .exe extension
-
Permission errors:
- Ensure read access to assembly files
- Check output directory permissions
Debug Mode
Enable debug logging to see detailed operation info:
{
"env": {
"LOGLEVEL": "DEBUG"
}
}
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Built on top of the excellent ILSpy decompiler
- Uses the Model Context Protocol for integration
Metadata
Release files for ilspy-mcp-server 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| ilspy_mcp_server-0.1.1.tar.gz | 9.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ilspy_mcp_server-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.0 kB
Release files / ilspy_mcp_server-0.1.1.tar.gz
| Download URL | ilspy_mcp_server-0.1.1.tar.gz |
|---|---|
| Size | 9.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4f0619a4f64e6f4fd1cfa60e62f2533acecdb691a3721617930a617b47b672b3
|
|
BLAKE2b-256 checksum How to use checksums |
69dc07beee10a55e283a79a255c8b865fdc3a9d64cda7687c0c0d67273584a3f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / ilspy_mcp_server-0.1.1-py3-none-any.whl
| Download URL | ilspy_mcp_server-0.1.1-py3-none-any.whl |
|---|---|
| Size | 11.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
16726912a69c66905e2372d3851cc13025c445457fbfb5be47afb25055b79623
|
|
BLAKE2b-256 checksum How to use checksums |
472416db0cf976fe270dc9609dcfa4fc0c8d6acacc6cc84c16f8cb05f61be0c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Security for ilspy-mcp-server 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.