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"],
        },
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. While it correctly indicates this is a destructive operation ('Delete'), it doesn't address critical behavioral aspects like whether deletions are permanent/reversible, what happens to orphaned data, permission requirements, rate limits, or error handling for invalid entity names.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose with zero wasted words. It's appropriately sized for a tool with one parameter and gets straight to the point without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive tool with no annotations and no output schema, the description is insufficient. It doesn't explain what 'associated relations' means operationally, what confirmation or validation occurs, what the return value or success indicators are, or how errors are handled - critical gaps for a deletion operation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with the single parameter 'entityNames' well-documented in the schema. The description adds no additional parameter semantics beyond what the schema already provides about the array of entity names to delete, meeting the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Delete') and target resources ('multiple entities and their associated relations from the knowledge graph'), providing a specific verb+resource combination. However, it doesn't explicitly distinguish this tool from sibling tools like 'delete_observations' or 'delete_relations', which handle different resource types in the same system.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'delete_observations' or 'delete_relations', nor does it mention prerequisites, constraints, or appropriate contexts for invocation. It simply states what the tool does without usage context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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