add_episodic_memory
Store user experiences and events with context, sentiment, and outcomes to build searchable memory for personalized AI interactions.
Instructions
Add a new episodic memory (past experience or event)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| context | Yes | Context surrounding the event | |
| event | Yes | Description of the event | |
| outcome | No | Outcome or resolution of the event | |
| sentiment | No | Sentiment of the experience | |
| sessionId | No | Optional session identifier | |
| tags | No | Tags for categorizing the memory | |
| userId | Yes | User identifier |
Implementation Reference
- src/handlers/ToolHandlers.ts:258-284 (handler)MCP tool handler case for 'add_episodic_memory': validates input parameters and delegates to MemoryStore.addEpisodicMemory, returning the generated memory ID.case "add_episodic_memory": { const memoryData = request.params.arguments as any; // Validate inputs ValidationUtils.validateUserId(memoryData.userId); ValidationUtils.validateEpisodicEvent(memoryData.event); ValidationUtils.validateEpisodicContext(memoryData.context); if (memoryData.sessionId !== undefined) { ValidationUtils.validateSessionId(memoryData.sessionId); } if (memoryData.outcome !== undefined) { ValidationUtils.validateEpisodicOutcome(memoryData.outcome); } ValidationUtils.validateSentiment(memoryData.sentiment); ValidationUtils.validateTags(memoryData.tags); const id = memoryStore.addEpisodicMemory(memoryData); return { content: [{ type: "text", text: `Added episodic memory with ID: ${id}` }] }; }
- src/handlers/ToolHandlers.ts:106-145 (schema)Input schema definition for the 'add_episodic_memory' tool, specifying parameters, types, descriptions, and required fields.{ name: "add_episodic_memory", description: "Add a new episodic memory (past experience or event)", inputSchema: { type: "object", properties: { userId: { type: "string", description: "User identifier" }, sessionId: { type: "string", description: "Optional session identifier" }, event: { type: "string", description: "Description of the event" }, context: { type: "string", description: "Context surrounding the event" }, outcome: { type: "string", description: "Outcome or resolution of the event" }, sentiment: { type: "string", enum: ["positive", "negative", "neutral"], description: "Sentiment of the experience" }, tags: { type: "array", items: { type: "string" }, description: "Tags for categorizing the memory" } }, required: ["userId", "event", "context"] } },
- src/store/MemoryStore.ts:148-159 (helper)Core implementation of adding episodic memory: generates unique ID, adds timestamp, stores in map, persists to JSON file, and returns ID.addEpisodicMemory(memory: Omit<EpisodicMemory, 'id' | 'timestamp'>): string { const id = `episodic_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`; const episodicMemory: EpisodicMemory = { ...memory, id, timestamp: Date.now() }; this.episodicMemory.set(id, episodicMemory); this.persistEpisodicMemory(); return id; }