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

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