Logo van GDB MCP Server

GDB MCP Server

Community
Ipiano

MCP server for GDB

UitgeverIpiano
Repositorygdb-mcp
TaalPython
Forks
12
Sterren
51
Beschikbare tools
0
Transporttypestdio
Categorieën
LicentieMIT
Links
  • Koppel tools aan AI-workflows

    GDB MCP Server biedt MCP-functionaliteit die compatibele AI-clients en agenten kunnen gebruiken.

  • 0 beschikbare tools

    Bekijk hieronder de aanroepbare acties, inclusief namen en beschrijvingen als de server die beschikbaar stelt.

  • Configuratie om direct te kopiëren

    Gebruik de installatievoorbeelden om deze server in je favoriete MCP-client te configureren.

  • Indicatoren van opensource-interesse

    51 sterren en 12 forks in de gekoppelde repository.

GDB MCP Server

An MCP (Model Context Protocol) server that provides AI assistants with programmatic access to GDB debugging sessions. This allows AI models to interact with debuggers in the same way IDEs like VS Code and CLion do, using the GDB/MI (Machine Interface) protocol.

Features

  • Full GDB Control: Start sessions, execute commands, control program execution
  • Thread Analysis: Inspect threads, get backtraces, analyze thread states
  • Breakpoint Management: Set conditional breakpoints, temporary breakpoints
  • Variable Inspection: Evaluate expressions, inspect variables and registers
  • Core Dump Analysis: Load and analyze core dumps with custom initialization
  • Flexible Initialization: Run GDB scripts or commands on startup

Architecture

This server uses the GDB/MI (Machine Interface) protocol, which is the same interface used by professional IDEs. It provides:

  • Structured, machine-parseable output
  • Full access to GDB's debugging capabilities
  • Reliable command execution and response handling

Installation

Prerequisites

  • Python 3.10 or higher
  • GDB installed and available in PATH

Quick Start

bash
# Install pipx if needed
python3 -m pip install --user pipx
python3 -m pipx ensurepath

# Install gdb-mcp-server
cd /path/to/gdb-mcp
pipx install .

For alternative installation methods (virtual environment, manual setup), see INSTALL.md.

Configuration

Claude Desktop

Add this to your Claude Desktop configuration file:

Location:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

Configuration:

json
{
  "mcpServers": {
    "gdb": {
      "command": "gdb-mcp-server"
    }
  }
}

For other installation methods and MCP clients, see INSTALL.md.

Environment Variables

The GDB MCP Server supports the following environment variables:

GDB_PATH

Specify the path to the GDB executable to use. This is useful when:

  • You have multiple GDB versions installed
  • GDB is installed in a non-standard location
  • You want to use a custom or patched GDB build

Default: gdb (resolved via system PATH)

Example:

bash
export GDB_PATH=/usr/local/bin/gdb-13.2
gdb-mcp-server

Note: The gdb_path parameter in the gdb_start_session tool overrides this environment variable if both are specified.

GDB_MCP_LOG_LEVEL

Set the logging level for the server.

Default: INFO Options: DEBUG, INFO, WARNING, ERROR, CRITICAL

Example:

bash
export GDB_MCP_LOG_LEVEL=DEBUG
gdb-mcp-server

Available Tools

The GDB MCP Server provides 22 tools for controlling GDB debugging sessions:

Session Management:

  • gdb_start_session - Start a new GDB session with optional initialization
  • gdb_execute_command - Execute GDB commands (CLI or MI format)
  • gdb_call_function - Call a function in the target process (dedicated tool for separate permissioning)
  • gdb_get_status - Get current session status
  • gdb_stop_session - Stop the current session

Thread & Frame Navigation:

  • gdb_get_threads - List all threads
  • gdb_select_thread - Select a specific thread
  • gdb_get_backtrace - Get stack trace for a thread
  • gdb_select_frame - Select a specific stack frame
  • gdb_get_frame_info - Get information about the current frame

Breakpoint Management:

  • gdb_set_breakpoint - Set breakpoints with optional conditions
  • gdb_list_breakpoints - List all breakpoints with structured data
  • gdb_delete_breakpoint - Delete a breakpoint by number
  • gdb_enable_breakpoint - Enable a breakpoint
  • gdb_disable_breakpoint - Disable a breakpoint

Execution Control:

  • gdb_continue - Continue execution
  • gdb_step - Step into functions
  • gdb_next - Step over functions
  • gdb_interrupt - Pause a running program

Data Inspection:

  • gdb_evaluate_expression - Evaluate expressions
  • gdb_get_variables - Get local variables
  • gdb_get_registers - Get CPU registers

For detailed documentation of each tool including parameters, return values, and examples, see TOOLS.md.

Usage Examples

Example 1: Analyzing a Core Dump

User: "Load the core dump at /tmp/core.12345, set the sysroot to /opt/sysroot, and tell me how many threads there were when it crashed."

AI Actions:

  1. Start session with init commands:
json
{
  "init_commands": [
    "file /path/to/executable",
    "core-file /tmp/core.12345",
    "set sysroot /opt/sysroot"
  ]
}
  1. Get threads: gdb_get_threads
  2. Report: "There were 8 threads when the program crashed."

Example 2: Conditional Breakpoint Investigation

User: "Set a breakpoint at process_data but only when the count variable is greater than 100, then continue execution."

AI Actions:

  1. Set conditional breakpoint:
json
{
  "location": "process_data",
  "condition": "count > 100"
}
  1. Continue execution: gdb_continue
  2. When hit, inspect state

For more detailed usage examples and workflows, see examples/USAGE_GUIDE.md and examples/README.md.

Advanced Usage

Custom GDB Initialization Scripts

Create a .gdb file with your setup commands:

gdb
# setup.gdb
file /path/to/myprogram
core-file /path/to/core

# Set up symbol paths
set sysroot /opt/sysroot
set solib-search-path /opt/libs:/usr/local/lib

# Convenience settings
set print pretty on
set print array on
set pagination off

Then use it:

json
{
  "init_commands": ["source setup.gdb"]
}

Python Initialization Scripts

You can also use GDB's Python API:

python
# init.py
import gdb
gdb.execute("file /path/to/program")
gdb.execute("core-file /path/to/core")
# Custom analysis

Use with:

json
{
  "init_commands": ["source init.py"]
}

Working with Running Processes

While this server primarily works with core dumps and executables, you can attach to running processes:

json
{
  "init_commands": [
    "attach 12345"  // PID of running process
  ]
}

Note: This requires appropriate permissions (usually root or same user).

Troubleshooting

Common Issues

GDB Not Found

bash
which gdb
gdb --version

Timeout Errors / Commands Not Responding

The program is likely still running! When a program is running, GDB is busy and won't respond to other commands.

Solution: Use gdb_interrupt to pause the running program, then other commands will work.

Program States:

  • Not started: Use gdb_execute_command with "run" or "start"
  • Running: Program is executing - use gdb_interrupt to pause it
  • Paused (at breakpoint): Use gdb_continue, gdb_step, gdb_next, inspect variables
  • Finished: Program has exited - restart with "run" if needed

Missing Debug Symbols

Always check the warnings field in gdb_start_session response! Compile your programs with the -g flag.

For detailed troubleshooting, installation issues, and more solutions, see INSTALL.md.

How It Works

  1. GDB/MI Protocol: The server communicates with GDB using the Machine Interface (MI) protocol, the same interface used by IDEs.

  2. pygdbmi Library: We use the excellent pygdbmi library to handle the low-level protocol details and response parsing.

  3. MCP Integration: The server exposes GDB functionality as MCP tools, allowing AI assistants to:

    • Understand the available debugging operations
    • Execute commands with proper parameters
    • Interpret structured responses
  4. Session Management: A single GDB session is maintained per server instance, allowing stateful debugging across multiple tool calls.

Contributing

Contributions welcome! Areas for improvement:

  • Additional GDB commands (e.g., watchpoints, memory inspection)
  • Better error handling and recovery
  • Enhanced output formatting

License

MIT

References

Installatie

TypingMind
{
  "mcpServers": {
    "gdb-mcp": {
      "command": "gdb-mcp-server",
      "args": []
    }
  }
}

Gebruik GDB MCP Server MCP met meerdere AI-modellen

TypingMind koppelt MCP-tools aan de werkruimte. Zodra GDB MCP Server is verbonden, kun je deze dus met verschillende AI-modellen in TypingMind gebruiken, zonder de verbinding voor elk model apart in te stellen. Deze MCP-integratie draait lokaal via de TypingMind MCP-connector op je apparaat.

Installatiehandleiding voor de lokale connector

Gebruik dit als de MCP-server toegang nodig heeft tot lokale bestanden, apps of privébronnen op je computer.

1

Open de MCP-instellingen

Ga in TypingMind naar Instellingen, Geavanceerde instellingen en vervolgens Model Context Protocol. Kies daar Connector instellen.

  1. Open TypingMind in je browser.
  2. Klik op het pictogram Instellingen.
  3. Ga naar Geavanceerde instellingen.
  4. Open het gedeelte Model Context Protocol.
  5. Klik op Connector instellen en kies Dit apparaat.
Instelscherm voor de TypingMind MCP-connector met Dit apparaat geselecteerd
2

Voer de connectoropdracht uit

Kies Dit apparaat, kopieer de opdracht uit TypingMind en voer deze uit in Terminal. Laat het proces draaien zolang je MCP gebruikt.

  1. Kopieer de installatieopdracht die TypingMind toont.
  2. Open Terminal op macOS of Windows Terminal op Windows.
  3. Plak de opdracht en voer deze uit.
  4. Keur de pakketinstallatie goed als Terminal vraagt of je wilt doorgaan.
  5. Laat het proces in het Terminal-venster draaien zolang je MCP-tools gebruikt.
3

Voeg GDB MCP Server toe als server

Klik op Servers bewerken zodra de connectorstatus Gereed is en plak de MCP-serverconfiguratie.

  1. Wacht tot de connectorstatus Gereed aangeeft.
  2. Klik op Servers bewerken.
  3. Plak de MCP-serverconfiguratie van GDB MCP Server.
  4. Sla de serverlijst op.
  5. Vernieuw om te controleren of de connector nog steeds klaar is voor gebruik.
MCP-instellingen van TypingMind met een actieve server en de knop Servers bewerken
{
  "mcpServers": {
    "gdb-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Gebruik de verbinding met verschillende modellen

Sla de serverlijst op, open Plug-ins en schakel de MCP-tools van GDB MCP Server in. Selecteer vervolgens een ondersteund AI-model in TypingMind en gebruik de tools in de chat of wijs ze toe aan een AI-agent.

  1. Open de pagina Plug-ins in TypingMind.
  2. Schakel de MCP-tools van GDB MCP Server in.
  3. Start een chat en kies het AI-model dat je wilt gebruiken.
  4. Gebruik de MCP-tools in een chat of wijs ze toe aan een AI-agent.
  5. Schakel wanneer nodig over naar een ander AI-model zonder opnieuw verbinding te maken met MCP.
TypingMind-chat met ingeschakelde MCP-tools en een geselecteerd AI-model
Kun je GDB MCP Server gebruiken om me hiermee te helpen?
GDB MCP Server
Zeker. Ik heb het gelezen.
Dit vond ik met GDB MCP Server.

Veelgestelde vragen

Waarvoor wordt de MCP-server GDB MCP Server gebruikt?

GDB MCP Server is een MCP-server waarmee compatibele AI-clients verbinding kunnen maken met externe tools en context. In TypingMind hoef je deze MCP-server maar één keer toe te voegen om de tools beschikbaar te maken in je AI-werkruimte.

Kan ik GDB MCP Server MCP met meerdere AI-modellen in TypingMind gebruiken?

Ja. TypingMind verbindt MCP-tools op werkruimteniveau. Daardoor kun je GDB MCP Server gebruiken met verschillende AI-modellen, zoals Claude, ChatGPT, Gemini of andere modellen die je in TypingMind hebt ingesteld, zonder de MCP-server voor elk model afzonderlijk in te stellen.

Waarom GDB MCP Server MCP gebruiken met TypingMind?

TypingMind is een van de beste interfaces voor chats met LLM's, omdat het meerdere AI-modellen, prompts, plug-ins, AI-agenten, API-sleutels en MCP-tools samenbrengt in één werkruimte. Als GDB MCP Server verbonden is, kun je de MCP-tools ervan gebruiken met je favoriete modellen en je chatworkflow overzichtelijk houden in TypingMind.

Hoe verbind ik GDB MCP Server MCP met TypingMind?

GDB MCP Server werkt via de lokale MCP-connector van TypingMind. Dit is de beste optie als de MCP-server toegang nodig heeft tot lokale bestanden, desktopapps, opdrachtregeltools of privébronnen op je computer.

Welke tools biedt GDB MCP Server MCP in TypingMind?

GDB MCP Server biedt MCP-functies die je kunt inschakelen via de pagina Plug-ins in TypingMind. Je kunt ze gebruiken in chats of toewijzen aan AI-agenten.

Moet ik mijn API-sleutels delen met TypingMind om GDB MCP Server MCP te gebruiken?

Nee. TypingMind werkt in de eerste plaats lokaal en laat je de controle houden over je modelaanbieders, API-sleutels, prompts en MCP-configuratie. Als GDB MCP Server authenticatie vereist, voeg je bij het maken van de verbinding de vereiste headers, OAuth-instellingen of lokale configuratie voor die MCP-server toe.

Gerelateerde MCP-servers

Toon alles

Maak nu je eigen AI-werkruimte

Schrijf je in voor onze nieuwsbrief en blijf op de hoogte van nieuwe functies en toekomstige weggeefacties 👇