delete_relation
Remove specific entity relations by specifying source, target, and relation type, enhancing data management on the libSQL-based server.
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:283-315 (handler)The handler function that implements the core logic of the 'delete_relation' MCP tool. It calls the database delete_relation method and formats the success or error response.async ({ source, target, type }) => { try { await db.delete_relation(source, target, type); return { content: [ { type: 'text' as const, text: `Successfully deleted relation: ${source} -> ${target} (${type})`, }, ], }; } 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, }; } },
- src/index.ts:52-56 (schema)Valibot schema defining the input parameters for the delete_relation tool: source, target, and type as strings.const DeleteRelationSchema = v.object({ source: v.string(), target: v.string(), type: v.string(), });
- src/index.ts:277-282 (registration)Registration of the 'delete_relation' tool on the MCP server, specifying name, description, and schema.server.tool<typeof DeleteRelationSchema>( { name: 'delete_relation', description: 'Delete a specific relation between entities', schema: DeleteRelationSchema, },
- src/db/client.ts:305-328 (helper)Database helper method that performs the actual SQL DELETE operation for a specific relation and handles errors.async delete_relation( source: string, target: string, type: string, ): Promise<void> { try { const result = await this.client.execute({ sql: 'DELETE FROM relations WHERE source = ? AND target = ? AND relation_type = ?', args: [source, target, type], }); if (result.rowsAffected === 0) { throw new Error( `Relation not found: ${source} -> ${target} (${type})`, ); } } catch (error) { throw new Error( `Failed to delete relation: ${ error instanceof Error ? error.message : String(error) }`, ); } }