Skip to main content
Glama

Think Recall

think_recall

Search through current session thoughts or past insights to find relevant decisions before tackling complex tasks.

Instructions

Search through thoughts or past insights.

Scopes:

  • session: Current session thoughts (default)

  • insights: Past successful solutions (cross-session)

Use before starting complex tasks to find relevant past decisions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query (fuzzy matching)
scopeNoWhere to searchsession
searchInNoWhat to search (session only)all
limitNoMax results
thresholdNoMatch strictness (lower = stricter)

Implementation Reference

  • The inline async handler function registered for the 'think_recall' MCP tool. It dispatches to session recall or insights recall based on scope, formats results with match counts and snippets, and handles errors.
    async (args) => {
      try {
        const scope = (args.scope as 'session' | 'insights') ?? 'session';
        const query = args.query as string;
        const limit = (args.limit as number) ?? 3;
    
        if (scope === 'insights') {
          // Search past insights
          const result = await thinkingService.recallInsights(query, limit);
    
          if (result.matches.length === 0) {
            const patternsText = result.topPatterns.length > 0
              ? `\n\nšŸ“Š Patterns in ${result.totalInsights} insights:\n${result.topPatterns.map(p => `  • ${p.keyword}: ${p.count}`).join('\n')}`
              : '';
            return { content: [{ type: 'text' as const, text: `šŸ” No insights for "${query}"${patternsText}` }] };
          }
    
          const text = [
            `🧠 INSIGHTS for "${query}"`,
            `Found ${result.matches.length}/${result.totalInsights}`,
            '',
            ...result.matches.map((m, i) => [
              `#${i + 1} (${Math.round((1 - m.relevance) * 100)}%)`,
              `  ${m.insight.summary}`,
              `  Keywords: ${m.insight.keywords.join(', ')}`,
            ].join('\n')),
          ].join('\n');
    
          return { content: [{ type: 'text' as const, text }] };
        } else {
          // Search current session
          const result = thinkingService.recallThought({
            query,
            scope: 'current',
            searchIn: (args.searchIn as 'thoughts' | 'extensions' | 'alternatives' | 'all') ?? 'all',
            limit,
            threshold: (args.threshold as number) ?? 0.4,
          });
    
          if (result.matches.length === 0) {
            return { content: [{ type: 'text' as const, text: `šŸ” No matches for "${query}" in ${result.totalSearched} items` }] };
          }
    
          const text = [
            `šŸ” RECALL "${query}"`,
            `Found ${result.matches.length}/${result.totalSearched}`,
            '',
            ...result.matches.map((m, i) => [
              `#${i + 1} Thought #${m.thoughtNumber} (${Math.round((1 - m.relevance) * 100)}%)`,
              `  "${m.snippet}"`,
            ].join('\n')),
          ].join('\n');
    
          return { content: [{ type: 'text' as const, text }] };
        }
      } catch (error) {
        return { content: [{ type: 'text' as const, text: `Error: ${error instanceof Error ? error.message : 'Unknown'}` }], isError: true };
      }
    }
  • Input schema (Zod object) for the think_recall tool, defining parameters like query, scope (session/insights), searchIn fields, limit, and threshold.
    const thinkRecallSchema = {
      query: z.string().min(2).describe('Search query (fuzzy matching)'),
      scope: z.enum(['session', 'insights']).optional().default('session').describe('Where to search'),
      searchIn: z.enum(['thoughts', 'extensions', 'alternatives', 'all']).optional().default('all').describe('What to search (session only)'),
      limit: z.number().int().min(1).max(10).optional().default(3).describe('Max results'),
      threshold: z.number().min(0).max(1).optional().default(0.4).describe('Match strictness (lower = stricter)'),
    };
  • src/index.ts:299-299 (registration)
    The server.registerTool call that registers the 'think_recall' tool with its title, description, schema, and inline handler function.
    server.registerTool('think_recall', { title: 'Think Recall', description: THINK_RECALL_DESCRIPTION, inputSchema: thinkRecallSchema },
  • RecallService.recallThought: Core fuzzy search logic for current session thoughts using Fuse.js. Builds searchable index from thoughts/extensions/alternatives/subSteps, performs search, extracts snippets, filters by scope.
    recallThought(input: RecallInput, thoughts: ThoughtRecord[]): RecallResult {
      const {
        query,
        scope = 'current',
        searchIn = 'all',
        limit = RECALL_DEFAULT_LIMIT,
        threshold = RECALL_DEFAULT_THRESHOLD,
      } = input;
    
      // Validate query
      if (!query || query.trim().length < 2) {
        return {
          matches: [],
          totalSearched: 0,
          query,
          searchParams: { scope, searchIn, threshold },
        };
      }
    
      // Rebuild index if dirty
      if (this.fuseIndexDirty || !this.fuseIndex) {
        this.rebuildFuseIndex(thoughts);
      }
    
      // Perform search (get more results than needed for filtering)
      const rawResults = this.fuseIndex?.search(query, { limit: limit * 5 }) ?? [];
    
      // Filter by threshold (Fuse returns score where lower = better match)
      const thresholdFiltered = rawResults.filter((r) => (r.score ?? 1) <= threshold);
    
      // Filter by searchIn parameter
      const filteredResults = thresholdFiltered.filter((r) => {
        if (searchIn === 'all') return true;
        if (searchIn === 'thoughts') return r.item.type === 'thought';
        if (searchIn === 'extensions') return r.item.type === 'extension';
        if (searchIn === 'alternatives')
          return r.item.type === 'alternative' || r.item.type === 'subStep';
        return true;
      });
    
      // Map to RecallMatch format
      const matches: RecallMatch[] = filteredResults.slice(0, limit).map((r) => ({
        thoughtNumber: r.item.thoughtNumber,
        snippet: this.extractSnippet(r.item.content, query),
        thought:
          r.item.originalThought.length > 300
            ? r.item.originalThought.substring(0, 300) + '...'
            : r.item.originalThought,
        confidence: r.item.confidence,
        relevance: r.score ?? 1,
        matchedIn: r.item.type,
        extensionType: r.item.extensionType as ExtensionType | undefined,
        sessionId: r.item.sessionId,
      }));
    
      // Log search
      console.error(
        `šŸ” Recall search: "${query}" → ${matches.length} matches (searched ${filteredResults.length} items)`
      );
    
      return {
        matches,
        totalSearched: rawResults.length,
        query,
        searchParams: { scope, searchIn, threshold },
      };
    }
  • InsightsService.search: Core search logic for past insights (cross-session winning paths). Uses Fuse.js on summaries, goals, keywords; provides top patterns and stats.
    async search(query: string, limit = 3): Promise<InsightsSearchResult> {
      if (!this.data) await this.load();
      if (!this.fuseIndex || this.data!.winningPaths.length === 0) {
        return {
          matches: [],
          totalInsights: 0,
          topPatterns: [],
        };
      }
    
      // Search using Fuse.js
      const results = this.fuseIndex.search(query, { limit });
    
      const matches: InsightMatch[] = results.map(r => ({
        insight: r.item,
        relevance: r.score ?? 1,
      }));
    
      // Get top patterns
      const topPatterns = Object.entries(this.data!.patterns)
        .sort((a, b) => b[1] - a[1])
        .slice(0, 5)
        .map(([keyword, count]) => ({ keyword, count }));
    
      return {
        matches,
        totalInsights: this.data!.winningPaths.length,
        topPatterns,
      };
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. While it mentions scopes and when to use the tool, it doesn't describe important behavioral aspects: whether this is a read-only operation, what format results return, if there are rate limits, authentication requirements, or error conditions. For a search tool with 5 parameters, this leaves significant gaps in understanding how the tool behaves.

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 perfectly structured and concise: a clear purpose statement, bulleted scope definitions, and a usage guideline - all in 3 sentences. Every sentence earns its place with no wasted words, and the information is front-loaded appropriately.

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 (5 parameters, search functionality) and 100% schema coverage but no annotations or output schema, the description provides adequate but incomplete context. It covers purpose and usage well but lacks behavioral transparency about what results look like, error handling, or operational constraints that would be important for a search tool.

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%, so the schema already documents all 5 parameters thoroughly with descriptions, enums, defaults, and constraints. The description adds minimal parameter semantics beyond the schema - it mentions scopes but doesn't explain the practical differences between 'session' and 'insights' beyond their names. Baseline 3 is appropriate when the schema does the heavy lifting.

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 as 'Search through thoughts or past insights' with specific scopes (session/insights), which is a clear verb+resource combination. However, it doesn't explicitly differentiate from sibling tools like 'think' or 'think_batch' - we can infer it's for searching rather than creating/processing thoughts, but no direct comparison is made.

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

Usage Guidelines4/5

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

The description provides clear context for when to use the tool ('Use before starting complex tasks to find relevant past decisions') and defines scopes with defaults. It doesn't explicitly state when NOT to use it or name specific alternatives among siblings, but the guidance is practical and actionable.

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/GofMan5/think-mcp'

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