store_memory
Save important information like preferences, lessons, or project context to persist across AI sessions.
Instructions
Store a memory. Use for preferences, lessons learned, project context, relationship notes, or general information worth remembering across sessions.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | The memory content to store | |
| category | No | Memory category | general |
| importance | No | Importance score 1-10 (higher = retrieved more often) | |
| project | No | Project scope for this memory |
Implementation Reference
- src/tools/store.ts:29-44 (handler)The handler function for the 'store_memory' tool. It destructures the validated inputs (content, category, importance, project), calls storage.store() to persist the memory, and returns the generated ID with a success message.
async ({ content, category, importance, project }) => { const id = storage.store( content, category as MemoryCategory, importance, project ); return { content: [ { type: "text" as const, text: JSON.stringify({ id, message: "Memory stored" }), }, ], }; } - src/tools/store.ts:12-28 (schema)Input schema for 'store_memory' tool. Defines Zod validations: content (string), category (enum with default 'general'), importance (1-10 number with default 5), and optional project (string).
{ content: z.string().describe("The memory content to store"), category: z .enum(["preference", "lesson", "context", "relationship", "general"]) .default("general") .describe("Memory category"), importance: z .number() .min(1) .max(10) .default(5) .describe("Importance score 1-10 (higher = retrieved more often)"), project: z .string() .optional() .describe("Project scope for this memory"), }, - src/tools/store.ts:5-46 (registration)The registerStoreMemory function registers the 'store_memory' tool on the MCP server via server.tool() with its name, description, schema, and handler.
export function registerStoreMemory( server: McpServer, storage: RekindleStorage ): void { server.tool( "store_memory", "Store a memory. Use for preferences, lessons learned, project context, relationship notes, or general information worth remembering across sessions.", { content: z.string().describe("The memory content to store"), category: z .enum(["preference", "lesson", "context", "relationship", "general"]) .default("general") .describe("Memory category"), importance: z .number() .min(1) .max(10) .default(5) .describe("Importance score 1-10 (higher = retrieved more often)"), project: z .string() .optional() .describe("Project scope for this memory"), }, async ({ content, category, importance, project }) => { const id = storage.store( content, category as MemoryCategory, importance, project ); return { content: [ { type: "text" as const, text: JSON.stringify({ id, message: "Memory stored" }), }, ], }; } ); } - src/server.ts:4-4 (registration)Import of registerStoreMemory from the tools/store module into the main server file.
import { registerStoreMemory } from "./tools/store.js"; - src/server.ts:18-18 (registration)Registration call: registerStoreMemory(server, storage) wires the tool into the MCP server on startup.
registerStoreMemory(server, storage); - src/storage/sqlite.ts:144-167 (helper)The RekindleStorage.store() method that persists a memory record to the SQLite database. Generates a unique ID, inserts into the 'memories' table (with FTS trigger), clamps importance to 1-10, and returns the new ID.
store( content: string, category: MemoryCategory = "general", importance: number = 5, project?: string, opts?: { type?: string; source?: string; session_id?: string } ): string { const id = generateId(); const stmt = this.db.prepare(` INSERT INTO memories (id, content, category, importance, project, type, source, session_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?) `); stmt.run( id, content, category, Math.max(1, Math.min(10, importance)), project ?? null, opts?.type ?? "memory", opts?.source ?? "manual", opts?.session_id ?? null ); return id; }