delete_relations
Remove specified relations from the Memento MCP knowledge graph memory. Input an array of relations with 'from,' 'to,' and 'relationType' fields to delete them efficiently.
Instructions
Delete multiple relations from your Memento MCP knowledge graph memory
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| relations | Yes | An array of relations to delete |
Implementation Reference
- Executes the delete_relations tool by calling KnowledgeGraphManager.deleteRelations with the input arguments and returns a success message.case 'delete_relations': await knowledgeGraphManager.deleteRelations(args.relations); return { content: [{ type: 'text', text: 'Relations deleted successfully' }] };
- src/server/handlers/listToolsHandler.ts:206-234 (registration)Registers the 'delete_relations' tool including its name, description, and input schema definition.{ name: 'delete_relations', description: 'Delete multiple relations from your Memento MCP knowledge graph memory', inputSchema: { type: 'object', properties: { relations: { type: 'array', items: { 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'], }, description: 'An array of relations to delete', }, }, required: ['relations'], }, },
- src/KnowledgeGraphManager.ts:657-680 (helper)KnowledgeGraphManager.deleteRelations method that delegates deletion to the storage provider or handles file-based storage by filtering relations.async deleteRelations(relations: Relation[]): Promise<void> { if (!relations || relations.length === 0) { return; } if (this.storageProvider) { // Use storage provider for deleting relations await this.storageProvider.deleteRelations(relations); } else { // Fallback to file-based implementation const graph = await this.loadGraph(); // Filter out relations that match the ones to delete graph.relations = graph.relations.filter((r) => { // Check if this relation matches any in the deletion list return !relations.some( (delRel) => r.from === delRel.from && r.relationType === delRel.relationType && r.to === delRel.to ); }); await this.saveGraph(graph); } }
- FileStorageProvider implementation of deleteRelations, which loads the graph, removes matching relations, and saves the updated graph.async deleteRelations(relations: Relation[]): Promise<void> { await this.loadGraph(); for (const relation of relations) { this.graph.relations = this.graph.relations.filter( (r) => !( r.from === relation.from && r.to === relation.to && r.relationType === relation.relationType ) ); } await this.saveGraph(this.graph); }