home / mcp / gdb mcp server

GDB MCP Server

Provides an MCP interface to discover, attach to, and control GDB sessions for AI-assisted debugging.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "yywz1999-gdb-mcp-server": {
      "command": "python3",
      "args": [
        "mcp_server.py"
      ]
    }
  }
}

You can run a Python-based MCP server that talks to GDB using the Model Context Protocol. This server lets an AI assistant interact with GDB, attach to running GDB sessions, manage breakpoints, inspect memory and registers, step through code, and perform common debugging tasks across multi-architecture and remote scenarios.

How to use

Launch the MCP server in a local environment to enable interaction with GDB through MCP. Start by attaching to a running GDB session or discovering active GDB processes, then perform debugging actions via MCP calls that correspond to common GDB operations.

How to install

# prerequisites: Python 3.11+ and Git
# 1) Clone the MCP server repository
git clone https://github.com/yywz1999/gdb-mcp-server.git
cd gdb-mcp-server

# 2) Install Python dependencies
python3 -m pip install -r requirements.txt

# 3) Run the MCP server (from the repository root or adjust path as needed)
python3 mcp_server.py
```
This sequence installs dependencies and starts the MCP server so you can begin interfacing with GDB via MCP.

Configuration and usage notes

The server provides a standard set of tools to locate and attach to GDB, followed by a suite of GDB-related actions you can trigger via MCP calls. When starting from macOS with a terminal, you may want to optimize terminal handling and ensure the GDB terminal is ready before attaching.

The following tools are available for interacting with GDB through MCP: sys_find_gdb_processes, sys_attach_to_gdb, gdb_execute_command, gdb_set_breakpoint, gdb_delete_breakpoint, gdb_step, gdb_next, gdb_finish, gdb_continue, gdb_get_registers, gdb_examine_memory, gdb_get_stack, gdb_get_locals, gdb_disassemble, gdb_connect_remote.

Available tools

sys_find_gdb_processes

Find all running GDB processes on the host so you can attach without manual process selection.

sys_attach_to_gdb

Attach the MCP server to a selected GDB process to start issuing commands.

gdb_execute_command

Execute an arbitrary GDB command and return the result.

gdb_set_breakpoint

Set a breakpoint at a specified location.

gdb_delete_breakpoint

Remove a breakpoint by its location or number.

gdb_step

Step through the next source line of code.

gdb_next

Continue execution until the next line in the current function.

gdb_finish

Run until the current function returns.

gdb_continue

Continue program execution.

gdb_get_registers

Fetch the current values of CPU registers.

gdb_examine_memory

Inspect a memory region by address and size.

gdb_get_stack

Obtain the current stack trace.

gdb_get_locals

Retrieve local variables in the current stack frame.

gdb_disassemble

Disassemble a code region to view assembly instructions.

gdb_connect_remote

Connect to a remote debugging target.