update_memory
Update a saved memory by providing its ID and any fields to change, ensuring relevant context persists across sessions.
Instructions
Update an existing memory. Provide the ID and any fields to change.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The memory ID to update | |
| content | No | New content | |
| category | No | New category | |
| importance | No | New importance score |
Implementation Reference
- src/tools/update.ts:5-58 (handler)Defines and registers the update_memory tool handler. Accepts id (required), content, category, and importance (optional). Calls storage.update(), returns success/failure with the updated memory.
export function registerUpdateMemory( server: McpServer, storage: RekindleStorage ): void { server.tool( "update_memory", "Update an existing memory. Provide the ID and any fields to change.", { id: z.string().describe("The memory ID to update"), content: z.string().optional().describe("New content"), category: z .enum(["preference", "lesson", "context", "relationship", "general"]) .optional() .describe("New category"), importance: z .number() .min(1) .max(10) .optional() .describe("New importance score"), }, async ({ id, content, category, importance }) => { const updated = storage.update(id, { content, category: category as MemoryCategory | undefined, importance, }); if (!updated) { return { content: [ { type: "text" as const, text: JSON.stringify({ success: false, message: "Memory not found", }), }, ], }; } const memory = storage.get(id); return { content: [ { type: "text" as const, text: JSON.stringify({ success: true, memory }), }, ], }; } ); } - src/tools/update.ts:12-25 (schema)Zod schema for update_memory input validation: id (required string), content (optional string), category (optional enum of 5 categories), importance (optional number 1-10).
{ id: z.string().describe("The memory ID to update"), content: z.string().optional().describe("New content"), category: z .enum(["preference", "lesson", "context", "relationship", "general"]) .optional() .describe("New category"), importance: z .number() .min(1) .max(10) .optional() .describe("New importance score"), }, - src/server.ts:8-22 (registration)Imports and calls registerUpdateMemory(server, storage) in the server setup to register the tool with the MCP server.
import { registerUpdateMemory } from "./tools/update.js"; import { registerBootReport } from "./tools/boot-report.js"; import { registerEndSession } from "./tools/end-session.js"; export function createServer(storage: RekindleStorage): McpServer { const server = new McpServer({ name: "rekindle", version: "0.2.0", }); registerStoreMemory(server, storage); registerSearchMemory(server, storage); registerListMemories(server, storage); registerDeleteMemory(server, storage); registerUpdateMemory(server, storage); - src/storage/sqlite.ts:260-280 (helper)Storage-layer update method: fetches existing memory, merges provided fields with defaults, clamps importance to 1-10, sets updated_at timestamp, and runs the SQL UPDATE query.
update( id: string, fields: { content?: string; category?: MemoryCategory; importance?: number } ): boolean { const existing = this.get(id); if (!existing) return false; const content = fields.content ?? existing.content; const category = fields.category ?? existing.category; const importance = fields.importance ? Math.max(1, Math.min(10, fields.importance)) : existing.importance; const now = new Date().toISOString().replace("T", " ").slice(0, 19); this.db .prepare( `UPDATE memories SET content = ?, category = ?, importance = ?, updated_at = ? WHERE id = ?` ) .run(content, category, importance, now, id); return true; }