Skip to main content
Glama

analyze_log

Analyze error logs to identify root causes and provide AI-powered insights for debugging server issues with contextual analysis.

Instructions

Analyze error logs and provide root cause analysis with AI-powered insights

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contextLinesNoNumber of context lines to include around errors
logFormatNoFormat of the log contentauto
logTextYesLog content to analyze

Implementation Reference

  • MCP tool handler for 'analyze_log': validates input, calls LogAnalyzer.analyzeLogs, formats MCPToolResult response
    private async handleAnalyzeLog(args: any): Promise<MCPToolResult> {
      const { logText, logFormat = 'auto', contextLines = 50 } = args;
    
      if (!logText || typeof logText !== 'string') {
        throw new Error('logText is required and must be a string');
      }
    
      const analysis = await this.logAnalyzer.analyzeLogs(logText, {
        logFormat,
        contextLines
      });
    
      return {
        success: true,
        data: analysis,
        metadata: {
          processedAt: new Date(),
          logLength: logText.length,
          format: logFormat
        }
      };
    }
  • Core implementation: preprocesses logs, generates AI prompt for Gemini, parses response into structured LogAnalysis
    async analyzeLogs(logText: string, options: LogParsingOptions): Promise<LogAnalysis> {
      // Pre-process the log content
      const processedContent = this.preprocessLogs(logText, options);
      
      // Build analysis prompt
      const prompt = this.buildAnalysisPrompt(processedContent, options);
      
      try {
        // Generate analysis using Gemini
        const result = await this.model.generateContent(prompt);
        const response = await result.response;
        
        // Parse and structure the response
        return this.parseResponse(response.text(), logText);
      } catch (error) {
        throw new Error(`Failed to analyze logs: ${error instanceof Error ? error.message : 'Unknown error'}`);
      }
    }
  • Input schema validation for analyze_log tool parameters
    inputSchema: {
      type: 'object',
      properties: {
        logText: {
          type: 'string',
          description: 'Log content to analyze'
        },
        logFormat: {
          type: 'string',
          enum: ['auto', 'json', 'plain'],
          default: 'auto',
          description: 'Format of the log content'
        },
        contextLines: {
          type: 'number',
          default: 50,
          description: 'Number of context lines to include around errors'
        }
      },
      required: ['logText']
    }
  • src/server.ts:78-102 (registration)
    Tool descriptor registration in ListToolsRequestSchema handler, including dispatch case at line 180
    {
      name: 'analyze_log',
      description: 'Analyze error logs and provide root cause analysis with AI-powered insights',
      inputSchema: {
        type: 'object',
        properties: {
          logText: {
            type: 'string',
            description: 'Log content to analyze'
          },
          logFormat: {
            type: 'string',
            enum: ['auto', 'json', 'plain'],
            default: 'auto',
            description: 'Format of the log content'
          },
          contextLines: {
            type: 'number',
            default: 50,
            description: 'Number of context lines to include around errors'
          }
        },
        required: ['logText']
      }
    },
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 mentions 'AI-powered insights', hinting at generative capabilities, but fails to detail critical aspects like processing time, rate limits, authentication needs, or what constitutes 'root cause analysis' (e.g., whether it modifies data or is read-only). For a tool with no annotation coverage, this is a significant gap in transparency.

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, efficient sentence: 'Analyze error logs and provide root cause analysis with AI-powered insights'. It is front-loaded with the core purpose and avoids unnecessary words, making it easy to parse quickly. Every part of the sentence contributes meaning without waste.

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 complexity (AI analysis with 3 parameters) and lack of annotations and output schema, the description is minimally adequate but incomplete. It states the purpose concisely but omits behavioral details, usage context, and output expectations. For a tool that performs analysis, more information on results or limitations would enhance completeness, though it meets a basic threshold.

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?

The input schema has 100% description coverage, providing clear details for all three parameters ('logText', 'contextLines', 'logFormat'). The description adds no additional parameter semantics beyond what's in the schema, such as explaining how 'AI-powered insights' relate to the parameters. With high schema coverage, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

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 tool's purpose: 'Analyze error logs and provide root cause analysis with AI-powered insights'. It specifies the verb ('analyze'), resource ('error logs'), and outcome ('root cause analysis with AI-powered insights'), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from sibling tools like 'get_recent_errors' or 'rapid_debug', which prevents a perfect score.

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. With sibling tools like 'get_recent_errors', 'quick_scan', and 'rapid_debug' available, there's no indication of specific contexts, prerequisites, or exclusions for using 'analyze_log'. This lack of comparative guidance leaves the agent uncertain about tool selection.

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/ChiragPatankar/loganalyzer-mcp'

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