使用说明
debug-mcp.net
的MCP服务器。NET调试 --使AI代理能够进行调试。NET应用程序交互。
什么是调试mcp?
调试mcp是一个 模型上下文协议 暴露的服务器。NET调试功能作为结构化API工具。它允许像Claude、GPT或Copilot这样的AI助手:
- 启动或连接到。NET进程
- 设置断点、异常断点和跟踪点
- 逐行遍历代码
- 检查变量、计算表达式和读取内存
- 分析堆栈跟踪和线程
- 通过一次调用获取完整的异常上下文(异常尸检)
- 通过转到定义、查找用法和诊断来导航代码
- 自动解析来自公共符号服务器的符号
与通过DAP协议使用外部调试器的类似工具不同,调试mcp接口 直接与。NET运行时 使用ICorDebug API——与JetBrains Rider使用的方法相同。
快速开始
跑
# No installation needed (.NET 10+)
dnx -y debug-mcp
需求
- .NET 10 SDK或更高版本
- Linux(计划支持Windows和macOS)
使用Claude Desktop进行配置
添加到您的 claude_desktop_config.json:
{
"mcpServers": {
"dotnet-debugger": {
"command": "dnx",
"args": ["-y", "debug-mcp"]
}
}
}
使用Claude代码进行配置
添加到您的 .mcp.json:
{
"mcpServers": {
"dotnet-debugger": {
"command": "dnx",
"args": ["-y", "debug-mcp"]
}
}
}
对话示例
You: Debug my ASP.NET app and find why GetUser returns null
Claude: I'll launch your application and investigate.
[Calls debug_launch with program path]
[Calls breakpoint_set at UserService.cs:42]
[Calls debug_continue]
[Calls breakpoint_wait with 30s timeout]
The breakpoint was hit. Let me check the variables.
[Calls variables_get for current frame]
I found the issue: the `userId` parameter is an empty string.
The bug is in the calling code at line 28 where...
You: My app throws NullReferenceException somewhere in checkout. Find it.
Claude: I'll set an exception breakpoint and trigger the flow.
[Calls debug_launch with program path]
[Calls breakpoint_set_exception for System.NullReferenceException]
[Calls debug_continue]
[Calls breakpoint_wait with include_autopsy: true]
Caught it! The exception was thrown in OrderService.cs at line 87.
Here's the full context from the autopsy:
- cart.Items was null because LoadCart() returned an empty cart
- The null check at line 85 only checked cart, not cart.Items
工具(34)
| 类别 | 工具 | 描述 |
|---|---|---|
| 会话 | debug_launch, debug_attach, debug_disconnect, debug_state |
启动、停止和监视调试会话 |
| 执行 | debug_continue, debug_pause, debug_step |
控制程序流程 |
| 断点 | breakpoint_set, breakpoint_remove, breakpoint_list, breakpoint_enable, breakpoint_wait |
设置和管理源断点 |
| 异常断点 | breakpoint_set_exception |
特定异常类型的中断(第一次/第二次机会) |
| 追踪点 | tracepoint_set |
非阻塞断点,在不暂停的情况下记录消息 |
| 尸检异常 | exception_get_context |
完整异常分析:类型、消息、内部异常、带源的堆栈帧和局部变量 |
| 检查 | threads_list, stacktrace_get, variables_get, evaluate |
检查程序状态 |
| 记忆 | object_inspect, memory_read, layout_get, references_get, members_get |
深度对象和内存分析 |
| 模块 | modules_list, modules_search, types_get |
探索加载的部件和类型 |
| 代码分析 | code_load, code_goto_definition, code_find_usages, code_find_assignments, code_get_diagnostics |
Roslyn驱动的代码导航和诊断 |
| 进程I/O | process_write_input, process_read_output |
与被调试的stdin/stdout交互 |
资源(4)
| URI | 描述 |
|---|---|
debugger://session |
当前调试会话状态 |
debugger://breakpoints |
所有活动断点 |
debugger://threads |
带状态的线程列表 |
debugger://source/{file} |
源文件内容 |
文档
类似项目
| 项目 | 语言 | 方法 | 。NET支持 |
|---|---|---|---|
| mcp调试器 | TypeScript | DAP | 通过外部调试器 |
| dap-mcp | Python | DAP | 通过外部调试器 |
| LLDB MCP | C++ | 本机 | 否 |
| 调试mcp | C# | ICorDebug | 本机,直接 |
许可证
AGPL-3.0——见 许可证 了解详情。
