Skip to main content
Glama
yufeizhou666

log-analyzer-mcp

by yufeizhou666

explain_error

Analyzes error logs and stack traces with surrounding context to provide AI-driven explanations. Helps understand and diagnose errors.

Instructions

AI-assisted error analysis. Formats error content for AI analysis.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
errorContentYesThe error log or stack trace to analyze
contextLinesNoNumber of context lines around the error

Implementation Reference

  • The main handler function for the 'explain_error' tool. It takes errorContent and contextLines input, formats an analysis request, and returns it as AI-prompt text.
    export async function explainError(input: ToolInput): Promise<{ content: Array<{ type: string; text: string }> }> {
      const { errorContent, contextLines = 10 } = input as ExplainErrorInput;
    
      if (!errorContent) {
        return { content: [{ type: 'text', text: 'Error: errorContent is required' }] };
      }
    
      const formatted = `Please analyze the following error and help me understand:
    1. What is the root cause of this error?
    2. What steps should I take to resolve it?
    3. Are there any related logs or patterns I should look for?
    
    Error Log:
    \`\`\`
    ${errorContent}
    \`\`\`
    
    Context: The error occurred with ${contextLines} lines of context around it.`;
    
      return {
        content: [
          { type: 'text', text: 'Error analysis request formatted. The AI will analyze the error content.' },
          { type: 'text', text: formatted }
        ]
      };
    }
  • Type definition for ExplainErrorInput, extending ToolInput with errorContent (string) and optional contextLines (number).
    interface ExplainErrorInput extends ToolInput {
      errorContent: string;
      contextLines?: number;
    }
  • src/index.ts:113-131 (registration)
    Tool registration in the TOOLS array: defines the 'explain_error' tool with name, description, and inputSchema (errorContent required, contextLines optional with default 10).
    {
      name: 'explain_error',
      description: 'AI-assisted error analysis. Formats error content for AI analysis.',
      inputSchema: {
        type: 'object',
        properties: {
          errorContent: {
            type: 'string',
            description: 'The error log or stack trace to analyze'
          },
          contextLines: {
            type: 'number',
            default: 10,
            description: 'Number of context lines around the error'
          }
        },
        required: ['errorContent']
      }
    }
  • src/index.ts:156-157 (registration)
    Request handler routing: the 'explain_error' case in the switch statement dispatches to the explainError function.
    case 'explain_error':
      return await explainError(args || {});
  • The ToolInput base interface used by ExplainErrorInput - defines a generic dictionary type for tool inputs.
    export interface ToolInput {
      [key: string]: unknown;
    }
Behavior2/5

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

No annotations are provided, so the description bears full responsibility. It implies a read-only analysis but does not explicitly state whether the tool modifies data, requires authentication, or has rate limits. The phrase 'formats error content' suggests it is non-destructive, but this is not confirmed.

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

Conciseness4/5

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

The description is two sentences, efficient for a simple tool. However, the second sentence ('Formats error content for AI analysis') is somewhat redundant with the first, and the title is null so the description stands alone.

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?

For a tool with 2 params and no output schema, the description is adequate but does not describe the output format. Given sibling tools (search_logs, count_by_level), it fits well but could mention that the result is formatted text for consumption by an AI.

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% with both parameters documented. The description adds no new meaning beyond what the schema provides; it merely repeats 'error log or stack trace' and 'number of context lines'. Baseline 3 applies due to high coverage.

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 it does AI-assisted error analysis and formats error content for AI analysis. It specifies the verb 'analyze' and resource 'error content'. However, it does not explicitly differentiate from siblings like search_logs which might also process errors.

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 like search_logs or get_system_metrics. It lacks prerequisites, when-not-to-use scenarios, or context for invocation.

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/yufeizhou666/my_mcp'

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