delete_entities
Remove entities and their relationships from a knowledge graph to maintain accurate data by specifying which entries to delete.
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 |
Implementation Reference
- index.ts:185-190 (handler)The core handler function deleteEntities in KnowledgeGraphManager class that loads the graph, filters out the specified entities and all relations connected to them, and saves the updated graph.
async deleteEntities(entityNames: string[]): Promise<void> { 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:440-450 (schema)Input schema definition for the delete_entities tool, specifying an object with required 'entityNames' property as an array of strings.
inputSchema: { type: "object", properties: { entityNames: { type: "array", items: { type: "string" }, description: "An array of entity names to delete" }, }, required: ["entityNames"], }, - index.ts:437-451 (registration)Tool registration in the listTools response, defining name, description, and input schema for delete_entities.
{ 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" }, }, required: ["entityNames"], }, }, - index.ts:559-561 (helper)Dispatcher in the CallToolRequestHandler switch statement that calls the deleteEntities handler with arguments and returns a success response.
case "delete_entities": await knowledgeGraphManager.deleteEntities(args.entityNames as string[]); return createResponse("Entities deleted successfully");