set_long_term_memory
Store user profiles including demographics, contact information, and preferences to enable personalized AI interactions through persistent memory management.
Instructions
Store user demographics, contact details, or preferences
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| contact | No | Contact information | |
| demographics | No | User demographics (age, location, occupation, etc.) | |
| preferences | No | User preferences and settings | |
| userId | Yes | User identifier |
Implementation Reference
- src/handlers/ToolHandlers.ts:66-91 (registration)Registration of the set_long_term_memory tool, including its name, description, and input schema definition.
{ name: "set_long_term_memory", description: "Store user demographics, contact details, or preferences", inputSchema: { type: "object", properties: { userId: { type: "string", description: "User identifier" }, demographics: { type: "object", description: "User demographics (age, location, occupation, etc.)" }, contact: { type: "object", description: "Contact information" }, preferences: { type: "object", description: "User preferences and settings" } }, required: ["userId"] } }, - src/handlers/ToolHandlers.ts:228-241 (handler)The MCP tool handler that processes the set_long_term_memory call: extracts arguments, validates userId, calls MemoryStore.setLongTermMemory, and returns a success response.
case "set_long_term_memory": { const { userId, demographics, contact, preferences } = request.params.arguments as any; // Validate inputs ValidationUtils.validateUserId(userId); memoryStore.setLongTermMemory(userId, { demographics, contact, preferences }); return { content: [{ type: "text", text: `Updated long-term memory for user ${userId}` }] }; } - src/store/MemoryStore.ts:123-137 (helper)Core helper method that merges new long-term memory data with existing, updates the in-memory map, and persists to JSON file.
setLongTermMemory(userId: string, data: Partial<LongTermMemory>): void { const existing = this.longTermMemory.get(userId) || { userId, lastUpdated: Date.now() }; const updated = { ...existing, ...data, lastUpdated: Date.now() }; this.longTermMemory.set(userId, updated); this.persistLongTermMemory(); }