forget_memory
Permanently delete a specific memory by its key to remove outdated or incorrect information from long-term storage.
Instructions
Permanently delete a specific memory by key.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | The memory key to delete |
Implementation Reference
- src/index.ts:292-298 (handler)The handler for the 'forget_memory' tool. It extracts the 'key' argument, validates it, calls store.remove(key), and returns an OK message indicating whether the memory was deleted or not found.
// ── forget_memory ────────────────────────────────────────────────────── case 'forget_memory': { const key = String(a['key'] ?? '').trim(); if (!key) return err('key is required'); const deleted = store.remove(key); return ok(deleted ? `Memory deleted: "${key}"` : `Memory not found: "${key}"`); } - src/index.ts:128-138 (schema)The tool registration and input schema definition for 'forget_memory'. It defines the tool name, description, and inputSchema requiring a 'key' string parameter.
{ name: 'forget_memory', description: 'Permanently delete a specific memory by key.', inputSchema: { type: 'object', properties: { key: { type: 'string', description: 'The memory key to delete' }, }, required: ['key'], }, }, - src/index.ts:23-150 (registration)The forget_memory tool is registered via the ListToolsRequestSchema handler (line 23-150), which lists all available tools. It is also registered in the CallToolRequestSchema switch statement (lines 292-298) where the actual dispatch happens.
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ { name: 'store_memory', description: 'Store a new memory — fact, preference, project detail, note, or any information worth remembering. ' + 'Tags and importance are auto-detected from content if not provided.', inputSchema: { type: 'object', properties: { key: { type: 'string', description: 'Unique snake_case identifier (e.g. "user_name", "preferred_language", "project_deadline")', }, content: { type: 'string', description: 'The memory content — be descriptive and specific for better retrieval', }, tags: { type: 'array', items: { type: 'string' }, description: 'Categorization tags (auto-detected if omitted)', }, importance: { type: 'number', description: 'Importance score 1-10 — higher = retrieved first (auto-scored if omitted)', }, }, required: ['key', 'content'], }, }, { name: 'search_memory', description: 'Search memories using BM25 full-text search with importance and recency weighting. ' + 'Supports optional tag filtering to narrow scope.', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query — natural language or keywords' }, limit: { type: 'number', description: 'Max results to return (default: 5)' }, tags: { type: 'array', items: { type: 'string' }, description: 'Only search memories with these tags', }, }, required: ['query'], }, }, { name: 'get_relevant_context', description: 'Auto-retrieve the most relevant memories for a given user query or task. ' + 'Use this at the start of any session or when the user references past context. ' + 'Returns formatted context ready to inject into your reasoning.', inputSchema: { type: 'object', properties: { user_query: { type: 'string', description: 'The current user query, task description, or topic to find context for', }, }, required: ['user_query'], }, }, { name: 'update_memory', description: 'Update the content, tags, or importance of an existing memory by key.', inputSchema: { type: 'object', properties: { key: { type: 'string', description: 'The memory key to update' }, new_content: { type: 'string', description: 'Replacement content (omit to keep existing)' }, tags: { type: 'array', items: { type: 'string' }, description: 'New tag list — replaces existing tags', }, importance: { type: 'number', description: 'New importance score 1-10' }, }, required: ['key'], }, }, { name: 'list_memories', description: 'Browse stored memories with optional tag filtering and sort order.', inputSchema: { type: 'object', properties: { tags: { type: 'array', items: { type: 'string' }, description: 'Filter to only memories with these tags', }, limit: { type: 'number', description: 'Max results (default: 20)' }, sort: { type: 'string', enum: ['recent', 'importance', 'access'], description: 'Sort by: recent (default), importance, or access count', }, }, }, }, { name: 'forget_memory', description: 'Permanently delete a specific memory by key.', inputSchema: { type: 'object', properties: { key: { type: 'string', description: 'The memory key to delete' }, }, required: ['key'], }, }, { name: 'memory_summary', description: 'Get a high-level overview of what the agent knows — total count, top tags, ' + 'most important memories, and access statistics. Good for orientation at session start.', inputSchema: { type: 'object', properties: {}, }, }, ], })); - src/store.ts:70-78 (helper)The store.remove() method called by the forget_memory handler. It filters out the memory by key, persists to disk if removed, and returns true if a memory was deleted or false if not found.
remove(key: string): boolean { const before = this.data.memories.length; this.data.memories = this.data.memories.filter(m => m.key !== key); if (this.data.memories.length !== before) { this.persist(); return true; } return false; }