GDB MCP Server
Provides debugging support for programs running on Arm architectures, including aarch64-none-linux-gnu and arm-none-eabi.
Interfaces with the GNU Project Debugger (GDB) to provide execution control, memory inspection, and breakpoint management tools.
Supports remote debugging of applications and systems targeting Linux-based environments.
Enables remote debugging of programs running inside QEMU emulators by connecting to their gdbserver interface.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@GDB MCP Server connect to localhost:1234 and show the local variables at the current breakpoint"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
GDB MCP Server
MCP服务器,用于AI Agent调试嵌入式系统程序。支持交叉编译GDB工具(aarch64、arm等),远程调试(gdbserver/QEMU),提供完整的调试信息查询功能。
功能特性
多架构支持: aarch64-none-linux-gnu-gdb, arm-none-eabi-gdb, x86_64-gdb
远程调试: 连接目标板的gdbserver或QEMU模拟器
条件断点: 支持条件表达式断点
完整调试信息: 寄存器、内存、堆栈、变量、线程等
MCP集成: 作为Claude Code或其他MCP客户端的工具使用
Related MCP server: embedded-gdb-mcp
快速开始
1. 安装
npm install
npm run build2. 配置MCP客户端
在Claude Code的设置中添加:
{
"mcpServers": {
"gdb": {
"command": "node",
"args": ["C:/Users/zjm09/Documents/work/2025/gdb-mcp/dist/index.js"]
}
}
}3. 使用MCP工具
# 初始化GDB
gdb_init({architecture: "aarch64"})
# 连接目标
gdb_connect({target: "localhost:1234"})
# 加载程序
gdb_load_program({programPath: "./main"})
# 设置断点
gdb_set_breakpoint({location: "main.c:10"})
gdb_set_breakpoint({location: "factorial", condition: "n==0"}) # 条件断点
# 执行调试
gdb_run()
gdb_step()
gdb_next()
# 查看信息
gdb_list_registers()
gdb_read_registers({registers: ["pc", "sp"]})
gdb_list_locals()
gdb_evaluate_expression({expression: "x"})工具列表
连接管理
工具 | 描述 |
| 启动GDB进程 |
| 连接远程目标 |
| 断开并终止GDB |
| 加载可执行文件 |
执行控制
工具 | 描述 |
| 开始执行 |
| 继续执行 |
| 单步进入函数 |
| 单步跳过函数 |
| 执行到返回 |
| 中断执行 |
断点管理
工具 | 描述 |
| 设置断点(支持条件) |
| 删除断点 |
| 列出断点 |
| 启用断点 |
| 禁用断点 |
| 设置断点条件 |
内存/寄存器
工具 | 描述 |
| 读取内存 |
| 列出寄存器名 |
| 读取寄存器值 |
| 写入寄存器 |
堆栈/变量
工具 | 描述 |
| 列出调用栈 |
| 选择栈帧 |
| 列出局部变量 |
| 列出函数参数 |
| 计算表达式 |
线程管理
工具 | 描述 |
| 列出线程 |
| 选择线程 |
调试信息
工具 | 描述 |
| 获取当前位置 |
| 列出源文件 |
| 反汇编 |
高级
工具 | 描述 |
| 执行原始GDB MI命令 |
测试
使用QEMU模拟
cd tests/test-program
make # 交叉编译
bash start-qemu.sh # 启动QEMU等待GDB连接测试流程
启动QEMU后,使用MCP工具连接
设置断点、执行调试
查看变量、寄存器等调试信息
项目结构
gdb-mcp/
├── src/
│ ├── index.ts # MCP服务器入口
│ ├── gdb/
│ │ ├── gdb-process.ts # GDB进程管理
│ │ ├── mi-parser.ts # MI输出解析
│ │ ├── mi-commands.ts # MI命令构建
│ │ └── types.ts # 类型定义
│ ├── schemas/ # Zod验证
│ └── constants.ts # 配置常量
├── tests/
│ └ test-program/ # 测试程序
│ └ README.md
│ └ tsconfig.json
│ └ package.json开发
npm run dev # 开发模式(自动重载)
npm run build # 编译
npm run inspector # 使用MCP Inspector测试许可证
MIT
Available Tools
31 toolsgdb_command执行GDB MI命令ADestructive
直接执行GDB Machine Interface (MI)命令。
参数:
command: MI命令 (以 - 开头,如 -break-list, -exec-run)
waitForDone (可选): 是否等待完成响应 (默认true)
示例:
gdb_command({command: "-break-list"}) → 列出所有断点
gdb_command({command: "-exec-run"}) → 运行程序
高级用法:当其他工具不支持特定操作时使用。
Inputs: command (required), waitForDone.
gdb_connect连接远程目标板A
通过TCP连接到目标板的gdbserver或QEMU。
参数:
target: 目标地址,格式为 host:port (例如 192.168.1.100:1234 或 localhost:1234)
示例:
gdb_connect({target: "localhost:1234"}) → 连接本地QEMU
gdb_connect({target: "192.168.1.100:1234"}) → 连接远程目标板
Inputs: target (required).
gdb_continue继续执行A
从当前位置继续执行程序。程序将运行直到遇到断点或异常。
Inputs: no named parameters.
gdb_delete_breakpoint删除断点ADestructiveIdempotent
删除指定编号的断点。
Inputs: breakpointId (required).
gdb_disable_breakpoint禁用断点AIdempotent
禁用指定编号的断点。
Inputs: breakpointId (required).
gdb_disassemble反汇编ARead-onlyIdempotent
反汇编当前函数或指定地址范围。
参数:
start (可选): 起始地址
end (可选): 结束地址
默认反汇编当前函数。
Inputs: end, start.
gdb_disconnect断开连接并终止GDBADestructiveIdempotent
优雅地断开与目标板的连接并终止GDB进程。会先发送detach命令通知gdbserver。
Inputs: no named parameters.
gdb_enable_breakpoint启用断点AIdempotent
启用指定编号的断点。
Inputs: breakpointId (required).
gdb_evaluate_expression计算表达式ARead-onlyIdempotent
计算并返回表达式的值。
参数:
expression: 要计算的表达式 (如 x, *ptr, sizeof(var), x+y)
示例:
gdb_evaluate_expression({expression: "x"}) → 返回变量x的值
gdb_evaluate_expression({expression: "*ptr"}) → 返回指针指向的值
Inputs: expression (required).
gdb_finish执行到函数返回A
继续执行直到当前函数返回。在返回点暂停。
Inputs: no named parameters.
gdb_get_current_location获取当前位置ARead-onlyIdempotent
获取程序当前位置(源文件和行号)。
Inputs: no named parameters.
gdb_init初始化GDB调试器A
启动指定架构的GDB进程,默认使用aarch64交叉编译器。
参数:
gdbPath (可选): GDB可执行文件路径
architecture (可选): 目标架构 (aarch64/arm/x86_64)
示例:
gdb_init() → 使用默认 aarch64-none-linux-gnu-gdb
gdb_init({architecture: "arm"}) → 使用 arm-none-eabi-gdb
gdb_init({gdbPath: "/opt/gdb/my-gdb"}) → 使用自定义GDB路径
Inputs: gdbPath, architecture.
gdb_interrupt中断执行A
中断正在运行的程序。程序将暂停在当前位置。
Inputs: no named parameters.
gdb_list_arguments列出函数参数ARead-onlyIdempotent
列出当前函数的参数及其值。
Inputs: no named parameters.
gdb_list_breakpoints列出所有断点ARead-onlyIdempotent
列出当前设置的所有断点及其详细信息(包括条件)。
Inputs: no named parameters.
gdb_list_frames列出调用栈帧ARead-onlyIdempotent
列出当前的调用栈帧信息。
Inputs: no named parameters.
gdb_list_locals列出局部变量ARead-onlyIdempotent
列出当前栈帧的局部变量及其值。
Inputs: no named parameters.
gdb_list_registers列出寄存器名称ARead-onlyIdempotent
获取目标架构的所有寄存器名称列表。
Inputs: no named parameters.
gdb_list_source_files列出源文件ARead-onlyIdempotent
列出调试程序的所有源文件。
Inputs: no named parameters.
gdb_list_threads列出所有线程ARead-onlyIdempotent
列出当前程序的所有线程信息。
Inputs: no named parameters.
gdb_load_program加载可执行文件A
加载要调试的可执行文件及其符号表。
参数:
programPath: 可执行文件路径
必须在连接目标板后调用此命令。
Inputs: programPath (required).
gdb_next单步执行(跳过函数)A
执行一行代码。如果当前行包含函数调用,将跳过该函数(不进入内部)。
Inputs: no named parameters.
gdb_read_memory读取内存ARead-onlyIdempotent
从指定地址读取内存内容。
参数:
address: 内存地址 (如 0x400000)
length: 读取字节数 (1-4096)
Inputs: length (required), address (required).
gdb_read_registers读取寄存器值BRead-onlyIdempotent
读取指定寄存器的值,默认读取所有寄存器。
参数:
registers (可选): 寄存器名称列表,如 [r0, pc, sp]
Inputs: registers.
gdb_run开始执行程序A
从程序入口点开始执行。程序将运行直到遇到断点或异常。
Inputs: no named parameters.
gdb_select_frame选择栈帧AIdempotent
选择指定编号的栈帧,用于查看该层的局部变量。
参数:
frameId: 栈帧编号 (从0开始,0为当前帧)
Inputs: frameId (required).
gdb_select_thread选择线程AIdempotent
切换到指定线程进行调试。
Inputs: threadId (required).
gdb_set_breakpoint设置断点A
在指定位置设置断点,支持条件断点和临时断点。
参数:
location: 断点位置 (文件:行号 或 函数名)
condition (可选): 条件表达式,如 x>5, i==10
temporary (可选): 临时断点,触发后自动删除
示例:
gdb_set_breakpoint({location: "main.c:10"}) → 在main.c第10行设置断点
gdb_set_breakpoint({location: "factorial", condition: "n==0"}) → 条件断点
gdb_set_breakpoint({location: "main", temporary: true}) → 临时断点
Inputs: location (required), condition, temporary.
gdb_set_condition设置断点条件A
为已有断点设置或修改条件表达式。
参数:
breakpointId: 断点编号
condition: 条件表达式,如 x>5, i==10;传空字符串清空条件
示例:
gdb_set_condition({breakpointId: "1", condition: "x>5"}) → 设置条件
gdb_set_condition({breakpointId: "1", condition: ""}) → 清除条件
Inputs: condition (required), breakpointId (required).
gdb_step单步执行(进入函数)A
执行一行代码。如果当前行包含函数调用,将进入该函数内部。
Inputs: no named parameters.
gdb_write_register写入寄存器ADestructive
修改指定寄存器的值。
参数:
register: 寄存器名称 (如 r0, pc, sp)
value: 要写入的值 (如 0x1000 或 42)
警告: 此操作可能影响程序执行状态。
Inputs: value (required), register (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 31 tools
Most tools have clear distinct purposes, but some overlap exists between gdb_run/gdb_continue and gdb_next/gdb_step. The descriptions help differentiate, but an agent might still confuse similar actions.
All tools follow a consistent 'gdb_verb_noun' pattern in snake_case, making the naming predictable and easy to interpret for both agents and humans.
31 tools is high for typical MCP server coherence; while GDB debugging is complex, the count exceeds the 25-tool threshold for 'too many' and could be streamlined (e.g., combining some list operations).
The tool set covers most core GDB workflows (breakpoints, stepping, memory, registers, expressions, threads). Minor gaps like watchpoints or variable modification exist, but overall it's comprehensive.
Maintenance
Related MCP Connectors
Shared debugging memory for AI coding agents
Live browser debugging for AI assistants — DOM, console, network via MCP.
Design circuits, simulate and verify embedded firmware, and lay out PCBs with AI agents.
Agent Replay Debugger MCP — record every agent step + deterministic replay. Step-debugger for
Related MCP Servers
- AlicenseCqualityBmaintenanceEnables LLM clients to interact with the GNU Debugger (GDB) for comprehensive debugging and binary analysis. It provides a wide range of tools for program execution control, memory examination, stack analysis, and disassembly.1374GPL 3.0
- AlicenseNot gradedqualityDmaintenanceEnables GDB debugging for embedded development workflows, allowing users to start sessions, load programs, set breakpoints, step through code, and examine memory/registers/variables via natural language.3MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to interact with GDB for debugging via the MCP protocol. Supports setting breakpoints, stepping through code, inspecting memory and registers, and more.85MIT
- AlicenseBqualityDmaintenanceEnables AI agents to debug C/C++ programs with GDB or LLDB, supporting breakpoints, stepping, variable inspection, and function calls.20MIT