delete_entities
Remove entities and their relationships from a knowledge graph stored in a specified memory file to maintain data accuracy and relevance.
Instructions
Delete multiple entities and their associated relations from the knowledge graph
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| entityNames | Yes | An array of entity names to delete | |
| memoryFilePath | Yes | The path to the memory file |
Implementation Reference
- index.ts:176-186 (handler)The handler function in KnowledgeGraphManager that implements the deletion of specified entities and all relations connected to them from the graph stored in the memory file.async deleteEntities(entityNames: string[], filepath: string): Promise<void> { await this.setMemoryFilePath(filepath); const graph = await this.loadGraph(); graph.entities = graph.entities.filter( (e) => !entityNames.includes(e.name) ); graph.relations = graph.relations.filter( (r) => !entityNames.includes(r.from) && !entityNames.includes(r.to) ); await this.saveGraph(graph); }
- index.ts:435-453 (schema)The tool schema definition including name, description, and input schema for validating parameters (entityNames array and memoryFilePath).name: "delete_entities", description: "Delete multiple entities and their associated relations from the knowledge graph", inputSchema: { type: "object", properties: { entityNames: { type: "array", items: { type: "string" }, description: "An array of entity names to delete", }, memoryFilePath: { type: "string", description: "The path to the memory file", }, }, required: ["entityNames", "memoryFilePath"], }, },
- index.ts:653-660 (registration)The dispatch case in the CallToolRequestHandler switch statement that invokes the deleteEntities handler with parsed arguments and returns success response.case "delete_entities": await knowledgeGraphManager.deleteEntities( args.entityNames as string[], args.memoryFilePath as string ); return { content: [{ type: "text", text: "Entities deleted successfully" }], };