Skip to main content
Glama
IzumiSy

MCP DuckDB Knowledge Graph Memory Server

delete_entities

Remove entities and their connections from a knowledge graph to maintain data accuracy and manage stored information.

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 core handler function that deletes the specified entities from the database. It first deletes associated observations and relations (ignoring errors), then deletes the entities, and updates the Fuse.js search index.
    async deleteEntities(entityNames: string[]): Promise<void> {
      if (entityNames.length === 0) return;
    
      try {
        using conn = await this.getConn();
    
        // Create placeholders
        const placeholders = entityNames.map(() => "?").join(",");
    
        // Delete related observations first
        try {
          await conn.execute(
            `DELETE FROM observations WHERE entityName IN (${placeholders})`,
            entityNames
          );
        } catch (error: unknown) {
          this.logger.error("Error deleting observations", extractError(error));
          // Ignore error and continue
        }
    
        // Delete related relations
        try {
          await conn.execute(
            `DELETE FROM relations WHERE from_entity IN (${placeholders}) OR to_entity IN (${placeholders})`,
            [...entityNames, ...entityNames]
          );
        } catch (error: unknown) {
          this.logger.error("Error deleting relations", extractError(error));
          // Ignore error and continue
        }
    
        // Delete entities
        await conn.execute(
          `DELETE FROM entities WHERE name IN (${placeholders})`,
          entityNames
        );
    
        // Update Fuse.js index
        const allEntities = await this.getAllEntities();
        this.fuse.setCollection(allEntities);
      } catch (error: unknown) {
        this.logger.error("Error deleting entities", extractError(error));
        throw error;
      }
    }
  • src/server.ts:89-103 (registration)
    Registers the 'delete_entities' tool with the MCP server, defining its description, input schema using Zod, and handler that delegates to KnowledgeGraphManager.
    server.tool(
      "delete_entities",
      "Delete multiple entities and their associated relations from the knowledge graph",
      {
        entityNames: z
          .array(z.string())
          .describe("An array of entity names to delete"),
      },
      async ({ entityNames }) => {
        await knowledgeGraphManager.deleteEntities(entityNames);
        return {
          content: [{ type: "text", text: "Entities deleted successfully" }],
        };
      }
    );
  • Zod input schema for the tool, specifying an array of strings for entity names.
      entityNames: z
        .array(z.string())
        .describe("An array of entity names to delete"),
    },
  • TypeScript interface definition for the deleteEntities method in KnowledgeGraphManagerInterface.
    deleteEntities(entityNames: string[]): Promise<void>;
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 'Delete' implies a destructive mutation, it doesn't specify whether this operation is reversible, what permissions are required, how deletions cascade through relations, or what happens if entities don't exist. The mention of 'associated relations' hints at cascading behavior but lacks detail.

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

Conciseness4/5

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

The description is a single, efficient sentence that gets straight to the point without unnecessary words. It's appropriately sized for a tool with one parameter and clear purpose, though it could be slightly more front-loaded with critical behavioral information.

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 mutation tool with no annotations and no output schema, the description is insufficient. It doesn't explain what happens after deletion (success/failure responses), error conditions, or important behavioral details like whether deletions are atomic or what happens to orphaned relations. The context signals indicate this is a significant operation that needs more complete documentation.

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 provides, but doesn't need to compensate for gaps. This meets 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 differentiate 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 or constraints. It simply states what the tool does without contextual usage information.

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/IzumiSy/mcp-duckdb-memory-server'

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