Logo de GDB MCP Server

GDB MCP Server

Communauté
Ipiano

MCP server for GDB

ÉditeurIpiano
Dépôtgdb-mcp
LanguePython
Forks
12
Étoiles
51
Outils disponibles
0
Type de transportstdio
Catégories
LicenceMIT
Liens
  • Connectez des outils à vos workflows IA

    GDB MCP Server propose des fonctionnalités MCP utilisables par les clients et agents IA compatibles.

  • 0 outils disponibles

    Parcourez les actions invocables ci-dessous, avec leurs noms et descriptions lorsque le serveur les fournit.

  • Configuration prête à copier

    Utilisez les exemples de configuration pour configurer ce serveur dans votre client MCP préféré.

  • Indicateurs de popularité open source

    51 étoiles et 12 forks sur le dépôt associé.

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

Installation

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

Utilisez le serveur MCP GDB MCP Server avec plusieurs modèles IA

TypingMind connecte les outils MCP au niveau de l’espace de travail. Une fois GDB MCP Server connecté, vous pouvez donc l’utiliser avec différents modèles IA dans TypingMind sans avoir à le configurer séparément pour chaque modèle. Cette intégration MCP s’exécute localement sur votre appareil via le connecteur MCP de TypingMind.

Guide de configuration du connecteur local

Choisissez cette méthode si le serveur MCP doit accéder à des fichiers locaux, à des applications ou à des ressources privées sur votre ordinateur.

1

Ouvrir les paramètres MCP

Dans TypingMind, accédez à « Paramètres », puis à « Paramètres avancés » et à « Model Context Protocol », et choisissez « Configurer connecteur ».

  1. Ouvrez TypingMind dans votre navigateur.
  2. Cliquez sur l’icône Paramètres.
  3. Accédez aux paramètres avancés.
  4. Ouvrez la section Model Context Protocol.
  5. Cliquez sur « Configurer connecteur » et choisissez « Cet appareil ».
Écran de configuration du connecteur MCP de TypingMind avec l’option « Cet appareil » sélectionnée
2

Exécuter la commande du connecteur

Choisissez « Cet appareil », copiez la commande depuis TypingMind et exécutez-la dans Terminal. Laissez le processus en cours d’exécution pendant que vous utilisez MCP.

  1. Copiez la commande de configuration affichée par TypingMind.
  2. Ouvrez Terminal sur macOS ou Windows Terminal sur Windows.
  3. Collez et exécutez la commande.
  4. Autorisez l’installation du paquet si Terminal vous demande de confirmer.
  5. Gardez la fenêtre de Terminal ouverte et le processus en cours d’exécution pendant que vous utilisez les outils MCP.
3

Ajoutez GDB MCP Server en tant que serveur

Lorsque l’état du connecteur affiche « Prêt », cliquez sur « Éditer serveurs » et collez la configuration du serveur MCP.

  1. Attendez que l’état du connecteur affiche « Prêt ».
  2. Cliquez sur « Éditer serveurs ».
  3. Collez la configuration du serveur MCP GDB MCP Server.
  4. Enregistrez la liste des serveurs.
  5. Actualisez pour vérifier que le connecteur est toujours prêt.
Paramètres MCP de TypingMind affichant un serveur actif et le bouton « Éditer serveurs »
{
  "mcpServers": {
    "gdb-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Utiliser la connexion avec différents modèles

Enregistrez la liste des serveurs, ouvrez « Plugins », activez les outils MCP de GDB MCP Server, puis sélectionnez un modèle IA compatible dans TypingMind et utilisez les outils dans une discussion ou attribuez-les à un agent IA.

  1. Ouvrez la page Plugins dans TypingMind.
  2. Activez les outils MCP de GDB MCP Server.
  3. Démarrez une discussion et choisissez le modèle IA que vous souhaitez utiliser.
  4. Utilisez les outils MCP dans le chat ou attribuez-les à un agent IA.
  5. Passez à un autre modèle IA selon vos besoins sans rétablir la connexion MCP.
Discussion TypingMind utilisant des outils MCP activés avec un modèle d’IA sélectionné
Pouvez-vous utiliser GDB MCP Server pour m’aider dans cette tâche ?
GDB MCP Server
Bien sûr. J’ai tout lu.
Voici ce que j’ai trouvé avec GDB MCP Server.

Foire aux questions

À quoi sert le serveur MCP GDB MCP Server ?

GDB MCP Server est un serveur MCP qui permet aux applications IA compatibles d’accéder à des outils et à des informations contextuelles externes. Dans TypingMind, il vous suffit d’ajouter ce serveur MCP une seule fois pour rendre ses outils disponibles dans votre espace de travail IA.

Puis-je utiliser le serveur MCP GDB MCP Server avec plusieurs modèles IA dans TypingMind ?

Oui. TypingMind connecte les outils MCP au niveau de l’espace de travail. Vous pouvez donc utiliser GDB MCP Server avec différents modèles IA comme Claude, ChatGPT, Gemini ou d’autres modèles configurés dans TypingMind, sans avoir à configurer le serveur MCP séparément pour chaque modèle.

Pourquoi utiliser le connecteur MCP GDB MCP Server avec TypingMind ?

TypingMind est l’une des meilleures interfaces de chat avec les LLM, car elle réunit plusieurs modèles IA, prompts, plugins, agents IA, clés API et outils MCP dans un seul espace de travail. Une fois GDB MCP Server connecté, vous pouvez utiliser ses outils MCP avec vos modèles préférés tout en gardant vos discussions bien organisées dans TypingMind.

Comment connecter le serveur MCP GDB MCP Server à TypingMind ?

GDB MCP Server fonctionne via le connecteur MCP local de TypingMind. C’est l’option idéale lorsque le serveur MCP doit accéder à des fichiers locaux, des applications de bureau, des outils en ligne de commande ou des ressources privées sur votre ordinateur.

Quels outils le serveur MCP GDB MCP Server propose-t-il dans TypingMind ?

GDB MCP Server propose des fonctionnalités MCP que vous pouvez activer depuis la page Plugins de TypingMind et utiliser dans les discussions ou attribuer à des agents IA.

Dois-je partager mes clés API avec TypingMind pour utiliser le serveur MCP GDB MCP Server ?

Non. TypingMind privilégie le fonctionnement local et vous permet de garder le contrôle de vos fournisseurs de modèles, clés API, prompts et paramètres MCP. Si GDB MCP Server nécessite une authentification, ajoutez les en-têtes, les paramètres OAuth ou la configuration locale requis pour ce serveur MCP lors de la création de la connexion.

Serveurs MCP similaires

Tout voir

Créez votre propre espace IA dès maintenant

Abonnez-vous à notre newsletter pour être informé des nouvelles fonctionnalités et des prochains cadeaux à gagner 👇