Token导航 LogoToken导航TokenDH.com
MCP Netcoredbg logo
开发工具未说明官方级别未说明来源级核验

MCP Netcoredbg

MCP Server

通过netcoredbg为.NET应用程序提供调试支持,包括设置断点、单步执行代码和检查变量等功能。

工具数

25

提示词数

0

GitHub Stars

0

资源数

0
TypeScriptClaude开发工具Claude

安装说明

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

作者 / 组织

AerialByte

提供方

AerialByte

最后核验

2026/5/17 20:21

快速接入

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

详细介绍

mcp netcoredbg

的MCP服务器。NET调试通过 netcoredbg.

允许AI代理(Claude等)设置断点、遍历代码和检查中的变量。NET应用程序。

建筑

┌─────────┐     MCP      ┌─────────────────┐     DAP      ┌─────────────┐
│  Claude │ ──────────►  │ mcp-netcoredbg  │ ──────────►  │ netcoredbg  │
│         │  (tools)     │   (this repo)   │  (stdio)     │  (Samsung)  │
└─────────┘              └─────────────────┘              └──────┬──────┘
                                                                │
                                                                ▼
                                                         ┌─────────────┐
                                                         │  .NET App   │
                                                         └─────────────┘

工具

会话管理(v2.0中的新功能)

工具说明
list_sessions列出所有活动的调试会话
select_session为命令设置默认会话
terminate_session终止特定会话

启动和连接

工具说明
launch开始调试a。NET应用程序(DLL路径)
launch_watch使用热重新加载开始调试 通过 dotnet watch
stop_watch停止热重载调试模式
attach附属于跑步。NET进程
invoke调用特定方法 在程序集中(带可选调试)
restart重新启动已调试的程序(用于 launch 模式)
terminate停止调试会话

断点

工具说明
set_breakpoint在file:行设置断点(支持条件)
remove_breakpoint删除断点
list_breakpoints列出所有活动断点

执行控制

工具说明
continue继续执行
pause暂停执行
step_over跨过当前线路
step_into进入函数调用
step_out退出当前功能

检查

工具说明
stack_trace获取当前调用堆栈
scopes获取堆栈帧的变量作用域
variables从作用域获取变量
evaluate在调试上下文中计算表达式
threads列出所有线程
output获取最近的程序输出
status获取调试器状态

注: 所有工具都接受可选 sessionId 参数以针对特定会话。如果省略,则使用默认会话。

多会话调试(v2.0)

2.0版本引入了对多个同时调试会话的支持。这允许您调试多个。NET应用程序—例如API和后台工作程序。

自动生成的会话ID

当您启动调试会话而不指定 sessionId,一个是从项目/程序名称自动派生出来的:

  • TopServer.Service.Api → 会话ID: api
  • TopServer.Service.Worker → 会话ID: worker
  • MyApp.Web → 会话ID: web
  • 自定义:指定 sessionId 显式参数

示例:同时调试API+Worker

# Start API debugging
launch_watch projectPath=/path/to/MyApp.Api launchProfile=https
→ Session 'api' created

# Start Worker in a second session
launch_watch projectPath=/path/to/MyApp.Worker launchProfile=default
→ Session 'worker' created

# List all sessions
list_sessions
→ api (default): watch - /path/to/MyApp.Api [running]
   worker: watch - /path/to/MyApp.Worker [running]

# Set breakpoint in API
set_breakpoint file=/path/to/ApiController.cs line=42 sessionId=api

# Set breakpoint in Worker
set_breakpoint file=/path/to/WorkerService.cs line=100 sessionId=worker

# Continue API execution
continue sessionId=api

# Check Worker status
status sessionId=worker

# Switch default session
select_session sessionId=worker

# Now commands without sessionId go to worker
continue  # continues worker

会话管理命令

命令描述
list_sessions显示所有活动会话及其状态
select_session更改默认情况下接收命令的会话
terminate_session停止特定会话

向后兼容

如果只使用一个会话,则从v1.x开始行为不变-否 sessionId 需要参数。

方法调用(invoke)

invoke 该工具允许您从运行特定方法。NET程序集,而无需启动整个应用程序。这有助于:

  • 单独测试单个方法
  • 运行实用程序功能
  • 调试特定的代码路径,而无需遍历整个应用程序

参数

参数类型必填说明
assemblystring到的路径。NET DLL
typestringYes完全限定类型名称(例如。, MyApp.Services.Calculator)
methodstring要调用的方法名称
argsarray方法参数为JSON数组
ctorArgsarray构造函数参数(例如实例方法)
debugboolean在调试器下启动以支持断点(默认值:false)
cwdstring工作目录

例子

静态方法:

{
  "assembly": "/path/to/MyApp.dll",
  "type": "MyApp.StringUtils",
  "method": "FormatName",
  "args": ["John", "Doe"]
}

带有构造函数参数的实例方法:

{
  "assembly": "/path/to/MyApp.dll",
  "type": "MyApp.Calculator",
  "method": "Add",
  "args": [5],
  "ctorArgs": [10]
}

通过调试(支持断点):

{
  "assembly": "/path/to/MyApp.dll",
  "type": "MyApp.Calculator",
  "method": "Add",
  "args": [5],
  "debug": true
}

特性

  • 静态方法:只需提供类型、方法和参数
  • 实例方法:自动构造类型(提供 ctorArgs 如果需要)
  • 自动ILogger注射: ILogger 参数自动解析
  • 异步支持:自动等待任务返回方法
  • 控制台捕获:捕获 Console.WriteLine 输出
  • 日志捕获:捕获 ILogger 执行过程中拨打的电话
  • 丰富的错误:失败时,显示可用的构造函数/方法以帮助您修复调用

输出格式

该工具返回结构化的JSON结果:

{
  "success": true,
  "method": "MyApp.StringUtils.FormatName",
  "args": ["John", "Doe"],
  "returnType": "string",
  "returnValue": "Doe, John",
  "durationMs": 2.5,
  "logs": [
    {"level": "Information", "message": "Processing..."}
  ],
  "stdout": ""
}

出现错误时,它会提供有用的诊断:

{
  "success": false,
  "error": "Method not found",
  "errorDetails": {
    "type": "MyApp.StringUtils",
    "reason": "Method 'DoSomething' not found",
    "methods": [
      {"name": "FormatName", "params": ["string firstName", "string lastName"], "returnType": "string", "isStatic": true}
    ]
  }
}

热重载调试(launch_watch)

launch_watch 该工具支持通过以下方式进行热重载调试 dotnet watch。当您更改代码时,应用程序会自动重新启动,调试器会重新连接,从而保留断点。

参数

参数类型必填说明
projectPathstring到的路径。NET项目目录(包含.csproj)
launchProfilestring启动配置文件的名称 Properties/launchSettings.json
argsarray要传递的其他参数 dotnet watch

例子

基本用法:

{
  "projectPath": "/path/to/MyApp"
}

使用启动配置文件(建议用于ASP.NET应用程序):

{
  "projectPath": "/path/to/MyApp.Api",
  "launchProfile": "https"
}

发布配置文件对ASP很重要。NET应用程序设置:

  • ASPNETCORE_ENVIRONMENT (例如,开发)
  • applicationUrl (例如。,https://localhost:7179)
  • 正常运行所需的其他环境变量

运作原理

  1. 开始 dotnet watch run 使用指定的项目
  2. 等待应用程序构建和启动
  3. 自动将调试器附加到正在运行的进程
  4. 当您编辑代码并保存时, dotnet watch 重建和重新启动
  5. 调试器检测到重新启动并自动重新连接
  6. 断点在重启过程中得以保留

停止热重新加载模式

使用 stop_watch 彻底终止调试器和 dotnet watch 过程。

状态信息

使用 status 查看热重载的具体信息:

  • 监视进程PID
  • 子应用程序PID
  • 调试器当前是否正在重新连接

先决条件

  • netcoredbg 已安装并位于PATH中
  • Node.js 18+
  • .NET SDK 8.0+(用于构建线束和目标应用程序)

安装

# Install netcoredbg (example for Linux x64)
curl -sLO https://github.com/Samsung/netcoredbg/releases/download/3.1.3-1062/netcoredbg-linux-amd64.tar.gz
tar xzf netcoredbg-linux-amd64.tar.gz
sudo mv netcoredbg /opt/netcoredbg
sudo ln -sf /opt/netcoredbg/netcoredbg /usr/local/bin/netcoredbg

# Build this MCP server
npm install
npm run build

# The method invocation harness is auto-built on first use

使用Claude代码

快速安装:

# Clone and build
git clone https://github.com/AerialByte/mcp-netcoredbg.git
cd mcp-netcoredbg && npm install && npm run build

# Add to Claude Code
claude mcp add netcoredbg -- node $(pwd)/dist/index.js

或手动 添加到您的Claude Code MCP设置中:

{
  "mcpServers": {
    "netcoredbg": {
      "command": "node",
      "args": ["/path/to/mcp-netcoredbg/dist/index.js"]
    }
  }
}

安全

此工具启动并控制调试器。通过设计,它可以:

  • 任意执行。应用程序
  • 评估调试进程中的表达式
  • 检查内存和变量

仅将其用于您信任的代码。不要调试不受信任的应用程序。

示例会话

完整应用程序调试

  1. 建立你的。带有调试符号的.NET应用程序: dotnet build --configuration Debug
  2. 启动调试器: launch 使用DLL路径
  3. 设置断点: set_breakpoint 在file:行
  4. 继续/逐步执行代码
  5. 检查变量 scopesvariables
  6. 使用以下公式计算表达式 evaluate
  7. 完成后终止

方法调用(快速测试)

  1. 构建目标程序集: dotnet build
  2. 使用 invoke 具有类型和方法名称
  3. 如果失败,请检查可用构造函数/方法的错误
  4. 调试:先设置断点,然后使用 invoke 随着 debug: true

代理商指南

当使用此MCP服务器作为AI代理时:

选择 launchinvoke

  • 使用 invoke 当你想单独测试一个特定的方法时
  • 使用 launch 当您需要运行完整的应用程序或调试复杂的场景时

使用 invoke 有效地

  1. 简单开始:不尝试 ctorArgs 首先,线束将使用无参数构造函数或自动注入 ILogger
  1. 迭代处理错误:如果调用失败,错误响应将包括可用的方法/构造函数。使用此功能更正您的呼叫。
  1. 用于调试特定方法:
   1. Set breakpoints in the source files first
   2. Call invoke with debug: true
   3. Use continue/step_over/step_into to navigate
   4. Use output to see the final result
  1. 参数为JSON:将args作为JSON数组传递。线束控制类型转换:

- 串: "hello" - 数字: 42, 3.14 - 布尔人: true, false - 无效的: null - 物体: {"name": "Alice", "age": 30}

常见模式

测试实用方法:

invoke assembly=/path/to.dll type=MyApp.Utils method=Parse args=["input"]

使用构造函数注入进行测试:

invoke assembly=/path/to.dll type=MyApp.Service method=Process ctorArgs=[100] args=["data"]

调试失败的方法:

1. set_breakpoint file=/path/to/Service.cs line=42
2. invoke assembly=/path/to.dll type=MyApp.Service method=Process args=["bad-input"] debug=true
3. (breakpoint hits)
4. variables variablesReference=1
5. continue
6. output

许可证

麻省理工学院

目录标签

目录标签

TypeScriptClaude开发工具.NET调试本地部署代码调试变量检查断点设置

支持客户端

Claude

接入字段

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

未说明

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

session

部署方式(deploymentType,部署类型)

local-only

工具数量(toolCount,工具数)

25

资源数量(resourceCount,资源数)

0

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

0

权限和风险

未说明sessionlocal-only

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

安装前确认

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

仍需确认:installCommand

来源信息

继续浏览同类 MCP