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.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。