Skip to main content
Glama
signal-slot

MCP GDB Server

by signal-slot

gdb_attach

Attach to a running process using session ID and process ID to enable debugging with GDB commands, facilitating real-time analysis and troubleshooting.

Instructions

Attach to a running process

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pidYesProcess ID to attach to
sessionIdYesGDB session ID

Implementation Reference

  • The handler function that implements the gdb_attach tool logic: validates sessionId, attaches to the given PID using GDB 'attach' command via executeGdbCommand, and returns the output or error.
    private async handleGdbAttach(args: any) {
      const { sessionId, pid } = args;
      
      if (!activeSessions.has(sessionId)) {
        return {
          content: [
            {
              type: 'text',
              text: `No active GDB session with ID: ${sessionId}`
            }
          ],
          isError: true
        };
      }
      
      const session = activeSessions.get(sessionId)!;
      
      try {
        const output = await this.executeGdbCommand(session, `attach ${pid}`);
        
        return {
          content: [
            {
              type: 'text',
              text: `Attached to process ${pid}\n\nOutput:\n${output}`
            }
          ]
        };
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        return {
          content: [
            {
              type: 'text',
              text: `Failed to attach to process: ${errorMessage}`
            }
          ],
          isError: true
        };
      }
    }
  • The tool registration including name, description, and input schema defining sessionId (string) and pid (number) as required parameters.
    {
      name: 'gdb_attach',
      description: 'Attach to a running process',
      inputSchema: {
        type: 'object',
        properties: {
          sessionId: {
            type: 'string',
            description: 'GDB session ID'
          },
          pid: {
            type: 'number',
            description: 'Process ID to attach to'
          }
        },
        required: ['sessionId', 'pid']
      }
    },
  • src/index.ts:369-370 (registration)
    The dispatch case in the CallToolRequestHandler switch statement that routes 'gdb_attach' calls to the handleGdbAttach method.
    case 'gdb_attach':
      return await this.handleGdbAttach(request.params.arguments);
Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/signal-slot/mcp-gdb'

If you have feedback or need assistance with the MCP directory API, please join our Discord server