
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 分