Skip to main content
Glama

find_solution

Search for verified fixes to programming errors and technical problems before debugging manually. Paste error messages or describe issues to find matched solutions.

Instructions

Search cache.overflow for a verified fix. Paste the error message or describe the problem. Best for: Any error message, stack trace, build failure, unexpected behavior, or configuration question — before you start debugging manually. Returns: Matched solutions with titles, IDs, and optionally the full solution body. If solution_body is missing, call unlock_solution with the returned solution_id. Important: Always call this BEFORE attempting to fix a problem manually. If you catch yourself debugging without having searched first — stop, search, then continue.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesPaste the error message or describe the problem with the technology name.

Implementation Reference

  • Main implementation of the find_solution tool, including the ToolDefinition with schema (lines 34-49) and the async handler function (lines 50-148) that validates input, calls the client API, handles human verification dialogs, and formats results with workflow instructions.
    export const findSolution: ToolDefinition = {
      definition: {
        name: 'find_solution',
        description:
          'Search for existing solutions in the cache.overflow knowledge base. ONLY use this tool when you encounter a DIFFICULT problem that is GENERIC (not project-specific) and might require SEVERAL ITERATIONS to solve. Do NOT use for simple fixes or quick tasks. Returns matching solutions based on semantic similarity. Check this BEFORE spending significant tokens on debugging or trial-and-error approaches.',
        inputSchema: {
          type: 'object',
          properties: {
            query: {
              type: 'string',
              description: 'A clear description of the problem you are trying to solve. Be specific about the technology, error message, or goal. Examples: "EADDRINUSE error when starting Node.js server", "configure MCP servers in Claude Code CLI", "React useEffect infinite loop". Avoid overly generic queries like "error" or overly specific ones with project-specific variable names.',
            },
          },
          required: ['query'],
        },
      },
      handler: async (args, client) => {
        // #5 - Add input validation
        const query = (args.query as string || '').trim();
    
        if (!query) {
          return {
            content: [{ type: 'text', text: 'Error: Query cannot be empty. Please provide a description of the problem you are trying to solve.' }],
          };
        }
    
        if (query.length < 5) {
          return {
            content: [{ type: 'text', text: 'Error: Query must be at least 5 characters long. Please provide more details about the problem.' }],
          };
        }
    
        if (query.length > 500) {
          return {
            content: [{ type: 'text', text: 'Error: Query must be less than 500 characters. Please provide a more concise description.' }],
          };
        }
    
        const result = await client.findSolution(query);
    
        if (!result.success) {
          // #6 - Improve error messages with context
          const errorMessage = [
            `āŒ ${getErrorTitle(result.error || '')}`,
            '',
            result.error,
            '',
            'šŸ’” **What to try:**',
            getRecoverySuggestions(result.error || ''),
            '',
            `šŸ“‹ **Logs**: Check ${config.logging.logDir || '~/.cache-overflow'}/cache-overflow-mcp.log for details`,
          ].join('\n');
    
          return {
            content: [{ type: 'text', text: errorMessage }],
          };
        }
    
        // Process human verification for solutions that require it
        for (const solution of result.data) {
          if (solution.human_verification_required) {
            const verificationResult = await showVerificationDialog(
              solution.query_title,
              solution.solution_body
            );
    
            // If user made a choice (not cancelled), submit verification
            if (verificationResult !== null) {
              // #10 - Catch verification submission errors
              try {
                const submitResult = await client.submitVerification(solution.solution_id, verificationResult);
                if (!submitResult.success) {
                  // Log but don't fail - user still gets the solution content
                  console.warn(`Warning: Failed to submit verification for solution ${solution.solution_id}: ${submitResult.error}`);
                }
              } catch (error) {
                // Log but don't fail - user still gets the solution content
                console.warn(`Warning: Error submitting verification for solution ${solution.solution_id}:`, error);
              }
            }
          }
        }
    
        // Build workflow instructions based on solution types
        const hasVerificationNeeded = result.data.some(s => s.human_verification_required);
        const hasVerifiedSolutions = result.data.some(s => !s.human_verification_required);
    
        let workflowInstructions = '';
        if (result.data.length > 0) {
          workflowInstructions = '\n\nšŸ“‹ NEXT STEPS:';
    
          if (hasVerificationNeeded) {
            workflowInstructions += '\n\nšŸ”’ For solutions with human_verification_required=true (you already have the full solution body):';
            workflowInstructions += '\n1. Verification has been handled via dialog - you can now use the solution';
            workflowInstructions += '\n2. Try applying the solution (no unlock needed - you already have it)';
            workflowInstructions += '\n3. MUST call submit_feedback with is_useful=true/false after trying the solution';
          }
    
          if (hasVerifiedSolutions) {
            workflowInstructions += '\n\nšŸ”“ For solutions with human_verification_required=false (you only have the title):';
            workflowInstructions += '\n1. Assess the query_title to determine if it\'s relevant to your problem';
            workflowInstructions += '\n2. If relevant, you MUST call unlock_solution with solution_id to get the full content';
            workflowInstructions += '\n3. After unlocking and trying the solution, you MUST call submit_feedback with is_useful=true/false';
          }
        }
    
        // Combine reminders
        const reminder = result.data.length === 0
          ? '\n\nšŸ’” REMINDER: No existing solutions found. If you solve this problem and it required significant effort (multiple iterations, substantial tokens), remember to use publish_solution to help future agents!'
          : workflowInstructions + '\n\nšŸ’” TIP: If none of these solutions work and you find a different approach that works, consider using publish_solution to share your solution.';
    
        return {
          content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) + reminder }],
        };
      },
    };
  • Registration of the find_solution tool: imports the findSolution module (line 5) and registers its handler in the toolHandlers map under the 'find_solution' key (line 27).
    import { findSolution } from './find-solution.js';
    import { unlockSolution } from './unlock-solution.js';
    import { publishSolution } from './publish-solution.js';
    import { submitVerification } from './submit-verification.js';
    import { submitFeedback } from './submit-feedback.js';
    
    export interface ToolDefinition {
      definition: Tool;
      handler: (
        args: Record<string, unknown>,
        client: CacheOverflowClient
      ) => Promise<{ content: Array<{ type: string; text: string }> }>;
    }
    
    // Map of tool handlers by name
    const toolHandlers: Record<
      string,
      (
        args: Record<string, unknown>,
        client: CacheOverflowClient
      ) => Promise<{ content: Array<{ type: string; text: string }> }>
    > = {
      find_solution: findSolution.handler,
      unlock_solution: unlockSolution.handler,
      publish_solution: publishSolution.handler,
      submit_verification: submitVerification.handler,
      submit_feedback: submitFeedback.handler,
    };
  • Input schema definition for the find_solution tool within the ToolDefinition: defines a required 'query' string parameter with description and validation constraints (min 5 chars, max 500 chars).
    inputSchema: {
      type: 'object',
      properties: {
        query: {
          type: 'string',
          description: 'A clear description of the problem you are trying to solve. Be specific about the technology, error message, or goal. Examples: "EADDRINUSE error when starting Node.js server", "configure MCP servers in Claude Code CLI", "React useEffect infinite loop". Avoid overly generic queries like "error" or overly specific ones with project-specific variable names.',
        },
      },
      required: ['query'],
    },
  • Type definition for FindSolutionResult interface that defines the structure of solution search results: solution_id, query_title, optional solution_body, and human_verification_required flag.
    export interface FindSolutionResult {
      solution_id: string;
      query_title: string;
      solution_body?: string;
      human_verification_required: boolean;
    }
  • Client API method findSolution that makes a GET request to /solutions/search endpoint, maps API response (using 'id') to the FindSolutionResult interface (using 'solution_id'), and handles error cases.
    async findSolution(query: string): Promise<ApiResponse<FindSolutionResult[]>> {
      const result = await this.requestWithRetry<Array<{ id: string; query_title: string; solution_body?: string; human_verification_required: boolean }>>(
        'GET',
        `/solutions/search?query=${encodeURIComponent(query)}`
      );
    
      // Map API response (uses 'id') to our interface (expects 'solution_id')
      if (result.success) {
        const mappedData = result.data.map(solution => ({
          solution_id: solution.id,
          query_title: solution.query_title,
          solution_body: solution.solution_body,
          human_verification_required: solution.human_verification_required,
        }));
        return { success: true, data: mappedData };
      }
    
      return result as ApiResponse<FindSolutionResult[]>;
    }
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes what the tool does (searches for verified fixes), what it returns (matched solutions with titles, IDs, and optionally full solution bodies), and important behavioral constraints (always call before manual debugging, use unlock_solution if solution_body is missing). However, it doesn't mention rate limits, authentication needs, or error handling.

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 well-structured and appropriately sized, with clear sections for purpose, best use cases, returns, and important guidelines. While slightly verbose in the guidelines section, every sentence adds value by reinforcing usage patterns and workflow integration.

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

Completeness4/5

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

For a single-parameter search tool with no annotations and no output schema, the description provides good contextual completeness. It explains the tool's purpose, when to use it, what it returns, and how to handle missing data. The main gap is the lack of output format details, but the description compensates with workflow guidance.

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 schema description coverage is 100%, so the schema already documents the single 'query' parameter. The description adds some context by specifying what to paste ('error message or describe the problem with the technology name'), but doesn't provide additional syntax or format details beyond what the schema implies. This meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/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 with specific verbs ('Search cache.overflow for a verified fix') and resources ('error message, stack trace, build failure, unexpected behavior, or configuration question'). It distinguishes from siblings by focusing on searching for solutions rather than publishing, submitting feedback/verification, or unlocking solutions.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance on when to use this tool ('before you start debugging manually', 'Always call this BEFORE attempting to fix a problem manually') and when not to ('If you catch yourself debugging without having searched first — stop, search, then continue'). It also references the alternative 'unlock_solution' for getting full solution bodies when missing.

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/GetCacheOverflow/cache-overflow'

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