Skip to main content
Glama

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
NameRequiredDescriptionDefault
sourceYesSource entity name
targetYesTarget entity name
typeYesType of relation

Implementation Reference

  • 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', ], }, },
  • 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)}` ); } }

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