Skip to main content
Glama

read_debug_logs

Access debug logs from the current session to identify and resolve issues in code execution. Choose between raw or formatted output for analysis.

Instructions

Read the collected debug logs from the current session.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formatNoOutput format (default: pretty)pretty

Implementation Reference

  • The handler function for the 'read_debug_logs' tool. It checks for an active session, reads raw logs via sessionManager.readLogs(), formats them if 'pretty' is specified, and returns the logs as text content.
    case 'read_debug_logs': {
      if (!sessionManager.isActive()) {
        return {
          content: [{ type: 'text', text: 'No active debug session.' }],
          isError: true,
        };
      }
    
      const format = (args?.format as string) || 'pretty';
      const logs = sessionManager.readLogs();
    
      if (!logs.trim()) {
        return {
          content: [
            {
              type: 'text',
              text: 'No logs collected yet. Make sure to reproduce the bug to trigger the instruments.',
            },
          ],
        };
      }
    
      if (format === 'raw') {
        return {
          content: [{ type: 'text', text: logs }],
        };
      }
    
      // Pretty format
      const entries = logs
        .trim()
        .split('\n')
        .map((line) => {
          try {
            return JSON.parse(line);
          } catch {
            return null;
          }
        })
        .filter(Boolean);
    
      const formatted = entries
        .map((entry, i) => {
          const time = new Date(entry.timestamp).toISOString();
          const data = JSON.stringify(entry.data, null, 2);
          return `[${i + 1}] ${time}\nInstrument: ${entry.id}\nLocation: ${entry.location}\nData:\n${data}`;
        })
        .join('\n\n---\n\n');
    
      return {
        content: [
          {
            type: 'text',
            text: `Debug logs (${entries.length} entries):\n\n${formatted}`,
          },
        ],
      };
    }
  • The schema definition for the 'read_debug_logs' tool, including input schema with optional 'format' parameter, provided in the ListTools response.
    {
      name: 'read_debug_logs',
      description: 'Read the collected debug logs from the current session.',
      inputSchema: {
        type: 'object',
        properties: {
          format: {
            type: 'string',
            enum: ['raw', 'pretty'],
            description: 'Output format (default: pretty)',
            default: 'pretty',
          },
        },
      },
    },
  • src/index.ts:31-126 (registration)
    The registration of all tools including 'read_debug_logs' via the ListToolsRequestSchema handler.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          {
            name: 'start_debug_session',
            description: 'Start a debug session. This starts a local HTTP server to receive logs from instrumented code.',
            inputSchema: {
              type: 'object',
              properties: {
                port: {
                  type: 'number',
                  description: 'Port number for the debug server (default: 9876)',
                  default: 9876,
                },
              },
            },
          },
          {
            name: 'stop_debug_session',
            description: 'Stop the current debug session and shut down the log server.',
            inputSchema: {
              type: 'object',
              properties: {},
            },
          },
          {
            name: 'add_instrument',
            description: 'Add a debug instrument at a specific line in a file. The instrument will log variable values when executed.',
            inputSchema: {
              type: 'object',
              properties: {
                file: {
                  type: 'string',
                  description: 'Path to the file to instrument (relative to working directory)',
                },
                line: {
                  type: 'number',
                  description: 'Line number where to insert the instrument (1-indexed)',
                },
                capture: {
                  type: 'array',
                  items: { type: 'string' },
                  description: 'Variable names to capture and log',
                  default: [],
                },
              },
              required: ['file', 'line'],
            },
          },
          {
            name: 'remove_instruments',
            description: 'Remove debug instruments from files.',
            inputSchema: {
              type: 'object',
              properties: {
                file: {
                  type: 'string',
                  description: 'Path to file to remove instruments from. If not specified, removes from all instrumented files.',
                },
              },
            },
          },
          {
            name: 'list_instruments',
            description: 'List all active debug instruments.',
            inputSchema: {
              type: 'object',
              properties: {},
            },
          },
          {
            name: 'read_debug_logs',
            description: 'Read the collected debug logs from the current session.',
            inputSchema: {
              type: 'object',
              properties: {
                format: {
                  type: 'string',
                  enum: ['raw', 'pretty'],
                  description: 'Output format (default: pretty)',
                  default: 'pretty',
                },
              },
            },
          },
          {
            name: 'clear_debug_logs',
            description: 'Clear all collected debug logs.',
            inputSchema: {
              type: 'object',
              properties: {},
            },
          },
        ],
      };
    });
  • The SessionManager.readLogs() helper method that reads the raw content from the debug log file.
    readLogs(): string {
      if (!this.session) {
        throw new Error('No active debug session');
      }
    
      if (!existsSync(this.session.logFile)) {
        return '';
      }
    
      return readFileSync(this.session.logFile, 'utf-8');
    }
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. It states this is a read operation, implying it's non-destructive, but doesn't cover other aspects like permissions needed, rate limits, session dependency, or what the output looks like (e.g., log format, size limits). For a tool with zero annotation coverage, this is a significant gap.

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 a single, clear sentence with no wasted words. It's front-loaded with the core purpose, making it highly efficient and easy to parse.

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

Completeness3/5

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

Given the tool's low complexity (one optional parameter) and high schema coverage, the description is minimally adequate. However, with no annotations and no output schema, it lacks details on behavioral traits (e.g., session requirements) and return values, leaving gaps for an agent to infer usage context.

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 fully documents the single parameter 'format' with its enum values and default. The description adds no parameter-specific information beyond what the schema provides, meeting the baseline of 3 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.

Purpose4/5

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

The description clearly states the action ('Read') and the resource ('collected debug logs from the current session'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'clear_debug_logs' or 'list_instruments', which would require a more specific scope statement.

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., needing an active debug session), exclusions, or comparisons to sibling tools like 'clear_debug_logs' for log management or 'list_instruments' for instrument-related data.

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

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/iarmankhan/agentic-debugger'

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