memory_history
View past memory states timeline to identify correct versions before reverting. Shows version numbers, timestamps, and state summaries for project memory management.
Instructions
View the timeline of past memory states for this project. Use this BEFORE memory_checkout to find the correct version to revert to. Shows version numbers, timestamps, and summaries of each saved state.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project | Yes | Project identifier to view history for. | |
| limit | No | Maximum number of history entries to return (default: 10, max: 50). |
Implementation Reference
- The memoryHistoryHandler function implements the logic for the memory_history tool, fetching and formatting the project's memory timeline from storage.
export async function memoryHistoryHandler(args: unknown) { if (!isMemoryHistoryArgs(args)) { throw new Error("Invalid arguments for memory_history"); } const { project, limit = 10 } = args; const storage = await getStorage(); console.error(`[memory_history] Fetching history for project="${project}" (limit=${limit})`); const history = await storage.getHistory(project, PRISM_USER_ID, Math.min(limit, 50)); if (history.length === 0) { return { content: [{ type: "text", text: `No memory history found for project "${project}".\n\n` + `History is automatically created each time you save a handoff.\n` + `Use session_save_handoff first, then check history again.`, }], isError: false, }; } // Format timeline for LLM readability const timeline = history.map(h => { const summary = h.snapshot.last_summary || "(no summary)"; const todos = h.snapshot.pending_todo?.length || 0; const branch = h.branch !== "main" ? ` [branch: ${h.branch}]` : ""; return ` v${h.version} [${h.created_at}]${branch}\n Summary: ${summary}\n TODOs: ${todos} items`; }).join("\n\n"); return { content: [{ type: "text", text: `π°οΈ Memory History for "${project}" (${history.length} snapshots):\n\n${timeline}\n\n` + `To revert to any version, use: memory_checkout with project="${project}" and target_version=<version number>.`, }], isError: false, }; } // βββ Memory Checkout Handler (v2.0 β Time Travel) ββββββββββββ /** * Reverts a project's memory to a historical version β like Git revert. * The version number moves FORWARD (no data is lost), and the revert itself * is recorded in history so you can undo an undo. */ export async function memoryCheckoutHandler(args: unknown) { if (!isMemoryCheckoutArgs(args)) { throw new Error("Invalid arguments for memory_checkout"); - The MEMORY_HISTORY_TOOL object defines the schema, name, and description for the memory_history MCP tool.
export const MEMORY_HISTORY_TOOL: Tool = { name: "memory_history", description: "View the timeline of past memory states for this project. " + "Use this BEFORE memory_checkout to find the correct version to revert to. " + "Shows version numbers, timestamps, and summaries of each saved state.", inputSchema: { type: "object", properties: { project: { type: "string", description: "Project identifier to view history for.", }, limit: { type: "number", description: "Maximum number of history entries to return (default: 10, max: 50).", default: 10, }, }, required: ["project"], }, };