delete_relation
Remove a specific relationship between entities in the MCP Memory LibSQL server by specifying the source, target, and relation type for efficient knowledge management.
Instructions
Delete a specific relation between entities
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| source | Yes | Source entity name | |
| target | Yes | Target entity name | |
| type | Yes | Type of relation |
Implementation Reference
- src/index.ts:422-444 (handler)MCP tool handler for 'delete_relation': validates input arguments from the tool call request, calls the deleteRelation service, and returns success response.case 'delete_relation': { // Safely access properties with type assertions if (!args.source || !args.target || !args.type) { throw new McpError( ErrorCode.InvalidParams, 'Missing required parameters: source, target, or type' ); } const source = args.source as string; const target = args.target as string; const type = args.type as string; await deleteRelation(source, target, type); return { content: [ { type: 'text', text: `Successfully deleted relation: ${source} -> ${target} (${type})`, }, ], }; }
- src/index.ts:234-259 (registration)Registration of 'delete_relation' tool in the server's listTools response, including name, description, and JSON input schema.{ name: 'delete_relation', description: 'Delete a specific relation between entities', inputSchema: { type: 'object', properties: { source: { type: 'string', description: 'Source entity name', }, target: { type: 'string', description: 'Target entity name', }, type: { type: 'string', description: 'Type of relation', }, }, required: [ 'source', 'target', 'type', ], }, },
- src/index.ts:237-258 (schema)JSON schema defining the input parameters for the 'delete_relation' tool (source, target, type), used for validation.inputSchema: { type: 'object', properties: { source: { type: 'string', description: 'Source entity name', }, target: { type: 'string', description: 'Target entity name', }, type: { type: 'string', description: 'Type of relation', }, }, required: [ 'source', 'target', 'type', ], },
- Core helper function deleteRelation that validates parameters and executes SQL DELETE on the relations table, called by the tool handler.public static async deleteRelation( source: string, target: string, type: string, ): Promise<void> { try { // Validate parameters if (!source || typeof source !== 'string') { throw new ValidationError('Source entity name must be a non-empty string'); } if (!target || typeof target !== 'string') { throw new ValidationError('Target entity name must be a non-empty string'); } if (!type || typeof type !== 'string') { throw new ValidationError('Relation type must be a non-empty string'); } const client = databaseService.getClient(); const result = await client.execute({ sql: 'DELETE FROM relations WHERE source = ? AND target = ? AND relation_type = ?', args: [source, target, type], }); if (result.rowsAffected === 0) { throw new ValidationError( `Relation not found: ${source} -> ${target} (${type})`, ); } logger.info(`Deleted relation: ${source} -> ${target} (${type})`); } catch (error) { if (error instanceof ValidationError) { throw error; } throw new DatabaseError( `Failed to delete relation: ${error instanceof Error ? error.message : String(error)}` ); } }