Skip to main content
Glama

delete_entity

Remove an entity and its associated data (observations, relations) from the MCP server mcp-memory-libsql. Input the entity name to ensure complete data deletion, enabling efficient entity management.

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

  • Valibot input schema for the delete_entity tool, requiring a 'name' string parameter.
    const DeleteEntitySchema = v.object({
    	name: v.string(),
    });
  • src/index.ts:234-240 (registration)
    MCP server tool registration for 'delete_entity', specifying name, description, and schema.
    server.tool<typeof DeleteEntitySchema>(
    	{
    		name: 'delete_entity',
    		description:
    			'Delete an entity and all its associated data (observations and relations)',
    		schema: DeleteEntitySchema,
    	},
  • Handler function that executes the delete_entity tool logic: calls database delete_entity, returns success message or error response.
    async ({ name }) => {
    	try {
    		await db.delete_entity(name);
    		return {
    			content: [
    				{
    					type: 'text' as const,
    					text: `Successfully deleted entity "${name}" and its associated data`,
    				},
    			],
    		};
    	} catch (error) {
    		return {
    			content: [
    				{
    					type: 'text' as const,
    					text: JSON.stringify(
    						{
    							error: 'internal_error',
    							message:
    								error instanceof Error
    									? error.message
    									: 'Unknown error',
    						},
    						null,
    						2,
    					),
    				},
    			],
    			isError: true,
    		};
    	}
    },
  • DatabaseManager helper method implementing the actual deletion: checks existence, deletes observations, relations, and entity in batch.
    async delete_entity(name: string): Promise<void> {
    	try {
    		// Check if entity exists first
    		const existing = await this.client.execute({
    			sql: 'SELECT name FROM entities WHERE name = ?',
    			args: [name],
    		});
    
    		if (existing.rows.length === 0) {
    			throw new Error(`Entity not found: ${name}`);
    		}
    
    		// Prepare batch statements for deletion
    		const batch_statements = [
    			{
    				// 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 this.client.batch(batch_statements, 'write');
    	} catch (error) {
    		throw new Error(
    			`Failed to delete entity "${name}": ${
    				error instanceof Error ? error.message : String(error)
    			}`,
    		);
    	}
    }
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.

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

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