delete_entities
Remove entities and their relationships from a knowledge graph to maintain accurate semantic indexing and search results in RAG systems.
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
- src/tools/graph/delete-entities.ts:31-55 (handler)The primary handler function for the 'delete_entities' tool. It validates the input entityNames array, calls the knowledgeGraphManager to perform the deletion, and returns a success message.export const deleteEntitiesHandler: ToolHandler = async (args) => { if (!args.entityNames || !Array.isArray(args.entityNames)) { throw new Error("The 'entityNames' parameter is required and must be an array"); } // Valider chaque nom d'entité for (const entityName of args.entityNames) { if (!entityName || typeof entityName !== 'string') { throw new Error("Each entity name must be a non-empty string"); } } try { await knowledgeGraphManager.deleteEntities(args.entityNames); return { content: [{ type: "text", text: "Entities deleted successfully" }] }; } catch (error) { console.error("Error in delete_entities tool:", error); throw error; } };
- The tool definition object containing name, description, and input schema for 'delete_entities', used for registration.export const deleteEntitiesTool: ToolDefinition = { 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"], }, };
- src/core/registry.ts:262-282 (registration)The getExpectedTools function lists 'delete_entities' among expected tools for auto-registration verification in the tool registry.export function getExpectedTools(): string[] { return [ // Outils Graph (9 outils) 'create_entities', 'create_relations', 'add_observations', 'delete_entities', 'delete_observations', 'delete_relations', 'read_graph', 'search_nodes', 'open_nodes', // Outils RAG (5 outils - avec injection_rag comme outil principal) 'injection_rag', // Nouvel outil principal 'index_project', // Alias déprécié (rétrocompatibilité) 'search_code', 'manage_projects', 'update_project' ]; }
- The core deleteEntities method in KnowledgeGraphManager that removes specified entities and their associated relations from the persistent graph storage.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); }
- build/tools/graph-tools.js:77-91 (schema)Alternative inline schema definition for 'delete_entities' within the graphTools array, used potentially in a switch-based dispatcher.{ 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"], }, },