Skip to main content
Glama
QuixiAI

AGI MCP Server

by QuixiAI

search_memories_text

Find stored memories by searching text content with full-text queries to retrieve relevant information from persistent 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

  • The core handler function searchMemoriesByText that executes full-text search on active memories using PostgreSQL tsquery and ts_rank, returning relevant memories ordered by rank and relevance.
    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;
      }
    }
  • Input schema definition for the search_memories_text tool, specifying query string and optional limit.
    {
      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"]
      }
    },
  • mcp.js:554-559 (registration)
    Registration and dispatching in the MCP tool call handler: switch case that invokes the memoryManager's searchMemoriesByText method and formats the response.
    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 (schema)
    Tool schema exposed in the MCP ListTools handler for client discovery.
    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"]
    }

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

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