Skip to main content
Glama

delete_entity

Remove an entity and its related data, including observations and relations, from the MCP Memory LibSQL server. Input the entity name to execute the deletion process.

Instructions

Delete an entity and all its associated data (observations and relations)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesName of the entity to delete

Implementation Reference

  • The tool handler in the CallToolRequestSchema switch statement that validates the input 'name', calls the deleteEntity service function, and returns a success message.
    case 'delete_entity': {
      // Safely access properties with type assertions
      if (!args.name) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Missing required parameter: name'
        );
      }
      
      const name = args.name as string;
      await deleteEntity(name);
      return {
        content: [
          {
            type: 'text',
            text: `Successfully deleted entity: ${name}`,
          },
        ],
      };
    }
  • JSON input schema for the delete_entity tool defining the required 'name' string parameter.
    inputSchema: {
      type: 'object',
      properties: {
        name: {
          type: 'string',
          description: 'Name of the entity to delete',
        },
      },
      required: [
        'name',
      ],
    },
  • src/index.ts:218-233 (registration)
    Registration of the delete_entity tool in the ListToolsRequestSchema handler, including name, description, and input schema.
    {
      name: 'delete_entity',
      description: 'Delete an entity and all its associated data (observations and relations)',
      inputSchema: {
        type: 'object',
        properties: {
          name: {
            type: 'string',
            description: 'Name of the entity to delete',
          },
        },
        required: [
          'name',
        ],
      },
    },
  • Core implementation of deleteEntity that checks if the entity exists, then deletes associated observations, relations, and the entity itself using batch SQL statements.
    public static async deleteEntity(name: string): Promise<void> {
      try {
        const client = databaseService.getClient();
        
        // Check if entity exists first
        const existing = await client.execute({
          sql: 'SELECT name FROM entities WHERE name = ?',
          args: [name],
        });
    
        if (existing.rows.length === 0) {
          throw new ValidationError(`Entity not found: ${name}`);
        }
    
        // Prepare batch statements for deletion
        const batchStatements = [
          {
            // Delete associated observations first (due to foreign key)
            sql: 'DELETE FROM observations WHERE entity_name = ?',
            args: [name],
          },
          {
            // Delete associated relations (due to foreign key)
            sql: 'DELETE FROM relations WHERE source = ? OR target = ?',
            args: [name, name],
          },
          {
            // Delete the entity
            sql: 'DELETE FROM entities WHERE name = ?',
            args: [name],
          },
        ];
    
        // Execute all deletions in a single batch transaction
        await client.batch(batchStatements, 'write');
      } catch (error) {
        throw new DatabaseError(
          `Failed to delete entity "${name}": ${
            error instanceof Error ? error.message : String(error)
          }`
        );
      }
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A3.5/5.0
Behavior3/5

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

With no annotations provided, the description carries full burden. It discloses the destructive nature ('Delete... and all its associated data'), which is crucial behavioral context. However, it lacks details on permissions needed, error conditions, or what happens if the entity doesn't exist.

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 front-loads the core action and scope. Every word contributes meaning without redundancy, making it appropriately sized for a one-parameter tool.

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

Completeness3/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 adequately covers the basic action and scope. However, it lacks important context about permissions, confirmation requirements, or return values, leaving gaps for safe agent 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%, providing a clear parameter description. The tool description doesn't add any parameter-specific information beyond what's in the schema, so it meets the baseline for high schema coverage without compensating value.

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

Purpose5/5

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

The description clearly states the specific action ('Delete') and target resource ('an entity and all its associated data'), with explicit mention of what gets deleted ('observations and relations'). It distinguishes from sibling tools like 'delete_relation' by specifying broader scope.

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?

No guidance on when to use this tool versus alternatives is provided. While the description implies destructive deletion, it doesn't specify prerequisites, warn about irreversible changes, or mention when to choose 'delete_entity' over 'delete_relation' or other siblings.

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

Deploy Server

Other Tools

Related Tools