
Gdbstub Mcp
io.github.0xmortuex由 GitHub 账号 0xmortuex 发布v0.1.0更新于 Oct 25, 2026
Debug kernels through QEMU's gdbstub with no gdb binary - and explain triple faults.
概览
该 MCP 服务器让 AI 助手无需 gdb 二进制,即可通过 GDB 远程串行协议调试在 QEMU 中运行的内核。
- 可以做什么
- 连接并管理针对 QEMU gdbstub 的调试会话,可加载 ELF 获取符号
- 读写寄存器和内存,解码标志位并符号化指针
- 设置、列出和删除断点与观察点,然后继续、等待、中断或单步执行
- 查看调用栈、反汇编代码,并解析地址、符号和源码行
- 根据 QEMU 中断日志解释崩溃或三重故障
- 适用场景
- 适合在开发或调试自制操作系统内核时使用,尤其是内核在 QEMU 中还没输出任何内容就崩溃,或在 Windows、macOS 上难以安装跨架构 gdb 的情况。它适合在机器层面检查寄存器、内存、断点和调用栈,并从 QEMU 日志诊断三重故障。它不是源码级调试器:目前没有 next/finish、局部变量和 C 表达式,故障解释仅支持 x86 日志(R61、R65)。
- 运行要求
- 本地 Python 3.10+ 进程,从 PyPI 安装(pip install gdbstub-mcp),以 stdio 服务器方式运行。需要一个已启用 gdbstub 的 QEMU 实例(例如 -s -S,默认端口 1234),若要解释故障还需 QEMU 的 -d int,cpu_reset 日志文件。未声明账号、API 密钥或环境变量。
安装
在 SourceWeft 中
- 打开 控制台中的 Gdbstub Mcp,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
gdbstub-mcp
Let your AI agent debug a kernel, and tell you why it triple-faulted.
gdbstub-mcp is an MCP server that gives AI agents
(Claude Code, or any MCP client) a debugger for bare-metal code running in QEMU. It
speaks the GDB Remote Serial Protocol directly to QEMU's built-in gdbstub, so you
don't need a gdb binary. That matters most on Windows and macOS, where a
cross-architecture gdb is a pain to get.
It's the companion to qemu-mcp. qemu-mcp lets an agent boot a kernel and see the crash. gdbstub-mcp lets it find out why.
What it looks like
An agent debugging a hobby kernel. This is real output, captured from the test
kernel in tests/fixtures/kernel:
And when the machine silently reboots, debug_explain_fault reads QEMU's interrupt
log and explains the crash:
A real QEMU log of a crash is thousands of lines of timer interrupts and register dumps. This tool picks out the exception chain, decodes the error codes, and points at the cause.
Why another debugger MCP?
Existing GDB MCP servers wrap a gdb binary and target userland programs or core
dumps. The embedded ones target microcontrollers through probe-rs or OpenOCD.
None of them is built for the osdev loop: a kernel you wrote yourself, running in
QEMU, crashing before it can print anything.
- No gdb required. It's pure Python (
pyelftools+capstone). Runpip install gdbstub-mcpand you're set. - Any architecture QEMU supports. The register layout comes from the stub's own
target.xml. Control registers (CR0/CR2/CR3/CR4, EFER) are there on x86, and flag registers are decoded. - Symbols and source lines. Break on
kmain,kmain+0x10orkernel.c:42, and every stop showsfunction+offset at file:line. Prefixed ABIs work too:kmainresolves tomort_kmainwhen that name is unique. - Backtraces that work on real kernels. It walks the frame-pointer chain, and
handles x86 prologues and epilogues correctly. For
-O2kernels without frame pointers it can scan the stack for return addresses instead. - Triple-fault diagnosis.
debug_explain_fault, described above. I haven't found another tool that does this.
Install
Claude Code:
Other MCP clients use the same idea: run gdbstub-mcp as a stdio server. Python 3.10+.
Usage
Start QEMU with its gdbstub on, with the CPU halted:
-sopens the stub ontcp::1234.-Shalts the CPU before the first instruction.-d int,cpu_reset -D int.log -no-rebootis only needed fordebug_explain_fault.
With qemu-mcp, pass the same flags through
qemu_boot's extra_args:
extra_args="-s -S -d int,cpu_reset -D int.log -no-reboot".
Then ask your agent something like "connect to the kernel with kernel.elf, break in kmain, and step until the page fault".
Addresses can be written as 0x1234, symbol, symbol+0x10, file.c:42 or $esp+8.
Tools
Limits (honest ones)
- Machine-level, not source-level. There's no
next/finish, and no local variables or C expressions yet (see BACKLOG.md). You get symbols, lines, registers, memory and disassembly, which covers most kernel debugging. - Stack scanning is a heuristic. It reports any stack word that points just after
a
callinside a known function, so stale frames can appear. Build with-fno-omit-frame-pointerfor exact backtraces. debug_explain_faultunderstands x86 logs only.- Tested against QEMU's gdbstub. Other RSP stubs (OpenOCD, Bochs, real-hardware probes) speak the same protocol and will likely work, but they're untested.
Tests
Unit tests use a fake gdbstub on a real TCP socket, plus a real QEMU log of a triple
fault, so they need no QEMU. tests/test_qemu_integration.py boots the fixture kernel
in real QEMU (CI installs qemu-system-x86). It checks breakpoints, watchpoints, line
numbers, a 4-deep backtrace and an end-to-end triple fault, and skips itself if QEMU
isn't installed. To rebuild the fixture kernel, run python tests/fixtures/kernel/build.py,
which needs pip install ziglang.
License
MIT
来源:README.md,提交 eb8a35c
工具
0版本历史
1- v0.1.0最新Oct 11, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分