get_memory
Retrieve detailed memory content, metadata, history, and categorization from stored knowledge to review context, make informed decisions, or reference past insights effectively.
Instructions
Access comprehensive memory details including full content, metadata, creation history, and categorization. Essential for reviewing stored knowledge, understanding context, and retrieving complete information when making decisions or referencing past insights.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The unique identifier of the memory to retrieve | |
| workingDirectory | Yes | The full absolute path to the working directory where data is stored. MUST be an absolute path, never relative. Windows: "C:\Users\username\project" or "D:\projects\my-app". Unix/Linux/macOS: "/home/username/project" or "/Users/username/project". Do NOT use: ".", "..", "~", "./folder", "../folder" or any relative paths. Ensure the path exists and is accessible before calling this tool. NOTE: When server is started with --claude flag, this parameter is ignored and a global user directory is used instead. |
Implementation Reference
- src/features/agent-memories/tools/memories/get.ts:10-71 (registration)Factory function that creates the 'get_memory' MCP tool, including name, description, input schema, and handler logic. This is the primary definition and registration point for the tool.export function createGetMemoryTool(storage: MemoryStorage) { return { name: 'get_memory', description: 'Get a specific memory by its ID', inputSchema: { id: z.string() }, handler: async ({ id }: { id: string }) => { try { // Validate inputs if (!id || id.trim().length === 0) { return { content: [{ type: 'text' as const, text: 'Error: Memory ID is required.' }], isError: true }; } const memory = await storage.getMemory(id.trim()); if (!memory) { return { content: [{ type: 'text' as const, text: `❌ Memory not found. **Memory ID:** ${id} The memory with this ID does not exist or may have been deleted.` }], isError: true }; } return { content: [{ type: 'text' as const, text: `📋 Memory Details: **Memory ID:** ${memory.id} **Title:** ${memory.title} **Content:** ${memory.content} **Category:** ${memory.category || 'Not specified'} **Created:** ${new Date(memory.createdAt).toLocaleString()} **Updated:** ${new Date(memory.updatedAt).toLocaleString()} **Metadata:** ${Object.keys(memory.metadata).length > 0 ? JSON.stringify(memory.metadata, null, 2) : 'None'}` }] }; } catch (error) { return { content: [{ type: 'text' as const, text: `Error retrieving memory: ${error instanceof Error ? error.message : 'Unknown error'}` }], isError: true }; } } }; }
- The core handler function that implements the get_memory tool logic: input validation, memory retrieval from storage, error handling, and formatted text response.handler: async ({ id }: { id: string }) => { try { // Validate inputs if (!id || id.trim().length === 0) { return { content: [{ type: 'text' as const, text: 'Error: Memory ID is required.' }], isError: true }; } const memory = await storage.getMemory(id.trim()); if (!memory) { return { content: [{ type: 'text' as const, text: `❌ Memory not found. **Memory ID:** ${id} The memory with this ID does not exist or may have been deleted.` }], isError: true }; } return { content: [{ type: 'text' as const, text: `📋 Memory Details: **Memory ID:** ${memory.id} **Title:** ${memory.title} **Content:** ${memory.content} **Category:** ${memory.category || 'Not specified'} **Created:** ${new Date(memory.createdAt).toLocaleString()} **Updated:** ${new Date(memory.updatedAt).toLocaleString()} **Metadata:** ${Object.keys(memory.metadata).length > 0 ? JSON.stringify(memory.metadata, null, 2) : 'None'}` }] }; } catch (error) { return { content: [{ type: 'text' as const, text: `Error retrieving memory: ${error instanceof Error ? error.message : 'Unknown error'}` }], isError: true }; } }
- Zod-based input schema defining the required 'id' string parameter for the tool.inputSchema: { id: z.string() },