Skip to main content
Glama
signal-slot

MCP GDB Server

by signal-slot

gdb_info_registers

Retrieve and display register values during a GDB debugging session on MCP GDB Server. Use this tool to inspect specific or all registers for debugging and analysis.

Instructions

Display registers

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
registerNoSpecific register to display (optional)
sessionIdYesGDB session ID

Implementation Reference

  • Handler function that processes the gdb_info_registers tool call. Extracts sessionId and optional register, validates session, executes the GDB 'info registers' command (with optional register), and returns formatted output or error.
    private async handleGdbInfoRegisters(args: any) {
      const { sessionId, register } = 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 {
        // Build info registers command, optionally with specific register
        const command = register ? `info registers ${register}` : `info registers`;
        const output = await this.executeGdbCommand(session, command);
        
        return {
          content: [
            {
              type: 'text',
              text: `Register info${register ? ` for ${register}` : ''}:\n\n${output}`
            }
          ]
        };
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        return {
          content: [
            {
              type: 'text',
              text: `Failed to get register info: ${errorMessage}`
            }
          ],
          isError: true
        };
      }
    }
  • Input schema defining the parameters for the gdb_info_registers tool: required sessionId (string) and optional register (string).
    inputSchema: {
      type: 'object',
      properties: {
        sessionId: {
          type: 'string',
          description: 'GDB session ID'
        },
        register: {
          type: 'string',
          description: 'Specific register to display (optional)'
        }
      },
      required: ['sessionId']
    }
  • src/index.ts:335-352 (registration)
    Tool registration in the list returned by ListToolsRequestSchema, specifying name, description, and input schema.
    {
      name: 'gdb_info_registers',
      description: 'Display registers',
      inputSchema: {
        type: 'object',
        properties: {
          sessionId: {
            type: 'string',
            description: 'GDB session ID'
          },
          register: {
            type: 'string',
            description: 'Specific register to display (optional)'
          }
        },
        required: ['sessionId']
      }
    }
  • src/index.ts:389-390 (registration)
    Switch case in CallToolRequestSchema handler that routes calls to the gdb_info_registers handler function.
    case 'gdb_info_registers':
      return await this.handleGdbInfoRegisters(request.params.arguments);
  • Helper function used by the handler to execute arbitrary GDB commands via stdin/stdout, waiting for response completion with timeout and error handling.
    private executeGdbCommand(session: GdbSession, command: string): Promise<string> {
      return new Promise<string>((resolve, reject) => {
        if (!session.ready) {
          reject(new Error('GDB session is not ready'));
          return;
        }
        
        // Write command to GDB's stdin
        if (session.process.stdin) {
          session.process.stdin.write(command + '\n');
        } else {
          reject(new Error('GDB stdin is not available'));
          return;
        }
        
        let output = '';
        let responseComplete = false;
        
        // Create a one-time event handler for GDB output
        const onLine = (line: string) => {
          output += line + '\n';
          
          // Check if this line indicates the end of the GDB response
          if (line.includes('(gdb)') || line.includes('^done') || line.includes('^error')) {
            responseComplete = true;
            
            // If we've received the complete response, resolve the promise
            if (responseComplete) {
              // Remove the listener to avoid memory leaks
              session.rl.removeListener('line', onLine);
              resolve(output);
            }
          }
        };
        
        // Add the line handler to the readline interface
        session.rl.on('line', onLine);
        
        // Set a timeout to prevent hanging
        const timeout = setTimeout(() => {
          session.rl.removeListener('line', onLine);
          reject(new Error('GDB command timed out'));
        }, 10000); // 10 second timeout
        
        // Handle GDB errors
        const errorHandler = (data: Buffer) => {
          const errorText = data.toString();
          output += `[stderr] ${errorText}\n`;
        };
        
        // Add error handler
        if (session.process.stderr) {
          session.process.stderr.once('data', errorHandler);
        }
        
        // Clean up event handlers when the timeout expires
        timeout.unref();
      });
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. 'Display registers' implies a read-only operation, but it doesn't specify whether this shows all registers or a subset, the format of output, any side effects, or error conditions. For a tool with no annotation coverage, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise with just two words, front-loading the core action. There is no wasted language or unnecessary elaboration, making it efficient and easy to parse. Every word earns its place by directly stating the tool's function.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of GDB debugging tools, no annotations, and no output schema, the description is incomplete. It doesn't cover what the output looks like, how registers are formatted, or any dependencies on session state. For a tool in a technical domain with siblings, more context is needed to use it effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters (register and sessionId) with descriptions. The description adds no additional meaning beyond what the schema provides—it doesn't explain parameter interactions, default behaviors, or examples. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Display registers' states the basic action (display) and target (registers), which is clear but vague. It doesn't specify what kind of registers (CPU, debug, etc.) or distinguish from siblings like gdb_print or gdb_examine that might also show register values. The purpose is understandable but lacks specificity and differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., requires an active GDB session), exclusions, or comparisons to siblings like gdb_print (which might display variables including registers) or gdb_examine (which might inspect memory). Usage is implied only by the tool name and context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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