list_memories
Retrieve saved memories from previous sessions to avoid re-explaining context. Filter by category or project.
Instructions
List stored memories, optionally filtered by category or project. Returns newest first.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | No | Filter by category | |
| project | No | Filter by project | |
| limit | No | Maximum results to return |
Implementation Reference
- src/tools/list.ts:5-47 (handler)The registerListMemories function registers the 'list_memories' tool with an McpServer. It defines a Zod schema for optional 'category' (enum of 5 values), optional 'project' string, and 'limit' (default 50, max 200). The handler calls storage.list() with these filters and returns the results as JSON with count and mapped memory fields.
export function registerListMemories( server: McpServer, storage: RekindleStorage ): void { server.tool( "list_memories", "List stored memories, optionally filtered by category or project. Returns newest first.", { category: z .enum(["preference", "lesson", "context", "relationship", "general"]) .optional() .describe("Filter by category"), project: z.string().optional().describe("Filter by project"), limit: z .number() .min(1) .max(200) .default(50) .describe("Maximum results to return"), }, async ({ category, project, limit }) => { const memories = storage.list({ category, project, limit }); return { content: [ { type: "text" as const, text: JSON.stringify({ count: memories.length, memories: memories.map((m) => ({ id: m.id, content: m.content, category: m.category, importance: m.importance, project: m.project, created_at: m.created_at, })), }), }, ], }; } ); } - src/tools/list.ts:10-24 (schema)Zod schema for 'list_memories' tool input: category (optional enum of preference/lesson/context/relationship/general), project (optional string), limit (number, 1-200, default 50).
"list_memories", "List stored memories, optionally filtered by category or project. Returns newest first.", { category: z .enum(["preference", "lesson", "context", "relationship", "general"]) .optional() .describe("Filter by category"), project: z.string().optional().describe("Filter by project"), limit: z .number() .min(1) .max(200) .default(50) .describe("Maximum results to return"), }, - src/server.ts:6-6 (registration)Import of registerListMemories from './tools/list.js'.
import { registerListMemories } from "./tools/list.js"; - src/server.ts:20-20 (registration)Registration call: registerListMemories(server, storage) registers the 'list_memories' tool on the McpServer instance.
registerListMemories(server, storage); - src/storage/sqlite.ts:230-251 (helper)The storage.list() method implementation. Builds a SQL SELECT from memories WITH optional category and project filters, orders by created_at DESC, rowid DESC, and limits results. Returns Memory[] array.
list( opts: { category?: string; project?: string; limit?: number } = {} ): Memory[] { const limit = opts.limit ?? 50; let sql = `SELECT * FROM memories WHERE 1=1`; const params: (string | number)[] = []; if (opts.category) { sql += ` AND category = ?`; params.push(opts.category); } if (opts.project) { sql += ` AND project = ?`; params.push(opts.project); } sql += ` ORDER BY created_at DESC, rowid DESC LIMIT ?`; params.push(limit); return this.db.prepare(sql).all(...params) as Memory[]; }