ILSpy-MCP-Server

ARISTODE/ILSpy-MCP-Server

3.2

If you are the rightful owner of ILSpy-MCP-Server 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.

The ILSpy MCP Server is a Model Context Protocol bridge that provides automated .NET reverse engineering capabilities by exposing ILSpy functionalities through MCP.

Tools
7
Resources
0
Prompts
0

ILSpy MCP Server

Model Context Protocol (MCP) bridge that surfaces ILSpy functionality for automated .NET reverse engineering. The server wraps the official ILSpy PowerShell cmdlets and exposes a small set of tools (list types, enumerate methods, decompile C#) over MCP so coordinating agents can reason about managed assemblies when native decompilers are unavailable.

Prerequisites

Follow these steps to prepare the environment (verified against the upstream ILSpy documentation and official installation guides):

  1. Install the .NET 10.0 SDK

    • macOS/Linux: download the installer from dotnet.microsoft.com/download/dotnet/10.0 or use Homebrew (brew install --cask dotnet-sdk).
    • Windows: use the .NET SDK installer from the same link.
    • Verify with dotnet --list-sdks (should show a 10.0.* entry).
  2. Install PowerShell 7+

  3. Clone and build ILSpy (per the official README)

    git clone https://github.com/icsharpcode/ILSpy ../ilspy
    cd ../ilspy
    git submodule update --init --recursive
    dotnet build ILSpy.XPlat.slnf
    

    The PowerShell module is emitted at ../ilspy/ICSharpCode.Decompiler.PowerShell/bin/Debug/netstandard2.0/ICSharpCode.Decompiler.PowerShell.dll.

  4. Install MCP server dependencies

    python -m pip install mcp[server] typer pydantic
    

    (Use a virtual environment if preferred.)

Installation

Clone this repository and install the package in editable mode (optional):

cd ILSpy-MCP-Server
python -m pip install -e .

Alternatively, run directly with PYTHONPATH=src.

Configuration

By default the server assumes the sibling ILSpy checkout and PowerShell module described above. To override locations, pass --module-path or --powershell-path arguments (see below).

Environment VariableCLI OptionDescription
ILSPY_MCP_HOST--hostInterface to bind (default 127.0.0.1).
ILSPY_MCP_PORT--portPort for SSE transport (default 8891).
ILSPY_MCP_TRANSPORT--transportsse, streamable-http, or stdio.
ILSPY_MCP_MODULE--module-pathPath to ICSharpCode.Decompiler.PowerShell.dll.
ILSPY_MCP_PWSH--powershell-pathPath to the pwsh executable.

(Transport environment variables are optional; the CLI options take precedence.)

Running the Server

cd ILSpy-MCP-Server
PYTHONPATH=src python -m ilspy_mcp.server \
  --port 8891 \
  --host 127.0.0.1 \
  --transport sse

On startup the server imports the ILSpy PowerShell module to verify prerequisites, then listens for MCP tool calls.

Available Tools

Tool IDDescription
set_binary_pathLoad a managed assembly (.dll/.exe) for subsequent calls.
list_typesEnumerate types; optional comma-separated kinds.
list_modulesReport module/assembly metadata.
list_methodsList methods for a fully qualified type.
decompile_typeReturn full C# source for a type.
decompile_methodReturn the C# body for a single method.
search_stringsRegex search across decompiled source; returns type hits.

Clients should call set_binary_path once per session before invoking other tools.

Testing

A minimal suite validates the client-side session helpers:

PYTHONPATH=src pytest tests -q

The tests assume the sample managed DLL used during development is available; replace the path in tests/test_session.py if needed.

Repository Layout

src/ilspy_mcp/        # FastMCP server implementation and helpers
tests/                # Basic integration tests using the MCP client wrapper
configs/              # Example MCP client configuration files

Client Configuration Examples

  • Cursor – copy configs/cursor.json into your Cursor MCP configuration directory and adjust environment variables (e.g., ILSPY_MCP_MODULE) as needed.
  • Claude Desktop – merge the configs/claude.json snippet with your existing claude_desktop_config.json to register the server under the ilspy-mcp key.

Both examples invoke python -m ilspy_mcp.server with SSE transport and rely on PYTHONPATH=src so the package is importable without installation. Update paths if you are running from a different working directory.

References