mcp-dotnet
Enables LLMs to read .NET assemblies as C# by providing tools to list types, decompile types, decompile assemblies, and search decompiled source.
README
mcp-dotnet
Русская версия ниже / Russian version below
A small Model Context Protocol (MCP) server that lets an LLM read .NET
assemblies as C#. It is a thin wrapper around the official ILSpy CLI
(ilspycmd), exposed over stdio so any MCP-capable client can list types,
decompile a single class, decompile the whole assembly into a project tree,
or grep across the decompiled source.
Why this exists
LLMs are good at reading source code, not raw IL bytecode. ILSpy already
turns CIL into faithful C#, but invoking it from a chat agent is awkward —
you end up shelling out to ilspycmd by hand and pasting the output back
into the conversation. This server formalizes that loop:
list-typesfirst, so the model knows which type to look at without dumping a megabyte of decompilation into context.decompile-typefor targeted reads — one fully-qualified class at a time.decompile-assemblywhen the model genuinely wants the whole project tree, e.g. before running a project-wide grep.search-sourcedecompiles once, caches the output, and greps across all the resulting.csfiles. Subsequent searches reuse the cached tree.
The target assembly is never executed. Everything is static.
It also handles the common modern case of .NET 6/7/8 single-file
deployments — point path at the published .exe and ILSpy 10+ resolves
the embedded core assembly automatically.
Tools
| Tool | What it does |
|---|---|
list-types |
List declared types in an assembly. Optional kinds filter (c/i/s/d/e). |
decompile-type |
Decompile one fully-qualified type to C#. Optional IL appended via includeIl. |
decompile-assembly |
Decompile to a folder of .cs files (a compilable project). |
search-source |
Decompile (once, cached) and grep the C# tree for a regex; returns file/line/snippet. |
Install
# 1. ILSpy CLI (one-time, requires .NET SDK 6+)
dotnet tool install --global ilspycmd
# 2. This server
git clone https://github.com/beekamai/mcp-dotnet.git
cd mcp-dotnet
npm install
npm run build
If ilspycmd is not on PATH, set the ILSPYCMD environment variable to its
absolute path. The server also auto-detects the default
%USERPROFILE%\.dotnet\tools\ilspycmd.exe location on Windows and
~/.dotnet/tools/ilspycmd on POSIX.
Wire it into any MCP-capable client over stdio:
your-mcp-client mcp add dotnet --scope user -- node /absolute/path/to/mcp-dotnet/dist/index.js
Notes
- All tools take absolute paths. Working directory differences between the MCP client and this server are common, so the server refuses to guess.
decompile-assemblyand the firstsearch-sourceon a fresh assembly can take tens of seconds to several minutes depending on size — the timeout is 10 minutes.search-sourcecaches the decompiled tree under<assemblyDir>/.mcp-dotnet-<assemblyName>/by default. Pass an explicitoutDirto control placement, or delete the cache to force re-decompilation.- The server runs
ilspycmdas a child process and never exposes its stdin. No code from the target assembly is executed at any point.
License
MIT.
<a id="mcp-dotnet-ru"></a>
mcp-dotnet (RU)
Небольшой MCP-сервер, который даёт языковой модели возможность читать
.NET-сборки как C#-исходники. Это тонкая обёртка над официальной
консольной утилитой ILSpy (ilspycmd) поверх stdio: модель может получить
список типов, декомпилировать один класс, развернуть всю сборку в дерево
.cs-файлов или прогнать regex по исходнику.
Зачем это нужно
LLM хорошо читают исходный код и плохо — IL. ILSpy и так умеет превращать
CIL в адекватный C#, но дёргать ilspycmd руками из чата неудобно — каждый
раз shell-out и копипаст в контекст. Этот сервер формализует цикл:
- Сначала
list-types, чтобы модель не тащила мегабайты декомпила в контекст ради того, чтобы выяснить какой класс ей нужен. decompile-type— точечно один полностью-квалифицированный тип.decompile-assembly— когда нужен весь проектный tree (например, чтобы потом сделать project-wide grep).search-source— декомпилирует один раз, кэширует результат и ищет regex по всем.cs. Повторные поиски используют кэш.
Целевую сборку никто не запускает. Всё статично.
Сервер также корректно работает с single-file deployment .NET 6/7/8 —
указываешь path на опубликованный .exe, ILSpy 10+ сам находит
встроенный основной assembly.
Тулы
| Тул | Что делает |
|---|---|
list-types |
Список типов сборки. Опциональный фильтр kinds (c/i/s/d/e). |
decompile-type |
Декомпиляция одного типа в C#. С опциональным IL через includeIl. |
decompile-assembly |
Развёртывает сборку в папку .cs-файлов (компилируемый проект). |
search-source |
Один раз декомпилирует (с кэшем), потом regex-grep по .cs — возвращает file/line/snippet. |
Установка
# 1. ILSpy CLI (один раз, нужен .NET SDK 6+)
dotnet tool install --global ilspycmd
# 2. Сам сервер
git clone https://github.com/beekamai/mcp-dotnet.git
cd mcp-dotnet
npm install
npm run build
Если ilspycmd не попал в PATH — выставь переменную окружения ILSPYCMD
с абсолютным путём. Сервер также автоматически находит дефолтные пути:
%USERPROFILE%\.dotnet\tools\ilspycmd.exe на Windows и
~/.dotnet/tools/ilspycmd на POSIX.
Подключение к MCP-клиенту через stdio:
your-mcp-client mcp add dotnet --scope user -- node /абсолютный/путь/к/mcp-dotnet/dist/index.js
Заметки
- Все тулы принимают абсолютные пути. Рабочая директория MCP-клиента и сервера часто различаются, поэтому сервер ничего не угадывает.
decompile-assemblyи первыйsearch-sourceна свежей сборке могут занимать от десятков секунд до нескольких минут — таймаут 10 минут.search-sourceкэширует декомпилированное дерево в<dir-сборки>/.mcp-dotnet-<имя-сборки>/. Если хочется в другое место — передайoutDirявно. Удаление каталога заставит декомпилировать заново.ilspycmdзапускается дочерним процессом, его stdin не пробрасывается. Код целевой сборки нигде не исполняется.
Лицензия
MIT.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.