阿森克龙。McpDebugger
人工智能通过MCP(模型上下文协议)控制协同调试器。
在C#代码中添加断点,暂停执行,直到AI(如Claude)恢复它们。AI可以检查调用堆栈、查看源代码上下文和控制程序流。
运作原理
┌─────────────────┐ MCP (stdio) ┌─────────────────────────┐
│ AI (Claude) │ ◄──────────────────► │ mcpdebugger mcp │
└─────────────────┘ └───────────┬─────────────┘
│ HTTP
┌───────────▼─────────────┐
│ mcpdebugger serve │
└───────────┬─────────────┘
│ HTTP
┌───────────▼─────────────┐
│ Your Application │
│ with DebugBreak calls │
└─────────────────────────┘安装
安装CLI工具(全局)
dotnet tool install -g Asynkron.McpDebugger将客户端库添加到项目中
dotnet add package Asynkron.McpDebugger.Client快速开始
1.在代码中添加断点
using Asynkron.McpDebugger.Client;
public class MyService
{
public async Task ProcessOrderAsync(Order order)
{
// Async breakpoint - doesn't block threadpool threads
await DebugBreak.HereAsync();
// Your code continues after AI resumes...
await ValidateOrder(order);
// Another breakpoint
await DebugBreak.HereAsync();
await ChargeCustomer(order);
}
}2.启动调试服务器
mcpdebugger serve3.配置克劳德代码
增添 ~/.claude/settings.json:
{
"mcpServers": {
"debugger": {
"command": "mcpdebugger",
"args": ["mcp"]
}
}
}4.运行您的应用程序
您的应用程序将在每个时间暂停 DebugBreak 呼叫,直到AI恢复。
API
客户端库
// Async breakpoint (recommended) - doesn't steal threadpool threads
await DebugBreak.HereAsync();
// Sync breakpoint - blocks the current thread
DebugBreak.Here();
// Configure server URL (default: http://localhost:5200)
DebugBreak.Configure("http://localhost:5200");
// Disable/enable breakpoints
DebugBreak.Disable();
DebugBreak.Enable();MCP工具(可供AI使用)
| 工具 | 说明 |
|---|---|
get_breakpoints | 列出所有活动断点 |
get_context | 获取断点的调用堆栈和源代码 |
resume | 恢复特定断点 |
resume_all | 恢复所有活动断点 |
HTTP API(用于直接访问)
# List active breakpoints
curl http://localhost:5200/status
# Resume a specific breakpoint
curl -X POST http://localhost:5200/resume/{breakpoint-id}
# Resume all breakpoints
curl -X POST http://localhost:5200/resume-allCLI命令
mcpdebugger serve [--port 5200] # Start the HTTP debug server
mcpdebugger mcp [--port 5200] # Start the MCP server (for AI integration)
mcpdebugger --help # Show help断点是如何工作的
异步断点(HereAsync)用途 TaskCompletionSource 内部:
- 您的代码正在等待向调试服务器发送HTTP POST
- 服务器保存请求,直到AI调用
resume - 没有线程池线程被阻塞
同步断点(Here)简单地阻止HTTP调用:
- 调用线程被阻塞,直到恢复
- 谨慎使用,避免线程不足
从源头构建
git clone https://github.com/asynkron/Asynkron.McpDebugger.git
cd Asynkron.McpDebugger
dotnet build许可证
麻省理工学院
