# 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
1. **ILSpy Command Line Tool**: Install the global dotnet tool:
```bash
dotnet tool install --global ilspycmd
```
2. **Python 3.8+**: Required for running the MCP server
## Installation
Install from PyPI:
```bash
pip install ilspy-mcp-server
```
Or for development:
```bash
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:
```json
{
"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 file
- `output_dir` (optional): Output directory for decompiled files
- `type_name` (optional): Specific type to decompile
- `language_version` (optional): C# language version (default: "Latest")
- `create_project` (optional): Create a compilable project structure
- `show_il_code` (optional): Show IL code instead of C#
- `remove_dead_code` (optional): Remove dead code during decompilation
- `nested_directories` (optional): Use nested directories for namespaces
**Example:**
```json
{
"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 file
- `entity_types` (optional): Array of entity types to list ("c", "i", "s", "d", "e")
**Example:**
```json
{
"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 file
- `output_dir` (optional): Output directory for the diagrammer
- `include_pattern` (optional): Regex pattern for types to include
- `exclude_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
1. **Install the package**:
```bash
pip install ilspy-mcp-server
```
2. **Configure your MCP client** (Claude Desktop example):
```json
{
"mcpServers": {
"ilspy": {
"command": "python",
"args": ["-m", "ilspy_mcp_server.server"]
}
}
}
```
3. **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`):
```json
{
"mcpServers": {
"ilspy": {
"command": "python",
"args": ["-m", "ilspy_mcp_server.server"],
"env": {
"LOGLEVEL": "INFO"
}
}
}
}
```
**Development/Testing**:
```json
{
"mcpServers": {
"ilspy": {
"command": "python",
"args": ["-m", "ilspy_mcp_server.server"],
"env": {
"LOGLEVEL": "DEBUG"
}
}
}
}
```
## Troubleshooting
### Common Issues
1. **"ILSpyCmd not found"**:
```bash
dotnet tool install --global ilspycmd
```
2. **"Assembly file not found"**:
- Check the file path is correct
- Ensure the file has .dll or .exe extension
3. **Permission errors**:
- Ensure read access to assembly files
- Check output directory permissions
### Debug Mode
Enable debug logging to see detailed operation info:
```json
{
"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](https://github.com/icsharpcode/ILSpy) decompiler
- Uses the [Model Context Protocol](https://modelcontextprotocol.io/) for integration
Raw data
{
"_id": null,
"home_page": null,
"name": "ilspy-mcp-server",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "csharp, decompiler, dotnet, ilspy, mcp, reverse-engineering",
"author": null,
"author_email": "Borealin <me@borealin.cn>",
"download_url": "https://files.pythonhosted.org/packages/69/dc/07beee10a55e283a79a255c8b865fdc3a9d64cda7687c0c0d67273584a3f/ilspy_mcp_server-0.1.1.tar.gz",
"platform": null,
"description": "# ILSpy MCP Server\n\nA Model Context Protocol (MCP) server that provides .NET assembly decompilation capabilities using ILSpy.\n\n## Features\n\n- **Decompile Assemblies**: Convert .NET assemblies back to readable C# source code\n- **List Types**: Enumerate classes, interfaces, structs, delegates, and enums in assemblies\n- **Generate Diagrammer**: Create interactive HTML visualizations of assembly structure\n- **Assembly Information**: Get metadata about .NET assemblies\n\n## Prerequisites\n\n1. **ILSpy Command Line Tool**: Install the global dotnet tool:\n ```bash\n dotnet tool install --global ilspycmd\n ```\n\n2. **Python 3.8+**: Required for running the MCP server\n\n## Installation\n\nInstall from PyPI:\n\n```bash\npip install ilspy-mcp-server\n```\n\nOr for development:\n\n```bash\ngit clone https://github.com/Borealin/ilspy-mcp-server.git\ncd ilspy-mcp-server\npip install -e .\n```\n\n## Usage\n\n### MCP Client Configuration\n\nConfigure your MCP client (e.g., Claude Desktop) to use the server:\n\n```json\n{\n \"mcpServers\": {\n \"ilspy\": {\n \"command\": \"python\",\n \"args\": [\"-m\", \"ilspy_mcp_server.server\"]\n }\n }\n}\n```\n\n### Available Tools\n\n#### 1. `decompile_assembly`\nDecompile a .NET assembly to C# source code.\n\n**Parameters:**\n- `assembly_path` (required): Path to the .NET assembly file\n- `output_dir` (optional): Output directory for decompiled files\n- `type_name` (optional): Specific type to decompile\n- `language_version` (optional): C# language version (default: \"Latest\")\n- `create_project` (optional): Create a compilable project structure\n- `show_il_code` (optional): Show IL code instead of C#\n- `remove_dead_code` (optional): Remove dead code during decompilation\n- `nested_directories` (optional): Use nested directories for namespaces\n\n**Example:**\n```json\n{\n \"name\": \"decompile_assembly\",\n \"arguments\": {\n \"assembly_path\": \"/path/to/MyAssembly.dll\",\n \"type_name\": \"MyNamespace.MyClass\",\n \"language_version\": \"CSharp10_0\"\n }\n}\n```\n\n#### 2. `list_types`\nList types in a .NET assembly.\n\n**Parameters:**\n- `assembly_path` (required): Path to the .NET assembly file\n- `entity_types` (optional): Array of entity types to list (\"c\", \"i\", \"s\", \"d\", \"e\")\n\n**Example:**\n```json\n{\n \"name\": \"list_types\",\n \"arguments\": {\n \"assembly_path\": \"/path/to/MyAssembly.dll\",\n \"entity_types\": [\"c\", \"i\"]\n }\n}\n```\n\n#### 3. `generate_diagrammer`\nGenerate an interactive HTML diagrammer.\n\n**Parameters:**\n- `assembly_path` (required): Path to the .NET assembly file\n- `output_dir` (optional): Output directory for the diagrammer\n- `include_pattern` (optional): Regex pattern for types to include\n- `exclude_pattern` (optional): Regex pattern for types to exclude\n\n#### 4. `get_assembly_info`\nGet basic information about an assembly.\n\n**Parameters:**\n- `assembly_path` (required): Path to the .NET assembly file\n\n### Available Prompts\n\n#### 1. `analyze_assembly`\nAnalyze a .NET assembly and provide insights about its structure.\n\n#### 2. `decompile_and_explain`\nDecompile a specific type and provide explanation of its functionality.\n\n## Supported Assembly Types\n\n- .NET Framework assemblies (.dll, .exe)\n- .NET Core/.NET 5+ assemblies\n- Portable Executable (PE) files with .NET metadata\n\n## Supported C# Language Versions\n\n- CSharp1 through CSharp12_0\n- Preview\n- Latest (default)\n\n## Quick Start\n\n1. **Install the package**:\n ```bash\n pip install ilspy-mcp-server\n ```\n\n2. **Configure your MCP client** (Claude Desktop example):\n ```json\n {\n \"mcpServers\": {\n \"ilspy\": {\n \"command\": \"python\",\n \"args\": [\"-m\", \"ilspy_mcp_server.server\"]\n }\n }\n }\n ```\n\n3. **Use the tools** in your MCP client:\n - Ask to decompile a .NET assembly\n - List types in an assembly\n - Generate interactive diagrams\n - Get assembly information\n\n## Error Handling\n\nThe server provides detailed error messages for common issues:\n- Assembly file not found\n- Invalid assembly format\n- ILSpyCmd not installed or not in PATH\n- Permission issues\n- Decompilation failures\n\n## Configuration\n\n### Environment Variables\n\n- `LOGLEVEL`: Set logging level (DEBUG, INFO, WARNING, ERROR). Default: INFO\n\n### MCP Client Examples\n\n**Claude Desktop** (`config.json`):\n```json\n{\n \"mcpServers\": {\n \"ilspy\": {\n \"command\": \"python\",\n \"args\": [\"-m\", \"ilspy_mcp_server.server\"],\n \"env\": {\n \"LOGLEVEL\": \"INFO\"\n }\n }\n }\n}\n```\n\n**Development/Testing**:\n```json\n{\n \"mcpServers\": {\n \"ilspy\": {\n \"command\": \"python\",\n \"args\": [\"-m\", \"ilspy_mcp_server.server\"],\n \"env\": {\n \"LOGLEVEL\": \"DEBUG\"\n }\n }\n }\n}\n```\n\n## Troubleshooting\n\n### Common Issues\n\n1. **\"ILSpyCmd not found\"**:\n ```bash\n dotnet tool install --global ilspycmd\n ```\n\n2. **\"Assembly file not found\"**:\n - Check the file path is correct\n - Ensure the file has .dll or .exe extension\n\n3. **Permission errors**:\n - Ensure read access to assembly files\n - Check output directory permissions\n\n### Debug Mode\n\nEnable debug logging to see detailed operation info:\n```json\n{\n \"env\": {\n \"LOGLEVEL\": \"DEBUG\"\n }\n}\n```\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n\n## Acknowledgments\n\n- Built on top of the excellent [ILSpy](https://github.com/icsharpcode/ILSpy) decompiler\n- Uses the [Model Context Protocol](https://modelcontextprotocol.io/) for integration",
"bugtrack_url": null,
"license": "MIT",
"summary": "MCP Server for ILSpy .NET Decompiler",
"version": "0.1.1",
"project_urls": {
"Homepage": "https://github.com/Borealin/ilspy-mcp-server",
"Issues": "https://github.com/Borealin/ilspy-mcp-server/issues",
"Repository": "https://github.com/Borealin/ilspy-mcp-server.git"
},
"split_keywords": [
"csharp",
" decompiler",
" dotnet",
" ilspy",
" mcp",
" reverse-engineering"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "472416db0cf976fe270dc9609dcfa4fc0c8d6acacc6cc84c16f8cb05f61be0c6",
"md5": "8ec173a4c082a08c181e9d9c5c59e979",
"sha256": "16726912a69c66905e2372d3851cc13025c445457fbfb5be47afb25055b79623"
},
"downloads": -1,
"filename": "ilspy_mcp_server-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8ec173a4c082a08c181e9d9c5c59e979",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 11601,
"upload_time": "2025-08-04T03:08:42",
"upload_time_iso_8601": "2025-08-04T03:08:42.519090Z",
"url": "https://files.pythonhosted.org/packages/47/24/16db0cf976fe270dc9609dcfa4fc0c8d6acacc6cc84c16f8cb05f61be0c6/ilspy_mcp_server-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "69dc07beee10a55e283a79a255c8b865fdc3a9d64cda7687c0c0d67273584a3f",
"md5": "49f51fb1f764f00c0ed436b3db1ca7e2",
"sha256": "4f0619a4f64e6f4fd1cfa60e62f2533acecdb691a3721617930a617b47b672b3"
},
"downloads": -1,
"filename": "ilspy_mcp_server-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "49f51fb1f764f00c0ed436b3db1ca7e2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 9375,
"upload_time": "2025-08-04T03:08:43",
"upload_time_iso_8601": "2025-08-04T03:08:43.843430Z",
"url": "https://files.pythonhosted.org/packages/69/dc/07beee10a55e283a79a255c8b865fdc3a9d64cda7687c0c0d67273584a3f/ilspy_mcp_server-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-04 03:08:43",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Borealin",
"github_project": "ilspy-mcp-server",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "mcp",
"specs": [
[
">=",
"0.1.0"
]
]
},
{
"name": "pydantic",
"specs": [
[
">=",
"2.0.0"
]
]
}
],
"lcname": "ilspy-mcp-server"
}