mcp-dotnet
mcp-dotnet
Русская версия ниже / Russian version below
LLMが**.NETアセンブリをC#として読み取る**ことを可能にする、小規模なModel Context Protocol (MCP) サーバーです。公式のILSpy CLI (ilspycmd) をstdio経由でラップしたもので、MCP対応クライアントであれば、型の一覧表示、単一クラスの逆コンパイル、アセンブリ全体のプロジェクトツリーへの逆コンパイル、または逆コンパイルされたソースコード全体に対するgrep検索が可能です。
なぜこれが必要なのか
LLMは生のILバイトコードではなく、ソースコードを読み取るのが得意です。ILSpyはすでにCILを忠実なC#に変換しますが、チャットエージェントからそれを呼び出すのは面倒です。手動で ilspycmd を実行し、出力を会話に貼り付ける必要があります。このサーバーはそのループを定型化します。
list-types: 最初に実行することで、モデルはコンテキストに数メガバイトの逆コンパイル結果をダンプすることなく、どの型を見るべきかを把握できます。decompile-type: ターゲットを絞った読み取り用。一度に1つの完全修飾クラスを読み取ります。decompile-assembly: モデルがプロジェクト全体を必要とする場合(例:プロジェクト全体のgrepを実行する前など)に使用します。search-source: 一度逆コンパイルして出力をキャッシュし、結果として得られたすべての.csファイルに対してgrepを実行します。後続の検索ではキャッシュされたツリーを再利用します。
ターゲットアセンブリは決して実行されません。すべて静的です。
また、現代の一般的なケースである**.NET 6/7/8の単一ファイルデプロイ**にも対応しています。path に公開された .exe を指定すれば、ILSpy 10以降が埋め込まれたコアアセンブリを自動的に解決します。
Related MCP server: dotnet-sherlock-mcp
ツール
ツール | 説明 |
| アセンブリ内で宣言されている型を一覧表示します。オプションの |
| 1つの完全修飾型をC#に逆コンパイルします。 |
|
|
| (一度だけキャッシュして)逆コンパイルし、C#ツリーに対して正規表現でgrepを実行します。ファイル名/行番号/スニペットを返します。 |
インストール
# 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 buildilspycmd がPATH上にない場合は、ILSPYCMD 環境変数に絶対パスを設定してください。サーバーはWindows上のデフォルトの %USERPROFILE%\.dotnet\tools\ilspycmd.exe およびPOSIX上の ~/.dotnet/tools/ilspycmd も自動的に検出します。
stdio経由でMCP対応クライアントに接続します:
your-mcp-client mcp add dotnet --scope user -- node /absolute/path/to/mcp-dotnet/dist/index.js注意事項
すべてのツールは絶対パスを受け取ります。MCPクライアントとこのサーバー間で作業ディレクトリが異なることが多いため、サーバーは推測を行いません。
decompile-assemblyおよび新しいアセンブリに対する最初のsearch-sourceは、サイズに応じて数十秒から数分かかる場合があります。タイムアウトは10分です。search-sourceはデフォルトで<assemblyDir>/.mcp-dotnet-<assemblyName>/に逆コンパイルされたツリーをキャッシュします。配置場所を制御するには明示的にoutDirを渡すか、キャッシュを削除して再逆コンパイルを強制してください。サーバーは
ilspycmdを子プロセスとして実行し、その標準入力(stdin)を公開することはありません。ターゲットアセンブリのコードが実行されることは一切ありません。
ライセンス
MIT。
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.
Тулы
Тул | Что делает |
| Список типов сборки. Опциональный фильтр |
| Декомпиляция одного типа в C#. С опциональным IL через |
| Развёртывает сборку в папку |
| Один раз декомпилирует (с кэшем), потом regex-grep по |
Установка
# 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。
Available Tools
4 toolsdecompile-assemblyA
Decompile the entire assembly into a folder of .cs files (a compilable project). Use this when you want to grep across the whole codebase. Returns the output directory and a flat list of generated files. Heavy - prefer list-types + decompile-type for targeted lookups.
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Absolute path to the assembly. | |
| outDir | Yes | Absolute path where the decompiled project tree should be written. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description discloses that the tool is 'Heavy' (resource-intensive) and returns an output directory and flat list of files. It implies writing to disk but does not specify overwrite behavior or permissions needed.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Three sentences, all essential: purpose, use case, return info, and caveat. Front-loaded and concise with no redundancy.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a tool with two simple parameters and no output schema, the description covers the return format ('output directory and flat list of generated files') and hints at the output being a compilable project, making it complete.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100%, so baseline is 3. The description does not add meaning beyond the schema's parameter descriptions, which are already clear.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb 'decompile' and the resource 'entire assembly into .cs files', and differentiates from sibling tools by specifying that it is for grepping across the whole codebase and that alternatives are better for targeted lookups.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Explicitly states when to use ('when you want to grep across the whole codebase') and when not ('prefer list-types + decompile-type for targeted lookups'), providing clear guidance for tool selection.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
decompile-typeA
Decompile a single fully-qualified type into C# source. Pass the fully qualified name as printed by list-types (e.g. 'Acme.Bot.LicenseManager').
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Absolute path to the assembly. | |
| type | Yes | Fully-qualified type name to decompile. | |
| languageVersion | No | C# language version. Default: Latest. Useful values: CSharp7_3, CSharp10_0, Latest. | |
| includeIl | No | Append IL alongside the C# (ilspycmd -il). Default: false. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations provided, so description must carry the full burden. It only states the basic action and parameter format, but omits information about output, errors, permissions, or side effects.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two sentences, no redundancy, action-first structure provides maximum information with minimal text.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Adequately describes the tool's core function and input requirements, but lacks details about output format, error handling, and usage context relative to siblings.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema descriptions cover all parameters (100% coverage), and the description adds value by specifying that the type name should come from list-types, which clarifies the expected format beyond the schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Clearly states 'Decompile a single fully-qualified type into C# source', which is a specific verb-resource combination. Distinguishes from sibling 'decompile-assembly' by targeting a single type rather than a whole assembly.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Provides a hint to use the output of list-types for the type name, but does not explicitly say when to use this tool vs alternatives or when not to use it.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list-typesA
List declared types in a .NET assembly (classes, interfaces, structs, delegates, enums). Use this first to find candidates before calling decompile-type. Works on .dll, .exe, and .NET 6+ single-file deployments (the embedded core assembly is decompiled directly).
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Absolute path to the assembly. | |
| kinds | No | Comma-separated subset of: c (class), i (interface), s (struct), d (delegate), e (enum). Default: 'c,i,s,d,e'. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Without annotations, the description discloses supported file types and special handling for single-file deployments. It implies read-only operation but does not explicitly state safety or side effects.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two sentences, no wasted words. Purpose and usage are front-loaded. Highly concise.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Completely covers the tool's purpose and relationship to sibling. Lacks output format details, but for a list tool with no output schema, this is acceptable.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100%, so baseline is 3. The description adds mapping from letters to full type names but does not provide significant additional meaning beyond the schema descriptions.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states it lists declared types in a .NET assembly, specifying categories (classes, interfaces, structs, delegates, enums). It distinguishes from sibling 'decompile-type' by advising to use this first.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Explicitly says 'Use this first to find candidates before calling decompile-type', providing clear context. Also notes compatibility with .dll, .exe, and .NET 6+ single-file deployments, but does not mention exclusions or alternatives for other siblings.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
search-sourceA
Decompile the assembly to a temporary directory then grep its C# source for a pattern. Returns the matching files with line snippets. The decompiled tree is preserved on disk for follow-up queries (path returned in 'outDir').
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Absolute path to the assembly. | |
| outDir | No | Optional output directory to reuse; otherwise a temp dir under the assembly's directory is created. | |
| pattern | Yes | JavaScript regex pattern. Case-insensitive flag is implied. | |
| maxMatches | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries full burden. It discloses that decompilation writes to a temporary directory, preserves the tree on disk for follow-up, and returns the outDir path. It does not mention safety or permissions, but the main behaviors are transparent.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Three sentences, all informative and front-loaded. The first sentence captures the core action, the second explains output, and the third adds key behavioral detail. No extraneous words.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Despite no output schema, the description explains both return values and disk persistence. It covers the necessary context for an agent to invoke the tool correctly, given the sibling tool set.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is high (75%), but the description adds value by explaining the purpose of outDir (optional reuse, returned path) and the pattern's case-insensitive nature. This provides context beyond the schema definitions.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool decompiles an assembly and then greps its C# source for a pattern, distinguishing it from sibling tools like decompile-assembly (decompilation only) and decompile-type (specific type decompilation). It specifies the output (matching files with line snippets) and the preserved disk state.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage for searching decompiled code but does not explicitly compare with siblings or state when not to use. It lacks guidance on alternatives or prerequisites.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
4 tool updates
v0.1.0- First observed
decompile-assembly - First observed
decompile-type - First observed
list-types - First observed
search-source
TDQS
Scored across 4 tools
Each tool has a clearly distinct purpose: list-types for browsing, decompile-type for a single type, decompile-assembly for full project, and search-source for pattern matching. No functional overlap.
All tool names follow a consistent lowercase hyphenated verb_noun pattern (e.g., list-types, decompile-assembly), ensuring predictability.
With 4 tools, the server is well-scoped for its domain—covering browsing, targeted decompilation, full decompilation, and source search without unnecessary redundancy.
The set covers core decompilation workflows (list, decompile single, decompile all, search). A minor gap exists for decompiling specific members without the full type, but the overall surface is sufficient for typical use.
Maintenance
Related MCP Connectors
Code intelligence for coding agents: semantic, AST, graph, and full-text search. 279+ languages.
Code intelligence for LLMs. Analyze, search, and retrieve code from any public git repository.
Neuronto Agentic Resource Discovery ARD Index. Search every ARD registry + 31,411 verified tools.
Search GitHub, npm, PyPI, StackOverflow, ArXiv from one MCP — built for coding agents.
Related MCP Servers
- AlicenseAqualityAmaintenanceA Model Context Protocol (MCP) server providing 62 AI-optimized tools for .NET/C# semantic code analysis, navigation, refactoring, and code generation using Microsoft Roslyn. Built for AI coding agents - provides compiler-accurate code understanding that AI cannot infer from reading source files alone.6232MIT
- AlicenseNot gradedqualityAmaintenanceILSpy for LLM coding agents. Reflection-based MCP server with 31+ tools to explore .NET assemblies, NuGet packages, types, members, attributes, and XML docs.8MIT
- AlicenseNot gradedqualityDmaintenanceEnables static analysis and patching of .NET binaries through decompilation, IL analysis, renaming, and IL patching over the Model Context Protocol.25MIT
- FlicenseAqualityDmaintenanceAn MCP server that decompiles and inspects .NET assemblies to C# source, wrapping ILSpy. Enables querying .NET DLLs via natural language to decompile types, list members, and search symbols.7-