
MCP Go Debugger

2025.04.02
1
GoGo 调试器开发工具开发效率
MCP Go Debugger 是一个专为 Go 程序设计的调试器接口,与 MCP(Model Context Protocol)集成。它提供了丰富的调试功能,包括启动和调试 Go 应用程序、附加到现有 Go 进程、设置断点、逐步执行代码、评估变量、查看堆栈跟踪等。该工具适用于开发过程中需要深入调试和问题诊断的场景,特别是对于复杂的 Go 应用程序和并发程序的调试。
View on GitHub
Overview
基本能力
产品定位
MCP Go Debugger 是一个专为 Go 程序设计的调试器接口,与 MCP(Model Context Protocol)集成,旨在提供高效的调试体验。
核心功能
- 启动和调试 Go 应用程序
- 附加到现有 Go 进程
- 设置断点
- 逐步执行代码(步入、步过、步出)
- 评估变量
- 查看堆栈跟踪
- 列出当前作用域中的所有变量
- 获取当前执行位置
- 调试单个测试函数
- 与 Delve 调试器 API 类型的原生集成
- 捕获并显示调试过程中的程序输出
- 支持调试测试时的自定义测试标志
- 具有可配置深度的详细变量检查
适用场景
- 开发过程中需要深入调试和问题诊断
- 复杂的 Go 应用程序调试
- 并发程序的调试
- 测试函数的调试
- 复杂数据结构的检查
- 命令行参数影响的调试
- 竞态条件的诊断
工具列表
ping
- 测试与调试器的连接status
- 检查调试器状态和服务器运行时间launch
- 启动一个 Go 程序进行调试attach
- 附加到一个正在运行的 Go 进程debug
- 直接调试一个 Go 源文件debug_test
- 调试一个特定的 Go 测试函数set_breakpoint
- 在特定文件和行设置断点list_breakpoints
- 列出所有当前断点remove_breakpoint
- 移除一个断点continue
- 继续执行直到下一个断点或程序结束step
- 步入下一个函数调用step_over
- 步过下一个函数调用step_out
- 步出当前函数eval_variable
- 评估一个变量的值,可配置深度list_scope_variables
- 列出当前作用域中的所有变量(局部、参数、包)get_execution_position
- 获取当前执行位置(文件、行、函数)get_debugger_output
- 从调试的程序中检索捕获的 stdout 和 stderrclose
- 关闭当前调试会话
常见问题解答
- 如何调试一个特定的测试函数?使用
debug_test
工具。 - 如何检查复杂数据结构?使用
eval_variable
工具并配置适当的深度。 - 如何调试带有命令行参数的程序?在
launch
命令中指定参数。
使用教程
使用依赖
- Go 1.20 或更高版本
安装教程
使用 Go 安装
go install github.com/sunfmin/mcp-go-debugger/cmd/mcp-go-debugger@latest
从源码构建
git clone https://github.com/sunfmin/mcp-go-debugger.git
cd mcp-go-debugger
make install
配置
Cursor 配置
在 ~/.cursor/mcp.json
中添加:
{
"mcpServers": {
"go-debugger": {
"command": "mcp-go-debugger",
"args": []
}
}
}
Claude Desktop 配置
claude mcp add go-debugger mcp-go-debugger
调试方式
测试连接
/mcp
调试 Go 程序
> Please debug my Go application main.go
附加到运行中的进程
> Attach to my Go application running with PID 12345
调试测试函数
> Please debug the TestCalculateTotal function in my calculator_test.go file
检查复杂数据结构
> Can you eval the user.Profile.Preferences object at line 45? I need to see all nested fields in detail.
调试带有命令行参数的程序
> Debug my data_processor.go with the arguments "--input=data.json --verbose --max-records=1000"
调试并发程序
> I think I have a race condition in my worker pool implementation. Can you help me debug it?
逐步执行函数调用
> Walk me through what happens when the processPayment function is called with an invalid credit card