Skip to main content
Glama
rodhayl
by rodhayl

mcp_error_explainer

Explains error messages and stack traces to identify root causes and suggest fixes for programming issues.

Instructions

Explain stack traces/errors and likely fixes.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
errorYesError message or stacktrace
languageNoProgramming language (optional)
contextNoAdditional context about the code (optional)

Implementation Reference

  • The `explainError` method implements the `mcp_error_explainer` tool logic, using an LLM to analyze error messages and context to provide explanations and fixes.
      async explainError(
        errorMessage: string,
        options?: {
          stackTrace?: string;
          codeContext?: string;
          language?: string;
        }
      ): Promise<ExplainErrorResult> {
        const language = options?.language ?? 'code';
    
        const prompt = `You are an expert debugger. Analyze this error and help diagnose the root cause.
    ${options?.language ? `Language: ${options.language}` : ''}
    
    Provide your response as JSON:
    {
      "rootCause": "The fundamental cause of the error",
      "explanation": "Detailed explanation of why this error occurred",
      "suggestedFixes": [
        {
          "description": "How to fix it",
          "code": "Optional code example"
        }
      ],
      "relatedDocs": ["Links or references to relevant documentation"]
    }`;
    
        const userContent = `Error: ${errorMessage}
    ${options?.stackTrace ? `\nStack Trace:\n${options.stackTrace}` : ''}
    ${options?.codeContext ? `\nCode Context:\n\`\`\`${language}\n${options.codeContext}\n\`\`\`` : ''}`;
    
        try {
          const responseText = await this.llmWrapper.callToolLlm(
            'mcp_error_explainer',
            [
              { role: 'system', content: prompt },
              { role: 'user', content: userContent },
            ],
            { type: 'explain_error', language }
          );
    
          const parsed = this.parseJsonResponse(responseText, {
            rootCause: '',
            explanation: responseText,
            suggestedFixes: [],
          });
    
          const rawExplanation =
            typeof (parsed as any)?.explanation === 'string' ? String((parsed as any).explanation) : '';
          const fallbackExplanation = responseText?.trim() || `Error: ${errorMessage}`;
          const explanation = rawExplanation.trim() ? rawExplanation.trim() : fallbackExplanation;
    
          return {
            success: true,
            rootCause: parsed.rootCause || 'Unable to determine',
            explanation,
            suggestedFixes: parsed.suggestedFixes || [],

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/rodhayl/mcpLocalHelper'

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