Skip to main content
Glama

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
NameRequiredDescriptionDefault
sessionIdYesSession identifier
idNoSpecific memory ID to delete (optional)
beforeNoISO date — delete entries before this date (optional)

Implementation Reference

  • 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;
    }
  • 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'],
      },
    },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Cartisien/engram-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server