delete_relations
Remove unwanted connections from a knowledge graph to maintain accurate data relationships. Specify entities and relation types to delete from your memory file.
Instructions
Delete multiple relations from the knowledge graph
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| relations | Yes | An array of relations to delete | |
| memoryFilePath | Yes | The path to the memory file |
Implementation Reference
- index.ts:205-221 (handler)The core handler function in KnowledgeGraphManager that deletes specified relations by filtering them out from the graph's relations array and saving the updated graph to the memory file.async deleteRelations( relations: Relation[], filepath: string ): Promise<void> { await this.setMemoryFilePath(filepath); const graph = await this.loadGraph(); graph.relations = graph.relations.filter( (r) => !relations.some( (delRelation) => r.from === delRelation.from && r.to === delRelation.to && r.relationType === delRelation.relationType ) ); await this.saveGraph(graph); }
- index.ts:488-525 (schema)The input schema definition for the delete_relations tool, specifying the expected parameters: an array of relations (each with from, to, relationType) and memoryFilePath.{ name: "delete_relations", description: "Delete multiple relations from the knowledge graph", 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", }, memoryFilePath: { type: "string", description: "The path to the memory file", }, }, required: ["relations", "memoryFilePath"], }, },
- index.ts:669-676 (registration)The registration in the CallToolRequestSchema switch statement that dispatches calls to the deleteRelations method and returns success message.case "delete_relations": await knowledgeGraphManager.deleteRelations( args.relations as Relation[], args.memoryFilePath as string ); return { content: [{ type: "text", text: "Relations deleted successfully" }], };
- index.ts:36-40 (helper)Type definition for Relation used in delete_relations parameters.interface Relation { from: string; to: string; relationType: string; }