get_short_term_memory
Retrieve session-specific data from temporary memory storage to maintain context and continuity in AI interactions.
Instructions
Retrieve data from short-term memory
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | No | Memory key (optional, returns all if not provided) | |
| sessionId | Yes | Session identifier |
Implementation Reference
- src/handlers/ToolHandlers.ts:210-226 (handler)MCP tool handler execution logic: validates sessionId and optional key, retrieves short-term memory from store, returns as formatted JSON text response.case "get_short_term_memory": { const { sessionId, key } = request.params.arguments as any; // Validate inputs ValidationUtils.validateSessionId(sessionId); if (key !== undefined) { ValidationUtils.validateMemoryKey(key); } const memory = memoryStore.getShortTermMemory(sessionId, key); return { content: [{ type: "text", text: JSON.stringify(memory, null, 2) }] }; }
- src/handlers/ToolHandlers.ts:51-63 (schema)Input schema definition for the get_short_term_memory tool, specifying sessionId as required and key as optional.inputSchema: { type: "object", properties: { sessionId: { type: "string", description: "Session identifier" }, key: { type: "string", description: "Memory key (optional, returns all if not provided)" } }, required: ["sessionId"]
- src/handlers/ToolHandlers.ts:48-65 (registration)Tool registration in the list of available tools, including name, description, and input schema.{ name: "get_short_term_memory", description: "Retrieve data from short-term memory", inputSchema: { type: "object", properties: { sessionId: { type: "string", description: "Session identifier" }, key: { type: "string", description: "Memory key (optional, returns all if not provided)" } }, required: ["sessionId"] } },
- src/store/MemoryStore.ts:104-111 (helper)Core implementation of short-term memory retrieval: fetches from in-memory map, checks expiration and cleans up if expired, returns specific key or entire session data.getShortTermMemory(sessionId: string, key?: string): any { const memory = this.shortTermMemory.get(sessionId); if (!memory || memory.expiresAt <= Date.now()) { this.shortTermMemory.delete(sessionId); return null; } return key ? memory.data[key] : memory.data; }