Token导航 LogoToken导航TokenDH.com
Dot Net MCP logo
AI代理stdio官方级别未说明来源级核验

Dot Net MCP

MCP Server

DotNet MCP是一个基于MCP协议的.NET程序集分析与修改工具,支持加载、分析、搜索和修改.NET程序集,适用于AI辅助开发和逆向工程。

工具数

41

提示词数

0

GitHub Stars

4

资源数

0
逆向工程C#ClaudeClaude DesktopClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

xjoker

提供方

xjoker

最后核验

2026/5/17 20:22

运行时

Docker

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

docker run -p 5000:5000 \

详细介绍

DotNet MCP

英语| 中文

v0.0.3 -纯C#架构、统一MCP服务器和后端

A.NET程序集逆向工程和基于MCP(模型上下文协议)的修改工具。

文档

概述

DotNet MCP是一个提供。NET程序集分析和AI助手(如Claude)的修改功能。通过MCP协议,AI可以:

  • 加载并分析。NET程序集(DLL/EXE)
  • 将类型和方法分解为C#源代码或IL
  • 搜索类型、方法和字符串(支持正则表达式/高级语法)
  • 分析调用图、控制流图和依赖关系图
  • 检查继承链、接口实现和方法重写
  • 检测设计模式(Singleton、Factory、Observer等)
  • 检测混淆并识别所使用的混淆器
  • 自动检测Unity游戏组装路径
  • 注入代码并修改程序集

建筑

flowchart TB
    subgraph Client["Claude / IDE"]
    end

    Client -->|"MCP Protocol (stdio/HTTP)"| Server

    subgraph Server["DotNetMcp.Server"]
        Tools["MCP Tools (41)
Assembly | Search | Analysis | Modification | Instance"]
        Registry["Backend Registry
(Local / Remote)"]
        Tools --> Registry
    end

    Server --> Backend

    subgraph Backend["DotNetMcp.Backend"]
        Analysis["Core Analysis
Decompiler | CallGraph | CFG | XRef | Search"]
        Modification["Core Modification
ILBuilder | CodeInjector | TypeFactory | Rewriter"]
    end

安全

API密钥验证

后端服务支持HTTP终结点的API密钥身份验证。

快速设置:

export API_KEYS="your-secret-key"

支持的标头:

  • X-API-Key: your-api-key
  • Authorization: Bearer your-api-key

排除的路径: /, /health, /openapi (无需身份验证)

备注:在生产中,始终配置API密钥。如果在没有配置API密钥的情况下在生产中运行,系统将记录严重警告。

多后端架构

flowchart TB
    Client["Claude / IDE"] -->|"MCP Protocol"| Server

    subgraph Server["DotNetMcp.Server"]
        Registry["Backend Registry"]
    end

    Registry --> Local["Local Backend
(In-Process)"]
    Registry -->|"HTTP + API Key"| Remote1["Remote Backend 1"]
    Registry -->|"HTTP + API Key"| Remote2["Remote Backend 2"]

通过AI进行后端管理

# Register backend with API Key authentication
User: Register remote backend http://server:5000 with API key "secret123"

AI: [Call register_remote_backend
     id="analysis-1"
     name="Analysis Server"
     endpoint="http://server:5000"
     apiKey="secret123"]

    Successfully registered remote backend "Analysis Server"

# List all backends
User: List all backends

AI: [Call list_backends]

    Available backends:
    - local (default) - Local, Healthy
    - analysis-1 - Remote, Healthy

# Set default backend
User: Use analysis-1 as default

AI: [Call set_default_backend id="analysis-1"]

    Default backend set to "analysis-1"

参数 register_remote_backend:

参数必填说明
id唯一后端ID
name显示名称
endpointHTTP URL
apiKey没有用于身份验证的API密钥
timeoutSeconds超时(默认值:30)

快速开始

选项A:下载预构建二进制文件(不需要.NET SDK)

  1. 首选 并下载适用于您平台的zip:
平台文件
Windows x64DotNetMcp-win-x64.zip
Linux x64DotNetMcp-linux-x64.zip
Linux ARM64DotNetMcp-linux-arm64.zip
macOS x64DotNetMcp-osx-x64.zip
macOS ARM64(苹果硅)DotNetMcp-osx-arm64.zip
  1. 拉开拉链。您将找到一个可执行文件: DotNetMcp.Server (或 DotNetMcp.Server.exe 在Windows上)。
  1. 仅限macOS/Linux --使其可执行:
   chmod +x /path/to/DotNetMcp.Server
  1. 配置Claude桌面--添加到 claude_desktop_config.json:

- 视窗: %APPDATA%\Claude\claude_desktop_config.json - macOS: ~/Library/Application Support/Claude/claude_desktop_config.json - Linux: ~/.config/Claude/claude_desktop_config.json

   {
     "mcpServers": {
       "dotnet-mcp": {
         "command": "/path/to/DotNetMcp.Server",
         "args": ["--stdio"]
       }
     }
   }

替换 /path/to/DotNetMcp.Server 以及提取的可执行文件的实际路径。

  1. 重新启动克劳德桌面。工具现在可用。

选项B:从源代码构建(需要.NET 10.0 SDK)

git clone https://github.com/xjoker/DotNetMCP.git
cd DotNetMCP
dotnet build

在stdio模式下运行(适用于Claude Desktop):

dotnet run --project src/DotNetMcp.Server -- --stdio

配置Claude Desktop(源代码构建):

{
  "mcpServers": {
    "dotnet-mcp": {
      "command": "dotnet",
      "args": [
        "run",
        "--project",
        "/path/to/DotNetMCP/src/DotNetMcp.Server",
        "--",
        "--stdio"
      ]
    }
  }
}

克劳德代码/其他MCP客户端

# Stdio mode — using the pre-built binary
claude mcp add dotnet-mcp -- /path/to/DotNetMcp.Server --stdio

# HTTP mode — start server first, then register
dotnet run --project src/DotNetMcp.Server &
claude mcp add dotnet-mcp --transport http --url http://localhost:5000/mcp

MCP工具

装配管理(4)

工具说明
load_assembly加载a。NET程序集
list_assemblies列出已加载的程序集
unload_assembly卸载组件
detect_unity_assembly自动检测Unity游戏目录中的Assembly-CSharp.dll

搜索工具(2)

工具说明
search_types按关键字搜索类型
search_strings搜索字符串文字

分析工具(20)

工具说明
decompile_type将类型分解为C#/IL(支持PDB原始源代码)
decompile_method精确分解单个方法
find_type_references查找类型引用
find_method_calls查找方法调用
get_call_graph构建调用图
get_control_flow_graph构建控制流图(Mermaid)
get_type_outline获取基于元数据的类型大纲(无需反编译)
plan_chunking计划LLM友好的源代码块
compare_assemblies比较两个组件的结构差异
batch_decompile在一次调用中分解多个成员
get_dependency_graph构建程序集/命名空间/类型依赖关系图(Mermaid)
detect_design_patterns检测Singleton、Factory、Observer和其他设计模式
find_base_types查找类型的基类链和接口
find_derived_types查找从给定类型继承的所有类型
get_implementations查找接口的所有实现
get_overrides查找虚拟/抽象方法的所有重写
get_overloads查找类型中方法的所有重载
enhanced_search具有高级语法的统一搜索(正则表达式/+/-/精确/模糊/令牌)
detect_obfuscation检测混淆,识别混淆者,评分0-100
warm_index预构建类型和成员索引,以实现更快的后续查询

修改工具(6)

工具说明
inject_at_entry在方法入口注入代码
replace_method_body用原始IL指令替换方法体
replace_method_body_with_csharp使用C#源代码替换方法体(Roslyn编译+Cecil合并)
add_type添加新类型
save_assembly保存修改后的组件
generate_patch_skeleton生成Harmony补丁骨架代码

实例管理

后端管理(5)

工具说明
list_backends列出所有后端
register_remote_backend注册远程后端
unregister_backend注销后端
set_default_backend设置默认后端
check_backend_health检查后端运行状况

装配别名管理(4)

工具说明
register_assembly_alias为加载的程序集MVID注册一个短别名
unregister_assembly_alias删除以前注册的别名
list_assembly_aliases列出所有已注册的别名(alias→ MVID映射)
instance_restore_persisted从上一个会话中保存的持久别名重新加载程序集

使用示例

加载和分析组件

User: Load /path/to/MyApp.dll and tell me what types it contains

AI: [Call load_assembly]
    [Call search_types keyword=""]

    Loaded assembly MyApp.dll, containing the following types:
    - MyApp.Program (class, 5 methods)
    - MyApp.Services.UserService (class, 10 methods)
    ...

分解和分析

User: Decompile the UserService class

AI: [Call decompile_type typeName="MyApp.Services.UserService"]

    public class UserService
    {
        private readonly IDatabase _db;

        public User GetUser(int id)
        {
            return _db.Query().FirstOrDefault(u => u.Id == id);
        }
        ...
    }

注入代码

User: Add logging at GetUser method entry

AI: [Call inject_at_entry
     methodFullName="MyApp.Services.UserService.GetUser"
     instructions=[
       {"opCode": "ldstr", "stringValue": "GetUser called"},
       {"opCode": "call", "stringValue": "System.Console::WriteLine"}
     ]]

    Logging code injected at GetUser method entry.

测试

# Run all tests
dotnet test

# Run Server tests only
dotnet test tests/DotNetMcp.Server.Tests

# Run Backend tests only
dotnet test tests/DotNetMcp.Backend.Tests

当前测试状态:

  • 后端测试:135通过
  • 服务器测试:96通过

项目结构

DotNetMCP/
├── src/
│   ├── DotNetMcp.Server/          # MCP Server
│   │   ├── Tools/                 # MCP Tool implementations
│   │   ├── Backend/               # Backend registration & management
│   │   └── Configuration/         # Configuration
│   └── DotNetMcp.Backend/         # Core Backend
│       ├── Core/
│       │   ├── Analysis/          # Analysis services
│       │   ├── Modification/      # Modification services
│       │   ├── Context/           # Assembly context
│       │   └── Identity/          # ID system
│       ├── Services/              # Business services
│       └── Controllers/           # HTTP API
├── tests/
│   ├── DotNetMcp.Server.Tests/    # Server unit tests
│   └── DotNetMcp.Backend.Tests/   # Backend unit tests
└── docs/
    ├── zh/                        # Chinese docs
    └── en/                        # English docs

技术栈

  • .NET 10.0 -运行时间
  • 模型上下文协议 -MCP-SDK
  • 单声道。塞西尔 -装配操作
  • ICSharpCode。反编译器 -反编译
  • 微软。代码分析 -罗斯林汇编

Docker 部署

没有发布预构建的Docker镜像。从源构建映像:

塑造形象

git clone https://github.com/xjoker/DotNetMCP.git
cd DotNetMCP
docker build -t dotnet-mcp .

运行(HTTP模式)

服务器在Docker中以HTTP模式运行。装载包含要分析的DLL/EXE文件的目录:

docker run -p 5000:5000 \
  -v /path/to/your/assemblies:/data \
  dotnet-mcp

服务器将在以下时间可用 http://localhost:5000. 健康检查端点: http://localhost:5000/health

在Claude内部加载组件时,使用容器路径(例如。 /data/MyApp.dll).

使用API密钥运行

docker run -p 5000:5000 \
  -v /path/to/your/assemblies:/data \
  -e API_KEYS="your-secret-key" \
  dotnet-mcp

将Claude连接到Docker容器

容器运行后,将其注册为MCP服务器:

claude mcp add dotnet-mcp --transport http --url http://localhost:5000/mcp

或添加到 claude_desktop_config.json 手动(Claude Desktop的内置MCP不支持HTTP传输,请使用stdio二进制文件进行桌面使用)。

环境变量

变量默认值描述
ASPNETCORE_URLShttp://+:5000收听地址
API_KEYS*(无)*用于身份验证的逗号分隔API密钥
TZUTC时区
备注:标准模式(--stdio)不适用于Docker。使用HTTP模式并通过以下方式连接Claude http://localhost:5000/mcp.

许可证

麻省理工学院

目录标签

目录标签

逆向工程C#Claude本地部署程序集分析代码注入AI辅助开发MCP协议

支持客户端

Claude DesktopClaude

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

api-key

运行时(runtime,运行环境)

Docker

工具数量(toolCount,工具数)

41

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdioapi-key部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP