Skip to main content
Glama

get_error_solutions

Find solutions for specific error messages by searching Claude conversation history to resolve coding problems.

Instructions

Find solutions for specific errors with enhanced matching

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
error_patternYesError message or pattern to search for solutions
limitNoMaximum number of results (default: 8)
detail_levelNoResponse detail: summary (default), detailed, rawsummary

Implementation Reference

  • Core handler implementation in HistorySearchEngine.getErrorSolutions. Searches conversation JSONL files across projects for matching error patterns, collects subsequent assistant/tool_result messages as solutions, filters for quality, and returns structured ErrorSolution objects with frequency.
    async getErrorSolutions(errorPattern: string, limit: number = 10): Promise<ErrorSolution[]> {
      const solutions: ErrorSolution[] = [];
      const errorMap = new Map<string, CompactMessage[]>();
    
      try {
        const projectDirs = await findProjectDirectories();
    
        // BALANCED: More projects for better coverage, still much faster than sequential
        const limitedDirs = projectDirs.slice(0, 12); // Increased for better coverage
    
        // PARALLEL PROCESSING: Process all projects concurrently
        const projectResults = await Promise.allSettled(
          limitedDirs.map(async (projectDir) => {
            const jsonlFiles = await findJsonlFiles(projectDir);
    
            // BALANCED: More files for better coverage
            const limitedFiles = jsonlFiles.slice(0, 6);
    
            const projectErrorMap = new Map<string, CompactMessage[]>();
    
            // PARALLEL: Process files within project simultaneously
            const fileResults = await Promise.allSettled(
              limitedFiles.map(async (file) => {
                const messages = await this.parser.parseJsonlFile(projectDir, file);
    
                // Find error patterns and their solutions
                for (let i = 0; i < messages.length - 1; i++) {
                  const current = messages[i];
    
                  // More precise error matching - require significant overlap
                  const lowerPattern = errorPattern.toLowerCase();
                  const patternWords = lowerPattern.split(/\s+/).filter((w) => w.length > 2);
    
                  // Extract error type if present (TypeError, SyntaxError, etc.)
                  const errorType = lowerPattern.match(
                    /(typeerror|syntaxerror|referenceerror|rangeerror|error)/
                  )?.[0];
    
                  const hasMatchingError = current.context?.errorPatterns?.some((err) => {
                    const lowerErr = err.toLowerCase();
    
                    // Require error type to match if specified
                    if (errorType && !lowerErr.includes(errorType)) {
                      return false;
                    }
    
                    // Require at least 3 pattern words to match, or full phrase match (stricter)
                    if (lowerErr.includes(lowerPattern)) return true;
                    const matchCount = patternWords.filter((w) => lowerErr.includes(w)).length;
                    return matchCount >= Math.min(3, patternWords.length);
                  });
    
                  // Only include if it's an actual error (not meta-discussion about errors)
                  const isActualErrorContent = this.isActualError(current.content);
    
                  // Filter out meta-content (plans, benchmarks, discussions)
                  if (
                    (hasMatchingError ||
                      SearchHelpers.hasErrorInContent(current.content, errorPattern)) &&
                    isActualErrorContent &&
                    !this.isMetaErrorContent(current.content)
                  ) {
                    // Use the most relevant error pattern as key
                    const matchedError =
                      current.context?.errorPatterns?.find((err) =>
                        err.toLowerCase().includes(lowerPattern)
                      ) ||
                      current.context?.errorPatterns?.[0] ||
                      errorPattern;
                    const errorKey = matchedError;
    
                    if (!projectErrorMap.has(errorKey)) {
                      projectErrorMap.set(errorKey, []);
                    }
    
                    // Include the error message and the next few messages as potential solutions
                    const solutionMessages = messages
                      .slice(i, i + 8) // Get more context for better solutions (increased from 5 to 8)
                      .filter(
                        (msg) =>
                          msg.type === 'assistant' ||
                          msg.type === 'tool_result' ||
                          (msg.type === 'user' && msg.content.length < 200) // Include short user clarifications
                      );
    
                    projectErrorMap.get(errorKey)!.push(...solutionMessages);
                  }
                }
              })
            );
    
            return projectErrorMap;
          })
        );
    
        // Aggregate results from parallel processing
        for (const result of projectResults) {
          if (result.status === 'fulfilled') {
            const projectErrorMap = result.value;
            for (const [pattern, msgs] of projectErrorMap.entries()) {
              if (!errorMap.has(pattern)) {
                errorMap.set(pattern, []);
              }
              errorMap.get(pattern)!.push(...msgs);
            }
          }
        }
    
        // Convert to ErrorSolution format
        for (const [pattern, msgs] of errorMap.entries()) {
          // Assistant responses following errors are solutions by context
          // Lower threshold from 50 to 20 chars for actionable short solutions
          const qualitySolutions = msgs.filter(
            (msg) =>
              msg.type === 'assistant' &&
              !this.isLowValueContent(msg.content) &&
              msg.content.length >= 20
          );
    
          if (qualitySolutions.length > 0) {
            solutions.push({
              errorPattern: pattern,
              solution: qualitySolutions.slice(0, 5), // Include up to 5 solutions (increased from 3)
              context: SearchHelpers.extractSolutionContext(qualitySolutions),
              frequency: msgs.length,
            });
          }
        }
    
        return solutions.sort((a, b) => b.frequency - a.frequency).slice(0, limit);
      } catch (error) {
        console.error('Error solution search error:', error);
        return [];
      }
    }
  • src/index.ts:133-157 (registration)
    Tool registration in ListToolsRequestSchema handler, including name, description, and input schema.
    {
      name: 'get_error_solutions',
      description: 'Find solutions for specific errors with enhanced matching',
      inputSchema: {
        type: 'object',
        properties: {
          error_pattern: {
            type: 'string',
            description: 'Error message or pattern to search for solutions',
          },
          limit: {
            type: 'number',
            description: 'Maximum number of results (default: 8)',
            default: 8,
          },
          detail_level: {
            type: 'string',
            description: 'Response detail: summary (default), detailed, raw',
            enum: ['summary', 'detailed', 'raw'],
            default: 'summary',
          },
        },
        required: ['error_pattern'],
      },
    },
  • MCP server handler wrapper that delegates to UniversalHistorySearchEngine.getErrorSolutions and formats output.
    case 'get_error_solutions': {
      const universalResult = await this.universalEngine.getErrorSolutions(
        args?.error_pattern as string,
        (args?.limit as number) || 8
      );
    
      const detailLevel = (args?.detail_level as string) || 'summary';
      const formattedResult = this.formatter.formatErrorSolutions(
        universalResult.results,
        args?.error_pattern as string,
        detailLevel
      );
    
      return {
        content: [{ type: 'text', text: formattedResult }],
      };
    }
  • Input schema definition for get_error_solutions tool.
    inputSchema: {
      type: 'object',
      properties: {
        error_pattern: {
          type: 'string',
          description: 'Error message or pattern to search for solutions',
        },
        limit: {
          type: 'number',
          description: 'Maximum number of results (default: 8)',
          default: 8,
        },
        detail_level: {
          type: 'string',
          description: 'Response detail: summary (default), detailed, raw',
          enum: ['summary', 'detailed', 'raw'],
          default: 'summary',
        },
      },
      required: ['error_pattern'],
    },
  • Helper formatter that structures and ranks error solutions output with robot emoji header and JSON response.
    formatErrorSolutions(
      solutions: ErrorSolution[],
      errorPattern: string,
      _detailLevel: string = 'summary'
    ): string {
      const header = `${robots.errorSolutions} "${errorPattern}" | ${solutions.length} solutions`;
    
      if (solutions.length === 0) {
        return `${header}\n\n{"solutions":[]}`;
      }
    
      const rankedSolutions = this.rankErrorSolutions(solutions);
      const topSolutions = rankedSolutions.slice(0, 5);
    
      const structured = {
        error_pattern: errorPattern,
        solutions: topSolutions.map((sol) => {
          // Include multiple fixes from all solutions, not just the first
          const fixes = sol.solution.map((s) => ({
            content: s.content,
            code: s.context?.codeSnippets || null,
            files: s.context?.filesReferenced || null,
          }));
    
          return {
            pattern: sol.errorPattern,
            frequency: sol.frequency,
            fixes: fixes,
            ctx: sol.solution[0]?.context || null,
          };
        }),
      };
    
      return `${header}\n\n${JSON.stringify(structured, null, 2)}`;
    }
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 'enhanced matching,' which hints at improved search capabilities, but doesn't explain what 'enhanced' entails, such as fuzzy matching or prioritization. It also omits details like rate limits, authentication needs, or response format, leaving gaps in understanding the tool's 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 a single, efficient sentence: 'Find solutions for specific errors with enhanced matching.' It's front-loaded with the core purpose and avoids unnecessary words. Every part of the sentence contributes directly to understanding the tool's function, making it highly concise and well-structured.

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 moderate complexity (3 parameters, no output schema, no annotations), the description is minimally adequate. It states the purpose but lacks details on behavioral traits, usage context, or output expectations. While it covers the basics, it doesn't fully compensate for the absence of annotations or output schema, leaving room for improvement in completeness.

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, clearly documenting all parameters: 'error_pattern,' 'limit,' and 'detail_level.' The description doesn't add any extra semantic meaning beyond this, such as examples or usage tips. Since the schema does the heavy lifting, the baseline score of 3 is appropriate, as the description doesn't compensate or enhance the parameter understanding.

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: 'Find solutions for specific errors with enhanced matching.' It specifies the verb ('Find') and resource ('solutions for specific errors'), making the function understandable. However, it doesn't explicitly differentiate from sibling tools like 'find_similar_queries' or 'search_conversations,' which might also involve error-related searches, so it doesn't reach the highest 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. It doesn't mention sibling tools or contexts where this tool is preferred, such as for error troubleshooting versus general search. Without such distinctions, users might struggle to choose between this and tools like 'search_conversations' or 'find_similar_queries.'

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/Vvkmnn/claude-historian'

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