Skip to main content
Glama

search_memories_text

Search stored memories by text content using full-text search to retrieve relevant information from persistent AI memory systems.

Instructions

Search memories by text content using full-text search

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesText query to search for
limitNoMaximum number of results

Implementation Reference

  • Actual implementation of searchMemoriesByText method that performs full-text search on memories using PostgreSQL's tsvector and plainto_tsquery for English text search, filtering by active status and ordering by text rank and relevance score
    async searchMemoriesByText(query, limit = 10) {
      try {
        const results = await this.db
          .select({
            id: schema.memories.id,
            type: schema.memories.type,
            content: schema.memories.content,
            importance: schema.memories.importance,
            accessCount: schema.memories.accessCount,
            createdAt: schema.memories.createdAt,
            relevanceScore: schema.memories.relevanceScore,
            textRank: sql`ts_rank(to_tsvector('english', ${schema.memories.content}), plainto_tsquery('english', ${query}))`.as('text_rank')
          })
          .from(schema.memories)
          .where(
            and(
              eq(schema.memories.status, 'active'),
              sql`to_tsvector('english', ${schema.memories.content}) @@ plainto_tsquery('english', ${query})`
            )
          )
          .orderBy(
            sql`ts_rank(to_tsvector('english', ${schema.memories.content}), plainto_tsquery('english', ${query})) DESC`,
            desc(schema.memories.relevanceScore)
          )
          .limit(limit);
    
        return results;
      } catch (error) {
        console.error('Error searching memories by text:', error);
        throw error;
      }
    }
  • mcp.js:554-559 (handler)
    MCP tool handler for search_memories_text that extracts query and limit arguments from the request and calls memoryManager.searchMemoriesByText()
    case "search_memories_text":
      const textResults = await memoryManager.searchMemoriesByText(
        args.query,
        args.limit || 10
      );
      return { content: [{ type: "text", text: JSON.stringify(textResults, null, 2) }] };
  • mcp.js:88-104 (registration)
    Tool registration in the MCP server's ListToolsRequestSchema handler, defining the search_memories_text tool with its name, description, and input schema
    name: "search_memories_text",
    description: "Search memories by text content using full-text search",
    inputSchema: {
      type: "object",
      properties: {
        query: {
          type: "string",
          description: "Text query to search for"
        },
        limit: {
          type: "integer",
          description: "Maximum number of results",
          default: 10
        }
      },
      required: ["query"]
    }
  • Schema definition for search_memories_text tool, specifying the input parameters (query string required, limit integer optional with default 10)
    {
      name: "search_memories_text",
      description: "Search memories by text content using full-text search",
      inputSchema: {
        type: "object",
        properties: {
          query: {
            type: "string",
            description: "Text query to search for"
          },
          limit: {
            type: "integer",
            description: "Maximum number of results",
            default: 10
          }
        },
        required: ["query"]
      }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions 'full-text search' which implies some behavioral context about search methodology, but doesn't disclose important traits like whether this is a read-only operation, what permissions might be needed, how results are ranked/returned, or any rate limits. The description adds minimal behavioral insight beyond the basic action.

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 states the core purpose without unnecessary words. It's appropriately sized for a search tool and front-loads the essential information. Every word earns its place.

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 no annotations and no output schema, the description is insufficient. It doesn't explain what constitutes a 'memory', what fields are searched, how results are structured, or what 'full-text search' entails operationally. Given the complexity of search operations and lack of structured metadata, more context is needed for the agent to use this effectively.

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 fully documents both parameters ('query' and 'limit'). The description adds no additional parameter semantics beyond what's in the schema - it doesn't explain query syntax, search scope, or result format. Baseline 3 is appropriate when schema does all the parameter documentation work.

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 action ('Search') and resource ('memories by text content'), specifying it uses 'full-text search'. It distinguishes from some siblings like 'get_memory' (retrieval) and 'create_memory' (creation), but doesn't explicitly differentiate from 'search_memories_advanced' or 'search_memories_similarity' which are closely related search variants.

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 this over 'search_memories_advanced' or 'search_memories_similarity', nor does it specify prerequisites or appropriate contexts for text-based searching versus other memory access methods.

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/randyandrade/agi-mcp-server'

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