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)
          }`
        );
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It discloses that deletion includes 'all its associated data', which is valuable behavioral context. However, it lacks critical details like whether deletion is irreversible, permission requirements, error conditions, or response format.

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?

Single sentence, front-loaded with the core action, zero waste. Every word earns its place by specifying the resource and scope of deletion efficiently.

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 incomplete. It mentions data deletion scope but omits critical behavioral details like irreversibility, permissions, or error handling, leaving significant gaps for agent understanding.

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 parameter 'name' documented in the schema. The description adds no additional parameter semantics beyond what the schema provides, such as format examples or constraints. Baseline 3 is appropriate when schema does the heavy lifting.

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 resource ('an entity and all its associated data'), with explicit mention of what gets removed ('observations and relations'). It distinguishes itself from sibling tools like 'delete_relation' by specifying broader deletion 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 explicit guidance on when to use this tool versus alternatives like 'delete_relation' or 'create_entities'. The description implies usage for deleting entities with associated data, but lacks context on prerequisites, exclusions, or comparison to siblings.

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

Related 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/joleyline/mcp-memory-libsql'

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