Skip to main content
Glama

search_conversations

Search Claude Code conversation history to find past solutions, track file changes, and learn from previous work.

Instructions

Search through Claude Code conversation history with smart insights

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query to find relevant conversations
projectNoOptional project name to filter results
timeframeNoTime range filter (today, week, month)
limitNoMaximum number of results (default: 10)
detail_levelNoResponse detail: summary (default), detailed, rawsummary

Implementation Reference

  • MCP CallTool handler for 'search_conversations' that invokes universalEngine.searchConversations and formats the result using BeautifulFormatter
    case 'search_conversations': {
      const universalResult = await this.universalEngine.searchConversations(
        args?.query as string,
        args?.project as string,
        args?.timeframe as string,
        (args?.limit as number) || 10
      );
    
      const detailLevel = (args?.detail_level as string) || 'summary';
      const formattedResult = this.formatter.formatSearchConversations(
        universalResult.results,
        detailLevel
      );
    
      return {
        content: [{ type: 'text', text: formattedResult }],
      };
    }
  • Input schema definition for the search_conversations tool, defining parameters like query, project, timeframe, limit, and detail_level
    inputSchema: {
      type: 'object',
      properties: {
        query: {
          type: 'string',
          description: 'Search query to find relevant conversations',
        },
        project: {
          type: 'string',
          description: 'Optional project name to filter results',
        },
        timeframe: {
          type: 'string',
          description: 'Time range filter (today, week, month)',
        },
        limit: {
          type: 'number',
          description: 'Maximum number of results (default: 10)',
          default: 10,
        },
        detail_level: {
          type: 'string',
          description: 'Response detail: summary (default), detailed, raw',
          enum: ['summary', 'detailed', 'raw'],
          default: 'summary',
        },
      },
      required: ['query'],
    },
  • src/index.ts:45-76 (registration)
    Tool registration in ListTools response, including name and description
      name: 'search_conversations',
      description: 'Search through Claude Code conversation history with smart insights',
      inputSchema: {
        type: 'object',
        properties: {
          query: {
            type: 'string',
            description: 'Search query to find relevant conversations',
          },
          project: {
            type: 'string',
            description: 'Optional project name to filter results',
          },
          timeframe: {
            type: 'string',
            description: 'Time range filter (today, week, month)',
          },
          limit: {
            type: 'number',
            description: 'Maximum number of results (default: 10)',
            default: 10,
          },
          detail_level: {
            type: 'string',
            description: 'Response detail: summary (default), detailed, raw',
            enum: ['summary', 'detailed', 'raw'],
            default: 'summary',
          },
        },
        required: ['query'],
      },
    },
  • Core implementation of searchConversations in UniversalHistorySearchEngine, combining results from Claude Code (primary) and Claude Desktop (if available, currently disabled)
    async searchConversations(
      query: string,
      project?: string,
      timeframe?: string,
      limit?: number
    ): Promise<UniversalSearchResult> {
      await this.initialize();
    
      const claudeCodeResults = await this.claudeCodeEngine.searchConversations(
        query,
        project,
        timeframe,
        limit
      );
    
      if (!this.claudeDesktopAvailable) {
        return {
          source: 'claude-code',
          results: claudeCodeResults,
          enhanced: false,
        };
      }
    
      const desktopMessages = await this.searchClaudeDesktopConversations(query, timeframe, limit);
    
      const combinedResults = this.combineSearchResults(claudeCodeResults, desktopMessages);
    
      // Only mark as enhanced if we actually found Desktop data
      const hasDesktopData = desktopMessages.length > 0;
    
      return {
        source: hasDesktopData ? 'claude-desktop' : 'claude-code',
        results: combinedResults,
        enhanced: hasDesktopData,
      };
    }
  • Helper function to format search results into a structured JSON response with ranking and deduplication for maximum information density
    formatSearchConversations(result: SearchResult, _detailLevel: string = 'summary'): string {
      const header = `${robots.search} "${result.searchQuery}" | ${result.messages.length} results`;
    
      if (result.messages.length === 0) {
        return `${header}\n\n{"results":[]}`;
      }
    
      const rankedMessages = this.rankAndDeduplicateMessages(result.messages);
      const topMessages = rankedMessages.slice(0, 8);
    
      const structured = {
        results: topMessages.map((msg) => ({
          type: msg.type,
          ts: this.formatTimestamp(msg.timestamp),
          content: msg.content,
          project: msg.projectPath?.split('/').pop() || null,
          score: msg.relevanceScore || msg.score || null,
          ctx: msg.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?

With no annotations provided, the description carries full burden but only vaguely mentions 'smart insights' without explaining what these entail (e.g., ranking, relevance scoring, or AI-enhanced filtering). It doesn't disclose behavioral traits like pagination, rate limits, authentication needs, or what 'search' means operationally (e.g., full-text, metadata). This leaves significant gaps for a search tool.

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 a single, efficient sentence that front-loads the core purpose. However, 'smart insights' is vague and could be more precise. It avoids redundancy but misses opportunities to add critical context, making it slightly under-specified rather than optimally concise.

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

Completeness2/5

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

For a search tool with 5 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain return values, error handling, or the 'smart insights' feature, leaving the agent unsure of behavioral outcomes. Given the complexity and lack of structured data, more detail is needed to guide effective tool use.

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 fully documents all 5 parameters. The description adds no parameter-specific information beyond what's in the schema, not explaining how 'query' interacts with 'smart insights' or clarifying parameter interdependencies. Baseline 3 is appropriate as the schema does the heavy lifting, but the description doesn't compensate with additional context.

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 searches through 'Claude Code conversation history with smart insights', specifying both the verb (search) and resource (conversation history). It distinguishes from siblings like 'list_recent_sessions' (which lists rather than searches) and 'find_similar_queries' (which focuses on queries rather than conversations). However, it doesn't explicitly mention what 'smart insights' entail, leaving some ambiguity.

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 like 'list_recent_sessions' for recent conversations without search, 'find_similar_queries' for query analysis, or 'search_plans' for different content. It mentions 'smart insights' but doesn't clarify what contexts benefit from them versus basic search, offering no explicit when/when-not instructions.

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