Skip to main content
Glama

get_memory_history

Retrieve change history for a specific memory in the AGI MCP Server's persistent storage system to track modifications and maintain continuity.

Instructions

Get change history for a specific memory

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
memory_idYesUUID of the memory

Implementation Reference

  • The actual implementation of getMemoryHistory method that queries the memoryChanges table for all changes associated with a given memory ID, ordered by changedAt in descending order (most recent first).
    async getMemoryHistory(memoryId) {
      try {
        const history = await this.db
          .select()
          .from(schema.memoryChanges)
          .where(eq(schema.memoryChanges.memoryId, memoryId))
          .orderBy(desc(schema.memoryChanges.changedAt));
    
        return history;
      } catch (error) {
        console.warn('Memory history query failed:', error.message);
        return [];
      }
    }
  • Tool schema definition for get_memory_history, specifying the input validation with memory_id as required parameter.
      name: "get_memory_history",
      description: "Get change history for a specific memory",
      inputSchema: {
        type: "object",
        properties: {
          memory_id: {
            type: "string",
            description: "UUID of the memory"
          }
        },
        required: ["memory_id"]
      }
    },
  • mcp.js:674-676 (registration)
    Handler registration in the switch statement that calls memoryManager.getMemoryHistory and returns the results as JSON.
    case "get_memory_history":
      const memoryHistory = await memoryManager.getMemoryHistory(args.memory_id);
      return { content: [{ type: "text", text: JSON.stringify(memoryHistory, null, 2) }] };
  • mcp.js:459-470 (registration)
    Tool registration in the MCP server's ListTools handler, exposing get_memory_history to clients.
    name: "get_memory_history",
    description: "Get change history for a specific memory",
    inputSchema: {
      type: "object",
      properties: {
        memory_id: {
          type: "string",
          description: "UUID of the memory"
        }
      },
      required: ["memory_id"]
    }
  • Database schema for the memoryChanges table that stores change history records with changeId, memoryId, changedAt, changeType, oldValue, and newValue fields.
    export const memoryChanges = pgTable("memory_changes", {
    	changeId: uuid("change_id").defaultRandom().primaryKey().notNull(),
    	memoryId: uuid("memory_id"),
    	changedAt: timestamp("changed_at", { withTimezone: true, mode: 'string' }).default(sql`CURRENT_TIMESTAMP`),
    	changeType: text("change_type").notNull(),
    	oldValue: jsonb("old_value"),
    	newValue: jsonb("new_value"),
    }, (table) => [
    	foreignKey({
    			columns: [table.memoryId],
    			foreignColumns: [memories.id],
    			name: "memory_changes_memory_id_fkey"
    		}),
    ]);

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/randyandrade/agi-mcp-server'

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