
Gdbstub Mcp
io.github.0xmortuexPublished by GitHub account 0xmortuexv0.1.0Updated Oct 25, 2026
Debug kernels through QEMU's gdbstub with no gdb binary - and explain triple faults.
Overview
An MCP server that lets an AI assistant debug bare-metal kernels running in QEMU over the GDB Remote Serial Protocol, without a gdb binary.
- What you can do
- Connect to and manage debug sessions against a QEMU gdbstub, optionally loading an ELF for symbols
- Read and write registers and memory, with decoded flags and symbolized pointers
- Set, list and remove breakpoints and watchpoints, then continue, wait, interrupt or single-step
- Inspect the call stack, disassemble code, and resolve addresses, symbols and source lines
- Explain a crash or triple fault from a QEMU interrupt log
- When to use it
- Useful when developing or debugging a hobby or hobbyist OS kernel that crashes in QEMU before it can print anything, especially on Windows or macOS where a cross-architecture gdb is hard to install. It suits machine-level inspection of registers, memory, breakpoints and backtraces, and diagnosing triple faults from QEMU logs. It is not a source-level debugger: there is no next/finish, no local variables and no C expressions yet, and fault explanation covers x86 logs only (R61, R65).
- Requirements
- Local Python 3.10+ process installed from PyPI (pip install gdbstub-mcp), run as a stdio server. Needs a QEMU instance started with its gdbstub enabled (for example -s -S, default port 1234) and, for fault explanation, a QEMU -d int,cpu_reset log file. No accounts, API keys, or environment variables are declared.
Installation
In SourceWeft
- Open Gdbstub Mcp in the dashboard and add it to a workspace.
- Enable the server for the chats that should use its tools.
Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.
Other MCP clients
Follow the launch instructions in the repository.
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
Source: README.md at commit eb8a35c
Tools
0Version history
1- v0.1.0LatestOct 11, 2026
Score
50% of the applicable checks met
How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.
- Reached in the last 30 days25 pts
Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.
- Auth declared10 pts
Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.
- Tools listed15 pts
Answer tools/list without a credential, or ship a package that starts in a sandbox without one.
- DescriptionRequired15 pts
- Logo10 pts
- Documentation15 pts
- License10 pts