gdb
A lightweight MCP Server for GDB automation.
claude mcp add --transport stdio jtang613-gdb-mcp python -u -c print('GDB MCP server is embedded and started from within GDB by sourcing the gdb-mcp script and invoking mcp-server. This is not a standalone process to run outside GDB.') \
--env GDB_MCP_NOTE="This configuration indicates the server is loaded via GDB and started with the mcp-server command from the gdb-mcp script. Ensure you source the script in an active GDB session."How to use
This MCP server runs inside GDB and exposes a single tool named gdb-command. The tool sends any GDB command you specify directly to GDB’s command interpreter and returns the textual output. To use it, start GDB with the MCP extension loaded via the provided gdb-mcp script, then start the SSE server from within GDB using the mcp-server command. Connect your MCP client to the configured host and port, and call the gdb-command tool with the exact GDB command you want executed. For example, you can query registers (info registers), examine memory (x /10i $pc), or control flow (step, next) by sending those commands through gdb-command and parsing the returned text.
Important: there is no built-in stop server function in the script. To teardown, exit GDB. The server has no timeout or stop control, and it can execute arbitrary GDB commands, so restrict access accordingly. If you need to auto-load this in your environment, add a line to your ~/.gdbinit to source the gdb-mcp script by absolute path.
How to install
Prerequisites
- GDB with Python support enabled (check by running gdb -q -ex "python print('ok')" -ex quit)
- Python 3.x installed
- The fastmcp library installed in the same Python environment that GDB uses
Install steps
- Ensure Python 3 is installed and available in your PATH.
- Install the FastMCP library into the Python environment used by GDB: python3 -m pip install fastmcp
- Obtain the gdb-mcp script (provided with the project) and place it in a convenient location.
- Start GDB and load the MCP extension by sourcing the script: gdb -q -ex 'source /absolute/path/to/gdb-mcp'
- Inside GDB, start the SSE MCP server: mcp-server 127.0.0.1 3333
- From an MCP client, connect to localhost:3333 and use the gdb-command tool to run GDB commands.
Note: If GDB cannot import fastmcp, verify that the Python environment GDB uses has fastmcp installed (you may need to locate the Python interpreter GDB was built with and install there).
Additional notes
Tips and caveats:
- The gdb-command tool forwards the exact string you provide as a GDB command; output is the textual response from GDB. If commands hang or long-running targets are active, you can interrupt with the standard GDB interrupt.
- Do not expose this endpoint publicly unless you trust clients, as it can execute arbitrary GDB commands.
- To auto-load in future sessions, add a line to ~/.gdbinit like: source /absolute/path/to/gdb-mcp
- There is no dedicated stop server command; terminating the GDB session will teardown the MCP server. Ensure you manage lifecycle via GDB sessions.
- The server is minimal and self-contained within GDB; there is no separate daemon or process to manage outside of GDB.
Related MCP Servers
context7
Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
mem0
✨ mem0 MCP Server: A memory system using mem0 for AI applications with model context protocl (MCP) integration. Enables long-term memory for AI agents as a drop-in MCP server.
time
⏰ Time MCP Server: Giving LLMs Time Awareness Capabilities
workflowy
Powerful CLI and MCP server for WorkFlowy: reports, search/replace, backup support, and AI integration (Claude, LLMs)
rdkit
MCP server that enables language models to interact with RDKit through natural language
gtm
An MCP server for Google Tag Manager. Connect it to your LLM, authenticate once, and start managing GTM through natural language.