MCP GDB服务器
](https://www.npmjs.com/package/mcp-gdb) 
一种模型上下文协议(MCP)服务器,提供GDB调试功能,供Claude或其他AI助手使用。
特性
- 启动和管理GDB调试会话
- 加载程序和堆芯转储以进行分析
- 设置断点、遍历代码和检查内存
- 查看调用堆栈、变量和寄存器
- 使用VS code集成查看源代码
- 执行任意GDB命令
安装
克劳德代码
claude mcp add gdb -- npx -y mcp-gdb克劳德桌面版
将以下内容添加到您的Claude Desktop MCP配置中:
{
"mcpServers": {
"gdb": {
"command": "npx",
"args": ["-y", "mcp-gdb"]
}
}
}从源代码安装
git clone https://github.com/signal-slot/mcp-gdb.git
cd mcp-gdb
npm install
npm run build用法
示例命令
以下是通过Claude使用GDB MCP服务器的一些示例:
启动GDB会话
Use gdb_start to start a new debugging session加载程序
Use gdb_load to load /path/to/my/program with the sessionId that was returned from gdb_start设置断点
Use gdb_set_breakpoint to set a breakpoint at main in the active GDB session运行程序
Use gdb_continue to start execution检查变量
Use gdb_print to evaluate the expression "my_variable" in the current context获取回溯
Use gdb_backtrace to see the current call stack终止会话
Use gdb_terminate to end the debugging session支持的GDB命令
gdb_start:启动新的GDB会话gdb_load:将程序加载到GDB中gdb_command:执行任意GDB命令gdb_terminate:终止GDB会话gdb_list_sessions:列出所有活动的GDB会话gdb_attach:附加到正在运行的进程gdb_load_core:加载核心转储文件gdb_set_breakpoint:设置断点gdb_continue:继续程序执行gdb_step:步骤程序执行gdb_next:跳过函数调用gdb_finish:执行直到当前函数返回gdb_backtrace:显示调用堆栈gdb_print:打印表达式值gdb_examine:检查内存gdb_info_registers:显示寄存器gdb_list_source:列出当前位置或与VS code集成的指定位置的源代码
许可证
麻省理工学院
