gdb-mcp
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 debug remote binary with breakpoint at main"
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 is a high-privilege Model Context Protocol (MCP) server that allows Codex to control the GDB debugger via the GDB/MI interface and the pygdbmi library.
Supported deployment architectures for this project:
Windows 上的 Codex
-> Windows 上的 gdb-mcp MCP 服务端
-> Windows 本地 GDB
-> target remote / target extended-remote
-> linux 虚拟机中的 gdbserver
-> 虚拟机内的目标程序This server is specifically designed for local authorized debugging, CTF Pwn challenges, crash analysis, Core Dump analysis, exploit reproduction, and ELF file analysis. High-risk GDB commands are not permanently disabled; the first execution will return a warning, and the caller can run them by passing confirm=true upon retry.
Tool List
gdb_session: Start, stop, restart, and status query for local GDB sessionsgdb_load: Load local binaries, core files, symbol files, and startup argumentsgdb_exec: General GDB CLI command execution entry pointgdb_mi: Native GDB/MI command execution entry pointgdb_remote: Configure and connect to the virtual machine'sgdbservergdb_context: View registers, stack, disassembly, call stack, breakpoints, memory maps, and shared librariesgdb_memory: Memory read, write, search, and dumpgdb_register: Register read and writegdb_breakpoint: Normal breakpoints, hardware breakpoints, temporary breakpoints, and watchpointsgdb_run_control: Run, continue, step into, step over, instruction-level step, finish function, interrupt, kill program, and restartgdb_analyze: Crash and exploit feasibility analysisgdb_elf: Security checks (checksec), ELF headers, sections, segments, symbols, GOT/PLT, relocations, and stringsgdb_pwndbg: Compatible execution of pwndbg/gef/peda commands
All tools return a unified JSON structure:
{
"ok": true,
"tool": "gdb_exec",
"action": "exec",
"risk_level": "low",
"need_confirm": false,
"executed_with_risk": false,
"warning": null,
"data": {},
"stdout": "",
"stderr": "",
"raw": {},
"error": null
}Related MCP server: pwndbg-lldb-mcp
Installation
git clone https://github.com/traver88/gdb-mcp.gitThe supported runtime environment for this project is Python 3.12.
Windows Environment: Codex + Windows gdb-mcp + Virtual Machine gdbserver
Install Python isolated environment in the project directory
python --version
python -m venv .venv
.\.venv\Scripts\activate
pip install -e .Windows: Install GDB
Method A: MSYS2 MinGW64 GDB
Install MSYS2
Open MSYS2 MinGW64 terminal
Execute:
pacman -Syu # 之后重启 MSYS2
pacman -S gdb gdb-multiarchAdd
C:\msys64\mingw64\binto WindowsPATHVerify:
gdb --version
gdb-multiarch --versionRun smoke_test
gdb-mcp项目目录下:
.\.venv\Scripts\activate
python tests\smoke_test.pySuccess will output:
smoke test passedsmoke_test.py test content:
Start Windows local GDB
Load test program compiled from
examples/hello.cSet breakpoint at
mainRun program
Read registers
Read stack
Disassemble
Close GDB
Virtual Machine (Ubuntu/Kali) Configuration
Install gdbserver
sudo apt update
sudo apt install -y gdbserver gdb gcc make binutils fileStart target program
cd xxx/xxx/
gdbserver 0.0.0.0:1234 ./pwnWindows side connectivity test
powershell:
ping 192.168.56.101
Test-NetConnection 192.168.56.101 -Port 1234Codex Configuration config.toml
[mcp_servers.gdb-mcp]
command = "D:\\gdb-mcp\\.venv\\Scripts\\python.exe"
args = ["D:\\gdb-mcp\\server.py"]command: Points to the Python program that starts the MCP serverargs: Points to theserver.pyserver entry point
Codex Usage Example
Requirement example:
请使用 gdb-mcp:
- 启动 GDB
- 加载本地符号文件 E:/ctf/pwn/pwn
- 连接 192.168.56.101:1234 的 gdbserver
- 在 main 下断点
- continue
- 显示寄存器、栈、RIP 附近反汇编、backtraceEquivalent MCP call:
gdb_session(action="start")
gdb_remote(
action="connect",
host="192.168.56.101",
port=1234,
mode="remote",
local_binary="E:/ctf/pwn/pwn",
confirm=true
)
gdb_breakpoint(action="add", location="main")
gdb_run_control(action="continue")
gdb_register(action="read_all")
gdb_memory(action="read", address="$rsp", size=160)
gdb_exec(command="x/20i $rip")
gdb_exec(command="bt")
gdb_context(depth=20)Equivalent GDB command:
file "E:/ctf/pwn/pwn"
target remote 192.168.56.101:1234
b main
c
info registers
x/20gx $rsp
x/20i $rip
btExtended remote mode
Virtual machine:
gdbserver --multi 0.0.0.0:1234MCP call:
gdb_remote(
action="connect",
host="192.168.56.101",
port=1234,
mode="extended-remote",
local_binary="E:/ctf/pwn/pwn",
remote_binary="/xxx/pwn",
confirm=true
)
gdb_breakpoint(action="add", location="main")
gdb_run_control(action="run")
gdb_context(depth=20)Internal GDB command:
file "E:/ctf/pwn/pwn"
set remote exec-file /xxx/pwn
target extended-remote 192.168.56.101:1234FAQ
Windows cannot ping the virtual machine: Check VM IP and network adapter mode
Cannot connect to port 1234: Confirm
gdbserveris runninggdbserveronly listening locally: Usegdbserver 0.0.0.0:1234 ./pwnWindows firewall blocking: Allow GDB or the corresponding port
VM NAT mode inaccessible: Switch to Host-only/Bridged adapter or configure port forwarding
local_binaryandremote_binaryconfusion: The former is the Windows path, the latter is the Linux pathWindows GDB cannot parse Linux ELF: Use a multi-architecture GDB for the corresponding architecture
info proc mappingsunavailable in remote mode:gdb_contextwill mark it as unavailable instead of crashingMissing remote libc symbols: Use
gdb_remote(action="set_sysroot", ...)orset_solib_search_path
Risk Operation Confirmation
Examples of high-risk commands requiring confirmation:
target remote HOST:PORTtarget extended-remote HOST:PORTdisconnectdetachset remote exec-file PATHset sysroot PATHset solib-search-path PATHshell ...source ...python ...dump memory ...restore ...maintenance ...
First call:
gdb_exec(command="target remote 192.168.56.101:1234")Server returns need_confirm=true, retry with confirmation:
gdb_exec(command="target remote 192.168.56.101:1234", confirm=true)After execution, the return contains executed_with_risk=true.
Available Tools
13 toolsgdb_analyzeC
Analyze crash state, registers, stack, exploitability, calling convention, or memory faults.
Inputs: mode. Returns: object
gdb_breakpointC
Add, delete, enable, disable, list, condition, or clear breakpoints/watchpoints.
Inputs: action (required), location, number, condition, +4 more. Returns: object
gdb_contextB
Return registers, current instruction, disassembly, stack, backtrace, breakpoints, and mappings.
Inputs: depth. Returns: object
gdb_elfB
Inspect ELF metadata using pyelftools when available and readelf/objdump as fallback.
Inputs: action (required), path. Returns: object
gdb_execC
Execute an arbitrary GDB CLI command with warning-and-confirm risk handling.
Inputs: command (required), confirm, timeout, parse. Returns: object
gdb_loadC
Load a binary, core file, symbol file, and optional program arguments.
Inputs: binary, core, symbol_file, args. Returns: object
gdb_memoryC
Read, write, search, or dump inferior memory.
Inputs: action (required), address, size, data_hex, +3 more. Returns: object
gdb_miC
Execute a raw GDB/MI command with warning-and-confirm risk handling.
Inputs: mi_command (required), confirm, timeout. Returns: object
gdb_pwndbgC
Execute pwndbg/gef/peda helper commands if they appear available.
Inputs: command (required), confirm. Returns: object
gdb_registerC
Read all registers, read one register, or write one register.
Inputs: action (required), name, value, confirm. Returns: object
gdb_remoteC
Configure or connect Windows GDB to a VM-side gdbserver.
Inputs: action (required), host, port, mode, +8 more. Returns: object
gdb_run_controlC
Run, continue, step, next, instruction-step, finish, until, interrupt, kill, or restart.
Inputs: action (required), count, args, stdin, +2 more. Returns: object
gdb_sessionC
Start, stop, restart, or inspect the current GDB session.
Inputs: action (required), gdb_path, workdir, extra_args. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 13 tools
Tools mostly cover distinct GDB aspects (breakpoints, memory, registers, execution control, session), with minor overlap between 'gdb_context' and 'gdb_register' for register info, and 'gdb_exec' vs 'gdb_mi' for command execution.
All tools start with 'gdb_', but naming patterns vary: some are verbs (analyze, exec), some nouns (breakpoint, context), and one is verb_noun (run_control). No consistent verb_noun pattern.
13 tools is well-scoped for a GDB debugger server, covering essential operations without being overwhelming.
Covers most key GDB features (session, loading, breakpoints, execution, memory, registers, analysis, context, remote, plugins), though source-level debugging or variable inspection are missing but can be handled via gdb_exec.
Related MCP Connectors
Live browser debugging for AI assistants — DOM, console, network via MCP.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Connect ChatGPT and Claude to your Mac, Windows or Linux with secure MCP remote access.
Persistent memory, knowledge graph, task management and more for AI agents via MCP.
Related MCP Servers
- AlicenseAqualityDmaintenanceMCP 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.343MIT
- AlicenseCqualityDmaintenanceAn MCP server that exposes pwndbg commands running under LLDB as tools for AI assistants. This enables AI-driven binary analysis, exploit development, and reverse engineering through pwndbg's enhanced debugging capabilities.1001MIT
- AlicenseAqualityDmaintenanceAn MCP server that enables AI assistants to control GDB debugging sessions, including breakpoint management, thread analysis, and variable inspection, using the GDB/MI protocol.221MIT
- FlicenseNot gradedqualityDmaintenanceEnables dynamic debugging with GDB via the MCP protocol, allowing LLMs to execute GDB commands, manage breakpoints, control execution, and inspect program state.3-