get_entity_history
Retrieve version history of entities from a knowledge graph memory system to track changes and analyze temporal data.
Instructions
Get the version history of an entity from your Memento MCP knowledge graph memory
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| entityName | Yes | The name of the entity to retrieve history for |
Implementation Reference
- MCP callTool handler for 'get_entity_history': invokes KnowledgeGraphManager.getEntityHistory(entityName) and returns JSON-formatted history or error message.case 'get_entity_history': try { const history = await knowledgeGraphManager.getEntityHistory(args.entityName); return { content: [{ type: 'text', text: JSON.stringify(history, null, 2) }] }; } catch (error: Error | unknown) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: 'text', text: `Error retrieving entity history: ${errorMessage}` }], }; }
- src/server/handlers/listToolsHandler.ts:408-422 (registration)Tool registration in listToolsHandler: defines name, description, and input schema requiring 'entityName' string.{ name: 'get_entity_history', description: 'Get the version history of an entity from your Memento MCP knowledge graph memory', inputSchema: { type: 'object', properties: { entityName: { type: 'string', description: 'The name of the entity to retrieve history for', }, }, required: ['entityName'], }, },
- KnowledgeGraphManager wrapper: validates storageProvider support and delegates to storageProvider.getEntityHistory(entityName).async getEntityHistory(entityName: string): Promise<Entity[]> { if (!this.storageProvider || typeof this.storageProvider.getEntityHistory !== 'function') { throw new Error('Storage provider does not support entity history operations'); } return this.storageProvider.getEntityHistory(entityName); }
- Core implementation in Neo4jStorageProvider: Cypher query retrieves all Entity versions by name ordered by validFrom ASC, maps to Entity objects using nodeToEntity.async getEntityHistory(entityName: string): Promise<any[]> { try { // Query for entity history const query = ` MATCH (e:Entity {name: $name}) RETURN e ORDER BY e.validFrom ASC `; // Execute query const result = await this.connectionManager.executeQuery(query, { name: entityName }); // Return empty array if no history found if (result.records.length === 0) { return []; } // Convert nodes to entities return result.records.map((record) => { const node = record.get('e').properties; return this.nodeToEntity(node); }); } catch (error) { logger.error(`Error retrieving history for entity ${entityName} from Neo4j`, error); throw error; } }