This MCP server enables AI agents and tools to interact with GDB using the Model Context Protocol, providing an interface for AI-assisted debugging across multiple architectures and environments.
To set up the GDB MCP server:
git clone https://github.com/yywz1999/gdb-mcp-server.git
cd gdb-mcp-server
python3 -m pip install -r requirements.txt
After installation, verify that the environment is set up correctly by running:
python3 mcp_server.py
If everything is configured properly, the server will start successfully.
To launch the MCP server:
python3 mcp_server.py
The server provides several functions to interact with GDB processes:
Find GDB processes:
Use sys_find_gdb_processes
to discover running GDB instances
Attach to GDB:
Connect to an existing GDB process with sys_attach_to_gdb
Start GDB with remote debugging:
Launch GDB and connect to a remote target using sys_start_gdb_with_remote
The server exposes these GDB operations through the MCP protocol:
Execute custom commands:
gdb_execute_command
- Run any arbitrary GDB command
Breakpoint management:
gdb_set_breakpoint
- Create a new breakpointgdb_delete_breakpoint
- Remove an existing breakpointCode execution control:
gdb_step
- Step into functionsgdb_next
- Step over functionsgdb_finish
- Run until current function returnsgdb_continue
- Resume executionSystem inspection:
gdb_get_registers
- View register valuesgdb_examine_memory
- Inspect memory contentsgdb_get_stack
- Display stack tracegdb_get_locals
- Show local variablesgdb_disassemble
- View disassembled codeRemote debugging:
gdb_connect_remote
- Connect to a remote debugging targetFor optimal performance on macOS:
The server includes several optimizations for macOS:
The server includes intelligent blocking detection that:
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "gdb-mcp-server" '{"command":"python3","args":["mcp_server.py"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"gdb-mcp-server": {
"command": "python3",
"args": [
"mcp_server.py"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"gdb-mcp-server": {
"command": "python3",
"args": [
"mcp_server.py"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect