JD

jimmy01240397/dnspy-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

10 stars 1 forks 质量 61 趋势 22NOASSERTION

A Model-Context-Protocol server that exposes 's static analysis and live-debug capabilities to LLM clients. Designed to make reverse-engineering a .

概览

A Model-Context-Protocol server that exposes 's static analysis and live-debug capabilities to LLM clients. Designed to make reverse-engineering a .NET binary or attached process feel as productive from a chat client as it does in the dnSpy GUI. dnspymcp talks to dnspymcpagent over persistent TCP connection (no HTTP, no per-call headers, no reconnect storms). The debug session is opened once and stays warm until the MCP server exits. ICorDebug lives under .NET Framework. For cross-version debugging the only safe host is an debugger that loads the right mscordbi.dll through ICLRMetaHost. That's the agent. The MCP-facing half lives on net9 so it can use the official ModelContextProtocol + AspNetCore packages and run side-by-side with other modern-.NET tooling. dnspymcp — when dnSpy already does the heavy work, we drive its types directly. The agent uses dndbg's DnDebugger for ICorDebug; the static surface uses dnSpy.Analyzer.x.

README

以下为原文 README 节选,完整内容请查看原文。

dnspymcp

A Model-Context-Protocol server that exposes dnSpy’s static analysis and ICorDebug live-debug capabilities to LLM clients. Designed to make reverse-engineering a .NET binary or attached process feel as productive from a chat client as it does in the dnSpy GUI.

Two binaries:

Binary TFM Role
dnspymcp net9.0 MCP server. Stdio / Streamable-HTTP / SSE transports.
dnspymcpagent net4.8 Lightweight debug backend that runs on the target host and speaks ICorDebug via dnSpy’s dndbg engine. Persistent TCP + newline-delimited JSON.

dnspymcp talks to dnspymcpagent over one persistent TCP connection (no HTTP, no per-call headers, no reconnect storms). The debug session is opened once and stays warm until the MCP server exits.


Why two binaries?

ICorDebug lives under .NET Framework. For cross-version debugging the only safe host is an out-of-process net48 debugger that loads the right mscordbi.dll through ICLRMetaHost. That’s the agent.

The MCP-facing half lives on net9 so it can use the official ModelContextProtocol + AspNetCore packages and run side-by-side with other modern-.NET tooling.


No-handroll philosophy

dnspymcp does not duplicate dnSpy’s source — when dnSpy already does the heavy work, we drive its types directly. The agent uses dndbg’s DnDebugger for ICorDebug; the static surface uses dnSpy.Analyzer.x.dll’s ScopedWhereUsedAnalyzer and every concrete analyzer node (MethodUsedByNode, TypeUsedByNode, FieldAccessNode, SubtypesNode, MethodOverridesNode, …) end-to-end. Krafs.Publicizer opens the internal types at build time so we can new them up from C# without forking dnSpy or copying any .cs file.

The thin layer in this repo is glue:

  • Services/AnalyzerDriver.cs — adapter that satisfies the WPF-coupled bits of IAnalyzerTreeNodeDataContext (Decompiler via DispatchProxy, the rest null-stubbed) so we can pull FetchChildrenInternal off any SearchNode subclass.
  • Services/WorkspaceDocumentService.cs — minimal IDsDocumentService that wraps the workspace’s opened-DLL list.
  • Services/CrossDllIndex.cs — the only legitimately hand-rolled engine, because dnSpy ships no library-accessible string-literal index (FilterSearcher lives in the WPF main project).

The result: every cross-DLL reverse_xref_* query reuses the production analyzer with full TypeRef pre-filtering, accessibility scoping, friend- assembly handling, type-equivalence and virtual-dispatch awareness.


Tool naming convention

Every MCP tool is tagged either [REVERSE] or [DEBUG] and prefixed accordingly:

  • [REVERSE] — operates on a .dll / .exe on disk via dnlib +
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →