Skip to main content
Glama

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
NameRequiredDescriptionDefault
entityNamesYesAn array of entity names to delete

Implementation Reference

  • 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"], }, };
  • 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); }
  • 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"], }, },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ali-48/rag-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server