MCP Hub
Back to servers

gdb-mcp (gdb and rr MCP server)

MCP server that exposes GDB debugging as tools. An AI assistant can set breakpoints, run programs, step through code, inspect variables and memory, and examine registers — all via structured tool calls. Reverse debugging with rr is also supported.

glama
Forks
1
Updated
Mar 6, 2026

gdb-mcp

Experimental — expect rough edges and breaking changes.

MCP server that exposes GDB debugging as tools. An AI assistant can set breakpoints, run programs, step through code, inspect variables and memory, and examine registers — all via structured tool calls.

Reverse debugging with rr is also supported.

Requirements

  • Python 3.12+
  • uv
  • GDB on $PATH
  • rr on $PATH (optional — only needed for rr_record / start_replay_session)

Installation

uv tool install git+https://github.com/schuay/gdb-mcp.git

This installs a gdb-mcp command into an isolated environment and puts a shim on your $PATH. Upgrade later with:

uv tool upgrade gdb-mcp

Install and configure Gemini CLI

curl -fsSL https://raw.githubusercontent.com/schuay/gdb-mcp/main/install-gemini.sh | bash

This installs the tool and adds the server to ~/.gemini/settings.json. Requires jq.

Tools

Session management

ToolDescription
start_sessionSpawn a GDB process, optionally loading a binary
stop_sessionKill a session and free its resources
list_sessionsShow all active sessions with idle time and kind (gdb / rr-replay)

Time-travel debugging (rr)

rr records a full execution trace and replays it deterministically, enabling reverse-execution (reverse-continue, reverse-step, etc.).

ToolDescription
rr_recordRecord a program execution; returns trace_dir for later replay
start_replay_sessionStart an rr replay session; accepts trace_dir from rr_record, or omit to replay the latest recording

A replay session works with all standard tools, plus dedicated reverse-execution tools:

ToolDescription
reverse-continueRun backwards to the previous breakpoint or watchpoint
reverse-stepStep backwards one source line or instruction (enters calls)
reverse-nextStep backwards one source line or instruction (skips calls)
reverse-finishRun backwards to where the current function was called

Typical workflow:

rr_record("/path/to/binary", args=["--flag"])
  → { "trace_dir": "/home/user/.local/share/rr/binary-0", ... }

start_replay_session(trace_dir="/home/user/.local/share/rr/binary-0")
  → { "session_id": "a1b2c3d4", ... }

# Now use the session_id with any tool: breakpoint, run, reverse-continue, etc.

Execution control

Execution tools block until the inferior stops (breakpoint, signal, exit, or timeout). While blocked, use interrupt to send SIGINT and unblock.

ToolGDB commandDescription
runrunStart or restart the inferior
continue_execcontinueContinue after a stop
stepstep / stepiStep into next line or instruction
nextnext / nextiStep over next line or instruction
finishfinishRun until current function returns
untiluntilRun until a specific location (skip loops)
interruptSIGINTInterrupt a running inferior

Breakpoints and watchpoints

ToolGDB commandDescription
breakpointbreak / tbreakSet a breakpoint (supports conditions)
delete_breakpointsdeleteDelete one or all breakpoints
watchwatch / rwatch / awatchStop when an expression is written, read, or accessed

Threads

ToolGDB commandDescription
list_threadsinfo threadsList all threads with their current location
select_threadthread NSwitch to a specific thread

Stack frames

ToolGDB commandDescription
backtracebacktraceShow the full call stack
select_frameframe NSelect a frame by number
upupMove up toward the caller
downdownMove down toward the innermost frame

Inspection

ToolGDB commandDescription
contextframe + info args + info locals + listFull snapshot of current location, arguments, locals, and source — call this after every stop
list_variablesinfo locals / info argsVariables in the current frame
printprintEvaluate and print a GDB expression
examinexExamine memory at an address
info_registersinfo registersShow CPU register values
list_sourcelistShow source code around the current position
disassembledisassembleDisassemble a function or address range

Generic

ToolDescription
exec_commandRun any GDB command and return its output
batch_commandsRun a list of commands sequentially (fewer round-trips)

exec_command handles execution commands correctly: advance, jump, signal, and return all block until the inferior stops, just like the named tools do.

Notes

GDB plugins such as pwndbg or GEF work if installed, but their custom prompts ((pwndbg), gef>) will break session startup. Either avoid them or force the standard prompt in .gdbinit:

set prompt (gdb)

Timeout behaviour: if an execution command times out, the session is in an indeterminate state. Call interrupt to stop the inferior, wait for the blocked tool call to return, then resume normally. When in doubt, stop_session

  • start_session gives a clean slate.

Reviews

No reviews yet

Sign in to write a review