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
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Text query to search for | |
| limit | No | Maximum number of results |
Implementation Reference
- src/memory-manager.js:346-377 (handler)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"] } - src/tools/memory-tools.js:61-78 (schema)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"] }