memory_get_related
Retrieve contextually related memory data from a persistent memory system, enabling LLMs to maintain continuous learning and knowledge retention across sessions.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The handler function that implements the core logic of the 'memory_get_related' tool. It calls factStore.getRelatedFacts and formats the response.async handleGetRelated(args) { try { const { factId, maxDepth = 2 } = args; const related = await this.factStore.getRelatedFacts(factId, maxDepth); if (related.length === 0) { return { content: [ { type: 'text', text: `No related facts found for ${factId}`, }, ], }; } let response = `🔗 **Related Facts for ${factId}:**\n\n`; for (const item of related) { response += `**${item.relationship}** (depth ${item.depth})\n`; response += `${item.fact.type}: ${item.fact.content.substring(0, 100)}...\n\n`; } return { content: [ { type: 'text', text: response.trim(), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error getting related facts: ${error.message}`, }, ], isError: true, }; } }
- src/tools/modules/MemoryOperations.js:123-146 (registration)Registers the 'memory_get_related' tool on the server, specifying name, description, input schema, and binding to the handleGetRelated handler.registerGetRelatedTool(server) { server.registerTool( 'memory_get_related', 'Get facts related to a specific fact', { type: 'object', properties: { factId: { type: 'string', description: 'The ID of the fact to find related facts for', }, maxDepth: { type: 'number', description: 'Maximum relationship depth to traverse', default: 2, }, }, required: ['factId'], }, async (args) => { return await this.handleGetRelated(args); } ); }
- JSON schema defining the input parameters for the 'memory_get_related' tool: factId (required string), maxDepth (optional number, default 2).{ type: 'object', properties: { factId: { type: 'string', description: 'The ID of the fact to find related facts for', }, maxDepth: { type: 'number', description: 'Maximum relationship depth to traverse', default: 2, }, }, required: ['factId'], },