get_relation
Retrieve detailed properties of a specific relation within the Memento MCP knowledge graph by specifying its start entity, end entity, and relation type.
Instructions
Get a specific relation with its enhanced properties from your Memento MCP knowledge graph memory
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| from | Yes | The name of the entity where the relation starts | |
| relationType | Yes | The type of the relation | |
| to | Yes | The name of the entity where the relation ends |
Implementation Reference
- The main handler for the 'get_relation' tool. Extracts parameters from args, calls KnowledgeGraphManager.getRelation, and returns the relation as JSON or a 'not found' message.case 'get_relation': const relation = await knowledgeGraphManager.getRelation( args.from, args.to, args.relationType ); if (!relation) { return { content: [ { type: 'text', text: `Relation not found: ${args.from} -> ${args.relationType} -> ${args.to}`, }, ], }; } return { content: [{ type: 'text', text: JSON.stringify(relation, null, 2) }] };
- Input schema definition and description for the 'get_relation' tool, included in the list of available tools.name: 'get_relation', description: 'Get a specific relation with its enhanced properties from your Memento MCP knowledge graph memory', inputSchema: { type: 'object', properties: { from: { type: 'string', description: 'The name of the entity where the relation starts', }, to: { type: 'string', description: 'The name of the entity where the relation ends', }, relationType: { type: 'string', description: 'The type of the relation', }, }, required: ['from', 'to', 'relationType'], }, },
- src/server/handlers/listToolsHandler.ts:530-532 (registration)The handleListToolsRequest function registers 'get_relation' by including it in the baseTools array returned in the tools list.return { tools: [...baseTools, ...temporalTools, ...(process.env.DEBUG === 'true' ? debugTools : [])], };
- Core logic for retrieving a relation, delegates to storageProvider if available, otherwise loads the full graph and searches for the matching relation.async getRelation(from: string, to: string, relationType: string): Promise<Relation | null> { if (this.storageProvider && typeof this.storageProvider.getRelation === 'function') { return this.storageProvider.getRelation(from, to, relationType); } // Fallback implementation const graph = await this.loadGraph(); const relation = graph.relations.find( (r) => r.from === from && r.to === to && r.relationType === relationType ); return relation || null; }
- File-based storage provider implementation of getRelation, loads graph and finds matching relation (deprecated).async getRelation(from: string, to: string, relationType: string): Promise<Relation | null> { const graph = await this.loadGraph(); const relation = graph.relations.find( (r) => r.from === from && r.to === to && r.relationType === relationType ); return relation || null; }