gdbMCP

jovanwongzixi/gdbMCP

3.1

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.

Tools
25
Resources
0
Prompts
0

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 connection
  • load_executable: Load an executable file into GDB
  • set_breakpoint: Set a breakpoint at a location
  • remove_breakpoint: Remove a breakpoint by ID
  • run_program: Run the program
  • continue_execution: Continue program execution
  • step_into: Step into the next line
  • step_over: Step over the next line
  • get_stack_frames: Get current stack frames
  • select_stack_frame: Select a specific stack frame
  • disassemble_function: Disassemble a function
  • disassemble_address_range: Disassemble a range of addresses
  • print_variable: Print a variable or expression
  • examine_memory: Examine memory at an address
  • get_memory_map: Get memory mappings for the process
  • get_registers: Get register values
  • get_register_names: Get register names
  • create_variable: Create a variable object for tracking
  • update_variable: Update a variable's value
  • evaluate_variable: Evaluate a variable's current value
  • list_variables: List all created variables
  • get_threads: Get information about threads
  • switch_thread: Switch to a specific thread
  • send_custom_command: Send a custom GDB command
  • shutdown_gdb: Shutdown the GDB connection

Architecture

The server is organized into three main components:

  1. 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.

  2. 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.

  3. 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