forget
Delete session memories from the engram-mcp server by removing all entries, specific IDs, or entries before a date.
Instructions
Delete session memories. Delete all, one by ID, or entries before a date.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | Yes | Session identifier | |
| id | No | Specific memory ID to delete (optional) | |
| before | No | ISO date — delete entries before this date (optional) |
Implementation Reference
- engram.ts:301-328 (handler)The core implementation of the 'forget' method in the Engram class. This async function deletes memories from the SQLite database by sessionId, with optional filters for a specific memory ID or a 'before' date timestamp. Returns the number of deleted records.
/** * Forget (delete) memories */ async forget( sessionId: string, options?: { before?: Date; id?: string } ): Promise<number> { await this.init(); if (options?.id) { const result = await this.db.run( 'DELETE FROM memories WHERE session_id = ? AND id = ?', [sessionId, options.id] ); return result.changes || 0; } let sql = 'DELETE FROM memories WHERE session_id = ?'; const params: (string | number)[] = [sessionId]; if (options?.before) { sql += ' AND timestamp < ?'; params.push(options.before.getTime()); } const result = await this.db.run(sql, params); return result.changes || 0; } - src/index.ts:240-246 (handler)MCP tool handler for 'forget' - extracts options (id, before) from args, calls memory.forget() with the sessionId and options, and returns a human-readable response with the count of deleted memories.
case 'forget': { const opts: Parameters<typeof memory.forget>[1] = {}; if (args.id) opts.id = args.id as string; if (args.before) opts.before = new Date(args.before as string); const deleted = await memory.forget(args.sessionId as string, opts); return { content: [{ type: 'text', text: `Deleted ${deleted} memor${deleted === 1 ? 'y' : 'ies'}.` }] }; } - src/index.ts:79-91 (registration)Tool registration for 'forget' - defines the tool name, description ('Delete session memories. Delete all, one by ID, or entries before a date.'), and inputSchema with sessionId (required), id, and before properties.
{ name: 'forget', description: 'Delete session memories. Delete all, one by ID, or entries before a date.', inputSchema: { type: 'object', properties: { sessionId: { type: 'string', description: 'Session identifier' }, id: { type: 'string', description: 'Specific memory ID to delete (optional)' }, before: { type: 'string', description: 'ISO date — delete entries before this date (optional)' }, }, required: ['sessionId'], }, },