jovanwongzixi/gdbMCP
If you are the rightful owner of gdbMCP and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
A Model Context Protocol (MCP) server that provides debugging capabilities through GDB (GNU Debugger) using the pygdbmi library.
GDB MCP Server
A Model Context Protocol (MCP) server that provides debugging capabilities through GDB (GNU Debugger) using the pygdbmi library.
Features
This MCP server allows you to:
- Load executables into GDB
- Set and remove breakpoints
- Run and control program execution (continue, step into, step over)
- Examine memory and variables
- Disassemble functions and address ranges
- Inspect stack frames and register values
- Manage threads
- Send custom GDB commands
Installation
# Install dependencies
uv sync
# Or if you prefer pip
pip install -e .
Usage
Start the server:
# Using the start script
./start_server.sh
# Or directly with Python
python gdb_mcp_server.py --transport sse
# Or using uv
uv run gdb_mcp_server.py --transport sse
The server will start on http://localhost:8001 by default.
You can also customize the host and port:
./start_server.sh --mcp-host 0.0.0.0 --mcp-port 8080
Available Tools
The server provides the following tools that can be called through the MCP protocol:
initialize_gdb: Initialize the GDB connectionload_executable: Load an executable file into GDBset_breakpoint: Set a breakpoint at a locationremove_breakpoint: Remove a breakpoint by IDrun_program: Run the programcontinue_execution: Continue program executionstep_into: Step into the next linestep_over: Step over the next lineget_stack_frames: Get current stack framesselect_stack_frame: Select a specific stack framedisassemble_function: Disassemble a functiondisassemble_address_range: Disassemble a range of addressesprint_variable: Print a variable or expressionexamine_memory: Examine memory at an addressget_memory_map: Get memory mappings for the processget_registers: Get register valuesget_register_names: Get register namescreate_variable: Create a variable object for trackingupdate_variable: Update a variable's valueevaluate_variable: Evaluate a variable's current valuelist_variables: List all created variablesget_threads: Get information about threadsswitch_thread: Switch to a specific threadsend_custom_command: Send a custom GDB commandshutdown_gdb: Shutdown the GDB connection
Architecture
The server is organized into three main components:
-
GDB Controller (
src/gdb_controller.py): A wrapper around pygdbmi's GdbController that provides a clean interface for sending commands to GDB and processing responses. -
GDB Service (
src/gdb_service.py): A service layer that manages the GDB instance and provides debugging functionality. It handles the business logic and error management. -
MCP Server (
src/server.py): The MCP server implementation with decorated functions that serve as entry points for the tools.
Requirements
- Python 3.11+
- GDB (GNU Debugger)
- pygdbmi library
- mcp library