Model Context Protocol server for driving GDB from an LLM.
Project description
gdb-mcp
Model Context Protocol server that wraps gdb so an LLM can drive live debugging
sessions. The server exposes tools for starting a session on a binary, attaching
to an existing PID, running ad-hoc commands, batching commands, checking status,
and shutting sessions down.
Requires
gdbon the host and themcppython package (v1+).
Setup
You can install either inside a virtualenv (recommended) or directly:
# optional but recommended
python -m venv .venv
. .venv/bin/activate
pip install -e .
# or: pip install .
Running the MCP server
You can start the server directly:
gdb-mcp
# or
python -m gdb_mcp.server
The server uses stdio for transport (the default for most MCP clients). Point your MCP client configuration at the command above.
One-shot client configuration
Run gdb-mcp --install to add the server to any detected MCP-aware clients
without editing config files by hand. The installer currently knows how to
update:
- Codex CLI (
~/.codex/config.toml) - Claude Desktop configs (common Linux/macOS paths)
- Cursor / Windsurf MCP config files (if present)
Use --install-command /custom/path/to/gdb-mcp or --install-args ... if you
need to override what gets written.
Exposed tools
start_binary(binary_path, args=None, cwd=None, load_init=True, start_timeout=30.0, prompt=None, force_prompt=True)– launch gdb against a target binary (with optional args) and return a session id and the initial banner. Setload_init=Falseto skip user gdbinit (default is to load it so helpers like GEF/pwndbg remain enabled). Increasestart_timeoutif loading extensions takes longer to reach the first prompt. Usepromptto force a specific prompt string (defaults cover(gdb),(pwndbg), andgef>).force_promptsets the prompt to the chosen value after startup to avoid timeouts from customized prompts (e.g., pwndbg); setforce_prompt=Falseif you need to keep your custom prompt unchanged.attach_to_pid(pid, cwd=None, load_init=True, start_timeout=30.0, prompt=None, force_prompt=True)– start gdb and attach to a running process (sameload_init/timeout/prompt behavior as above).gdb_command(session_id, command, timeout_seconds=15.0)– execute a single gdb command in the given session and return the output.batch_commands(session_id, commands, timeout_seconds=15.0)– run a list of commands sequentially.list_sessions()– get a snapshot of all active sessions.session_status(session_id)– check if the gdb process is still alive.stop_session(session_id)– shut down the gdb process and remove it.
Each tool returns simple JSON so it is easy to route back into your LLM prompt.
Notes and tips
- The server automatically disables pagination and confirmation prompts and enables pending breakpoints to keep interactions non-blocking.
timeout_secondsapplies per command. If you expect a program to run for a long time, pass a larger timeout orNone.- Output is captured from gdb stdout/stderr until the next
(gdb)prompt. If you spawn a program that never returns to the prompt (e.g., it blocks on input), the call will time out. - Common debugger prompts are detected automatically (
(gdb),(pwndbg),gef>), even with ANSI colors. You can still pass a custompromptif you use something nonstandard. By default the server forces the prompt to a stable value (force_prompt=True) so gdbinit customizations (like pwndbg) don’t prevent the initial prompt from being detected.
Demo
Auto-playing preview:
Source video: docs/media/demo.mp4
Credits
- This project was built for my CSE 598 class, which emphasized using AI/LLMs in our workflow. I leaned on AI to write the entire project—including this README.
- Inspired by https://github.com/mrexodia/ida-pro-mcp, and their server logic was used as a starting point.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gdb_mcp-1.0.1.tar.gz.
File metadata
- Download URL: gdb_mcp-1.0.1.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ad0ca16af59b41481f9e13b3cd57175bc08d829577e61f4d0426f8f73991312
|
|
| MD5 |
6f8d4a59a486b6e0056eb1b20e74bace
|
|
| BLAKE2b-256 |
52d2db533b048b61319f329051a33f37983a4722fed0c62de9065e7edee7dcb8
|
Provenance
The following attestation bundles were made for gdb_mcp-1.0.1.tar.gz:
Publisher:
workflow.yml on datobena/gdb-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gdb_mcp-1.0.1.tar.gz -
Subject digest:
9ad0ca16af59b41481f9e13b3cd57175bc08d829577e61f4d0426f8f73991312 - Sigstore transparency entry: 760439687
- Sigstore integration time:
-
Permalink:
datobena/gdb-mcp@13aea057175e7294e6f4f3ba2af5892f73db368d -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/datobena
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@13aea057175e7294e6f4f3ba2af5892f73db368d -
Trigger Event:
release
-
Statement type:
File details
Details for the file gdb_mcp-1.0.1-py3-none-any.whl.
File metadata
- Download URL: gdb_mcp-1.0.1-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa07a946a025343c4188d08ee6d14ce148d41c3aed2640c00d029d2321b2f2ff
|
|
| MD5 |
5e15379be4c6b630fa8b575888c6b5f4
|
|
| BLAKE2b-256 |
9807470451f837f84549fc21a948b511a55f524370133e1359967cbf8a89c4cc
|
Provenance
The following attestation bundles were made for gdb_mcp-1.0.1-py3-none-any.whl:
Publisher:
workflow.yml on datobena/gdb-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gdb_mcp-1.0.1-py3-none-any.whl -
Subject digest:
aa07a946a025343c4188d08ee6d14ce148d41c3aed2640c00d029d2321b2f2ff - Sigstore transparency entry: 760439691
- Sigstore integration time:
-
Permalink:
datobena/gdb-mcp@13aea057175e7294e6f4f3ba2af5892f73db368d -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/datobena
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@13aea057175e7294e6f4f3ba2af5892f73db368d -
Trigger Event:
release
-
Statement type: