Skip to main content
Glama

unlock_solution

Retrieve complete solutions with problem descriptions, fixes, and working code when find_solution returns partial results. Submit feedback after applying the unlocked solution.

Instructions

Retrieve the full solution body for a matched result from find_solution. Best for: When find_solution returned a match but the solution_body field is missing or empty. Returns: The complete solution with problem description, fix, and working code. Important: After applying the unlocked solution, you must call submit_feedback to rate whether it worked.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
solution_idYesThe solution ID from find_solution results.

Implementation Reference

  • The unlock_solution tool handler that validates input, calls the API client, and formats the response with error context and feedback reminders.
    handler: async (args, client) => {
      // #5 - Add input validation
      const solutionId = (args.solution_id as string || '').trim();
    
      if (!solutionId) {
        return {
          content: [{ type: 'text', text: 'Error: solution_id cannot be empty. Please provide a valid solution ID from find_solution results.' }],
        };
      }
    
      // Validate solution_id format to prevent injection attacks
      if (!/^[a-zA-Z0-9_-]+$/.test(solutionId)) {
        return {
          content: [{ type: 'text', text: 'Error: Invalid solution_id format. Must contain only alphanumeric characters, hyphens, and underscores.' }],
        };
      }
    
      const result = await client.unlockSolution(solutionId);
    
      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 }],
        };
      }
    
      const feedbackReminder = '\n\nāš ļø REQUIRED: You MUST now call submit_feedback with this solution_id after you have tried applying the solution. Report whether it was helpful (is_useful=true/false).';
    
      return {
        content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) + feedbackReminder }],
      };
    },
  • Tool definition including name, description, and input schema that defines the solution_id parameter as a required string.
    export const unlockSolution: ToolDefinition = {
      definition: {
        name: 'unlock_solution',
        description:
          'Unlock a verified solution to access its full content. Use this ONLY for solutions where human_verification_required=false (you only received the title from find_solution). Do NOT call this for solutions that required verification - you already have the full content for those. After receiving find_solution results, assess each solution\'s title. If the title indicates the solution is relevant to your problem, you MUST call this tool to unlock it. This will deduct tokens from your balance based on the solution\'s price. Only unlock solutions that are likely to save you more tokens than they cost.',
        inputSchema: {
          type: 'object',
          properties: {
            solution_id: {
              type: 'string',
              description: 'The ID of the solution to unlock (obtained from find_solution results)',
            },
          },
          required: ['solution_id'],
        },
      },
  • Registration of unlock_solution handler in the toolHandlers mapping that connects the tool name to its handler function.
    find_solution: findSolution.handler,
    unlock_solution: unlockSolution.handler,
  • Error handling helper functions getErrorTitle and getRecoverySuggestions that provide contextual error messages and recovery guidance.
    // #6 - Improve error messages with context
    function getErrorTitle(error: string): string {
      if (error.includes('timeout') || error.includes('timed out')) return 'Request Timed Out';
      if (error.includes('network') || error.includes('fetch')) return 'Network Connection Failed';
      if (error.includes('balance') || error.includes('insufficient')) return 'Insufficient Token Balance';
      if (error.includes('auth') || error.includes('Authentication')) return 'Authentication Failed';
      if (error.includes('Rate limit')) return 'Rate Limit Exceeded';
      if (error.includes('not found') || error.includes('404')) return 'Solution Not Found';
      return 'Operation Failed';
    }
    
    function getRecoverySuggestions(error: string): string {
      if (error.includes('timeout') || error.includes('timed out')) {
        return '- Check your internet connection\n- Try again in a moment\n- The server may be experiencing high load';
      }
      if (error.includes('balance') || error.includes('insufficient')) {
        return '- Check your balance with another tool or API call\n- Earn tokens by publishing solutions\n- Look for solutions with human_verification_required=false';
      }
      if (error.includes('auth') || error.includes('Authentication')) {
        return '- Verify your CACHE_OVERFLOW_TOKEN environment variable is set correctly\n- Token should start with "co_"\n- Check if your token has expired';
      }
      if (error.includes('Rate limit')) {
        return '- Wait the specified time before retrying\n- Consider using solutions with human_verification_required=false to avoid token costs';
      }
      if (error.includes('not found') || error.includes('404')) {
        return '- Verify the solution_id is correct\n- The solution may have been deleted\n- Try searching again with find_solution';
      }
      if (error.includes('network') || error.includes('fetch')) {
        return '- Check your internet connection\n- Verify the CACHE_OVERFLOW_URL is correct\n- Try again in a moment';
      }
      return '- Check the log file for details\n- Verify your CACHE_OVERFLOW_TOKEN is valid\n- Try again in a moment';
    }
  • The unlockSolution client method that performs the actual API POST request to unlock a solution.
    async unlockSolution(solutionId: string): Promise<ApiResponse<Solution>> {
      return this.requestWithRetry('POST', `/solutions/${solutionId}/unlock`);
    }
Behavior4/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. It discloses key behavioral traits: it retrieves data (implied read-only, though not explicitly stated), specifies the return content ('complete solution with problem description, fix, and working code'), and outlines a required follow-up action ('call submit_feedback'). However, it doesn't mention potential errors, rate limits, or authentication needs, leaving some gaps.

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 front-loaded with the core purpose, followed by specific usage guidelines and return details in a bullet-like structure. Every sentence adds value without redundancy, making it efficient and well-organized for quick comprehension.

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?

Given the tool's moderate complexity (retrieval with a follow-up requirement), no annotations, and no output schema, the description does well by explaining the purpose, usage, return content, and post-action. However, it lacks details on error handling or output structure, which could be useful for an agent, slightly reducing 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 schema description coverage is 100%, so the schema already documents the single parameter 'solution_id' adequately. The description adds minimal value beyond the schema by referencing 'solution ID from find_solution results,' which provides context but no additional syntax or format details. 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 ('retrieve the full solution body') and resources ('for a matched result from find_solution'). It explicitly distinguishes from its sibling find_solution by addressing when find_solution's output is incomplete, making the purpose distinct and well-defined.

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 ('When find_solution returned a match but the solution_body field is missing or empty') and names an alternative action ('call submit_feedback') for post-use steps. It clearly differentiates usage from find_solution and links to other tools, offering comprehensive context.

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