Skip to main content
Glama

search_memory

Search through agent memory to retrieve relevant information using semantic similarity matching. Specify queries to find stored data with configurable relevance thresholds and result limits.

Instructions

Search for relevant information in agent memory

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
agentIdNoFilter by specific agent ID (optional)
limitNoMaximum number of results to return (default: 10)
queryYesSearch query to find relevant memory entries
thresholdNoMinimum similarity threshold (0-1, default: 0.7)

Implementation Reference

  • The main handler function for the 'search_memory' MCP tool. It receives arguments, calls ragService.searchMemory with defaults, and returns the results as JSON text content.
    private async handleSearchMemory(args: {
      query: string;
      agentId?: string;
      limit?: number;
      threshold?: number;
    }) {
            const results = await this.ragService.searchMemory(args.query, args.agentId, {
          limit: args.limit || 10,
          threshold: args.threshold || 0.7,
        });
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(results, null, 2),
          },
        ],
      };
    }
  • src/index.ts:132-159 (registration)
    Tool registration in ListToolsRequestHandler, including name, description, and input schema for 'search_memory'.
    {
      name: 'search_memory',
      description: 'Search for relevant information in agent memory',
      inputSchema: {
        type: 'object',
        properties: {
          query: {
            type: 'string',
            description: 'Search query to find relevant memory entries',
          },
          agentId: {
            type: 'string',
            description: 'Filter by specific agent ID (optional)',
          },
          limit: {
            type: 'number',
            description: 'Maximum number of results to return (default: 10)',
            default: 10,
          },
          threshold: {
            type: 'number',
            description: 'Minimum similarity threshold (0-1, default: 0.7)',
            default: 0.7,
          },
        },
        required: ['query'],
      },
    },
  • RAGService helper method that handles agentId filtering and delegates to vectorDatabase.searchMemory.
    async searchMemory(
      query: string,
      agentId?: string,
      options: SearchOptions = {}
    ): Promise<SearchResult[]> {
      try {
        logger.info(`Searching memory with query: "${query}"`);
        
        const searchOptions = { ...options };
        if (agentId) {
          searchOptions.filter = { ...searchOptions.filter, agentId };
        }
        
        return await this.vectorDatabase.searchMemory(query, searchOptions);
      } catch (error) {
        logger.error(`Error searching memory: ${error}`);
        throw new Error(`Memory search failed: ${error}`);
      }
    }
Behavior2/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 of behavioral disclosure. It states the tool searches memory but doesn't describe what 'agent memory' entails (e.g., stored conversations, data), how results are returned (e.g., format, ordering), or any limitations (e.g., performance, access controls). For a search tool with no annotation coverage, this leaves significant gaps in understanding its behavior.

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 a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is front-loaded with the core action ('Search for relevant information'), making it easy to parse. Every part of the sentence earns its place by conveying essential information.

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?

Given the complexity of a search operation with 4 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain the nature of 'agent memory', how search results are structured, or any behavioral traits like pagination or error handling. For a tool that likely returns multiple results, more context is needed to guide effective 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?

The schema description coverage is 100%, so all parameters are documented in the schema. The description adds no additional meaning beyond what the schema provides (e.g., it doesn't explain how 'query' is processed or what 'threshold' implies semantically). With high schema coverage, the baseline score of 3 is appropriate, as the description doesn't compensate but also 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 as 'Search for relevant information in agent memory', which specifies the verb (search) and resource (agent memory). It distinguishes from siblings like 'search_files' (which searches files) and 'get_memory_by_agent' (which retrieves memory by agent without searching). However, it doesn't explicitly mention the similarity-based nature of the search, which is implied by the 'threshold' parameter but could be more specific.

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. It doesn't mention when to choose 'search_memory' over 'get_memory_by_agent' (which retrieves memory by agent ID) or 'search_files' (which searches files), nor does it specify prerequisites or exclusions. The agent must infer usage from the tool name and parameters alone.

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/santis84/mcp-rag'

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