Skip to main content
Glama

search_memories

Search stored memories by content or category to retrieve relevant information from your AI assistant's knowledge base.

Instructions

find|search|look for|query memories - Search memories by content

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query
categoryNoCategory to search in

Implementation Reference

  • The main execution handler for the search_memories tool. It uses MemoryManager to search memories by query, optionally filters by category, formats the results as a bulleted list, and returns a ToolResult with the findings or error.
    export async function searchMemoriesHandler(args: { query: string; category?: string }): Promise<ToolResult> {
      const { query, category } = args;
    
      try {
        const mm = MemoryManager.getInstance();
        let results = mm.search(query);
    
        // Filter by category if specified
        if (category) {
          results = results.filter(m => m.category === category);
        }
    
        const resultList = results.map(m =>
          `• ${m.key} (${m.category}): ${m.value.substring(0, 100)}${m.value.length > 100 ? '...' : ''}`
        ).join('\n');
    
        const categoryInfo = category ? ` in category "${category}"` : '';
        return {
          content: [{
            type: 'text',
            text: `✓ Found ${results.length} matches for "${query}"${categoryInfo}:\n${resultList || 'None'}`
          }]
        };
      } catch (error) {
        return {
          content: [{ type: 'text', text: `✗ Error: ${error instanceof Error ? error.message : 'Unknown error'}` }]
        };
      }
    }
  • The ToolDefinition object defining the tool's name, description, input schema (requiring 'query' string, optional 'category'), and annotations.
    export const searchMemoriesDefinition: ToolDefinition = {
      name: 'search_memories',
      description: 'find|search|look for|query memories - Search memories by content',
      inputSchema: {
        type: 'object',
        properties: {
          query: { type: 'string', description: 'Search query' },
          category: { type: 'string', description: 'Category to search in' }
        },
        required: ['query']
      },
      annotations: {
        title: 'Search Memories',
        audience: ['user', 'assistant']
      }
    };
  • src/index.ts:124-134 (registration)
    Registration of searchMemoriesDefinition in the main tools array, which is used by the MCP server's listTools handler with pagination support.
    // Memory Management Tools
    saveMemoryDefinition,
    recallMemoryDefinition,
    listMemoriesDefinition,
    deleteMemoryDefinition,
    searchMemoriesDefinition,
    updateMemoryDefinition,
    autoSaveContextDefinition,
    restoreSessionContextDefinition,
    prioritizeMemoryDefinition,
    startSessionDefinition,
  • src/index.ts:644-645 (registration)
    Dispatch case in the central executeToolCall switch statement that routes calls to the searchMemoriesHandler.
    case 'search_memories':
      return await searchMemoriesHandler(args as any) as CallToolResult;
  • src/index.ts:66-66 (registration)
    Import statement bringing in the tool definition and handler from the implementation file.
    import { searchMemoriesDefinition, searchMemoriesHandler } from './tools/memory/searchMemories.js';
Behavior3/5

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

Annotations provide a title but no behavioral hints (e.g., readOnlyHint, destructiveHint). The description adds minimal behavioral context beyond the basic action—it mentions searching 'by content' but doesn't disclose details like search scope (e.g., full-text vs. keywords), result format, pagination, or error handling. With no annotations to rely on, the description carries the burden but offers only basic transparency.

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 concise and front-loaded with the core action ('search memories by content'), using minimal words. However, the pipe-separated verb list ('find|search|look for|query') is slightly redundant and could be streamlined without losing clarity, preventing a perfect score.

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 (search function with 2 parameters), no annotations, and no output schema, the description is incomplete. It covers the basic purpose but lacks details on behavioral traits (e.g., search behavior, result structure) and output expectations, which are critical for an agent to use it effectively. The description is adequate as a minimum but has clear gaps.

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%, with clear descriptions for both parameters ('query' and 'category'). The description adds no additional meaning beyond what the schema provides—it doesn't explain query syntax, category options, or interaction between parameters. Given high schema coverage, the baseline score of 3 is appropriate as the description doesn't compensate but doesn't detract.

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 with specific verbs ('find|search|look for|query') and resource ('memories'), and specifies the search mechanism ('by content'). It distinguishes from siblings like 'list_memories' by focusing on content-based search rather than listing. However, it doesn't explicitly differentiate from 'recall_memory' or 'find_references', which slightly limits sibling distinction.

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_memories' (for browsing all memories) or 'recall_memory' (for retrieving specific memories by ID). It lacks explicit when/when-not instructions or named alternatives, offering only implied usage through the action description.

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/ssdeanx/ssd-ai'

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