I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

gdb-mcp-server
3 years
Works with Finder
1
Github Watches
0
Github Forks
17
Github Stars
GDB MCP 服务器
一个支持人工智能辅助调试的 GDB MCP (Model Context Protocol) 服务器。该服务器允许 AI 代理和其他工具通过 MCP 协议与 GDB 进行交互。
注意:本项目目前处于开发阶段。我们欢迎社区成员提出建议和反馈,帮助我们改进这个工具。
项目地址:https://github.com/yywz1999/gdb-mcp-server
特性
- 发现并附加到现有的 GDB 进程
- 通过终端窗口与 GDB 通信(macOS 上优化支持 iTerm2)
- 支持 MCP 协议,便于与 AI 助手集成
- 智能处理 GDB 命令阻塞,自动发送中断信号
- 支持多架构、多主机和远程调试场景
- 通过简单的函数调用执行常见的 GDB 调试操作:
- 设置和删除断点
- 单步执行代码
- 检查内存
- 查看寄存器和堆栈跟踪
- 反汇编代码
- 获取局部变量
演示视频
项目包含一个演示视频,展示了如何使用 GDB MCP 服务器进行附加调试的完整工作流程:
https://github.com/user-attachments/assets/dbb5c2dc-1bc9-4a19-86d7-c967725bc145
通过观看此视频,您可以更直观地了解 GDB MCP 服务器如何简化多架构和远程调试场景。
使用说明(以Cursor为例)
- 下载项目并验证:
git clone https://github.com/yywz1999/gdb-mcp-server.git
cd gdb-mcp-server
python3 -m pip install -r requirements.txt
python3 ~/MCP_server/gdb-mcp-server/mcp_server.py
结果如下图所示,即为环境正常
- 配置Cursor:
最新改进
1. 增强的 iTerm2 支持
- 优化了 iTerm2 会话查找和交互机制
- 使用直接命令写入方式,无需切换窗口焦点
- 支持基于会话内容识别 GDB 会话
2. 智能阻塞处理
- 自动检测可能导致阻塞的命令(如远程连接、继续执行等)
- 使用超时机制识别阻塞状态
- 在检测到阻塞时自动发送中断信号
- 提取并返回部分执行结果
3. 更可靠的输出捕获
- 使用唯一标记标识命令输出范围
- 智能移除 GDB 提示符和命令回显
- 多尝试机制确保命令响应可靠性
技术实现简介
GDB MCP 服务器使用以下技术实现 GDB 的控制和通信:
-
MCP 协议实现:使用 FastMCP 库提供符合 Model Context Protocol 规范的工具接口
-
多种通信策略:
- AppleScript:在 macOS 上与 iTerm2 通信(推荐)
- pexpect:直接与 GDB 进程通信(Linux 优先)
- 键盘模拟:作为最后的回退方案
-
进程发现:自动查找系统中运行的 GDB 进程,无需用户手动指定进程 ID
测试环境
- 操作系统:macOS(Intel架构)
- Python版本:Python 3.11
- 终端:iTerm2
安装
-
克隆仓库:
git clone https://github.com/yywz1999/gdb-mcp-server.git cd gdb-mcp-server
-
安装依赖:
python3 -m pip install -r requirements.txt
使用方法
-
启动服务器:
python3 mcp_server.py
-
使用 MCP 协议通过服务器与 GDB 交互。服务器提供以下工具函数:
系统工具
-
sys_find_gdb_processes
- 查找所有运行的 GDB 进程 -
sys_attach_to_gdb
- 附加到 GDB 进程 -
sys_start_gdb_with_remote
- 启动 GDB 并连接到远程目标
GDB 调试工具
-
gdb_execute_command
- 执行任意 GDB 命令 -
gdb_set_breakpoint
- 设置断点 -
gdb_delete_breakpoint
- 删除断点 -
gdb_step
- 单步执行 -
gdb_next
- 执行到下一行 -
gdb_finish
- 执行到函数返回 -
gdb_continue
- 继续执行 -
gdb_get_registers
- 获取寄存器值 -
gdb_examine_memory
- 检查内存 -
gdb_get_stack
- 获取堆栈跟踪 -
gdb_get_locals
- 获取局部变量 -
gdb_disassemble
- 反汇编代码 -
gdb_connect_remote
- 连接到远程调试目标
-
macOS 上的最佳实践
在 macOS 上使用 GDB MCP 服务器时,建议:
- 使用 iTerm2 作为终端模拟器(提供最佳支持)
- 确保 GDB 终端窗口在启动服务器前已打开
- 对于远程调试,建议先手动在 GDB 中设置相关配置,然后通过 MCP 服务器附加
故障排除
macOS 上的常见问题
- 窗口激活问题:如果 GDB 窗口无法正确激活,尝试手动将其置于前台
- 输入法状态:确保 GDB 终端未处于中文或其他输入法状态
- 命令阻塞:对于阻塞的命令(如 target remote),服务器会自动发送中断信号
Linux 上的常见问题
- TTY 权限:确保当前用户有权限访问 GDB 进程的 TTY 设备
- pexpect 依赖:确保已安装 pexpect 库
许可证
本项目采用 MIT 许可证 - 详见 LICENSE 文件
相关推荐
Converts Figma frames into front-end code for various mobile frameworks.
I find academic articles and books for research and literature reviews.
Confidential guide on numerology and astrology, based of GG33 Public information
Embark on a thrilling diplomatic quest across a galaxy on the brink of war. Navigate complex politics and alien cultures to forge peace and avert catastrophe in this immersive interstellar adventure.
Advanced software engineer GPT that excels through nailing the basics.
💬 MaxKB is an open-source AI assistant for enterprise. It seamlessly integrates RAG pipelines, supports robust workflows, and provides MCP tool-use capabilities.
The all-in-one Desktop & Docker AI application with built-in RAG, AI agents, No-code agent builder, MCP compatibility, and more.
Micropython I2C-based manipulation of the MCP series GPIO expander, derived from Adafruit_MCP230xx
MCP server to provide Figma layout information to AI coding agents like Cursor
Reviews

user_lpPt1O94
I've been using the gdb-mcp-server by yywz1999 for a while now and it has significantly improved my debugging workflow. The setup is straightforward and the server integration is seamless. I highly recommend checking it out at https://github.com/yywz1999/gdb-mcp-server for anyone looking for a reliable and efficient solution to enhance their development environment.