Skip to main content
Glama
IzumiSy

MCP DuckDB Knowledge Graph Memory Server

delete_relations

Remove specific relations between entities in the DuckDB-based knowledge graph, ensuring accurate and up-to-date data for enhanced conversational memory and query performance.

Instructions

Delete multiple relations from the knowledge graph

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
relationsYesAn array of relations to delete

Implementation Reference

  • The handler function for the 'delete_relations' MCP tool. It calls the knowledge graph manager to perform the deletion and returns a success message.
    async ({ relations }) => { await knowledgeGraphManager.deleteRelations(relations); return { content: [{ type: "text", text: "Relations deleted successfully" }], }; }
  • Zod input schema validating the 'relations' parameter as an array of objects with 'from', 'to', and 'relationType' fields.
    relations: z .array( z.object({ from: z .string() .describe("The name of the entity where the relation starts"), to: z .string() .describe("The name of the entity where the relation ends"), relationType: z.string().describe("The type of the relation"), }) ) .describe("An array of relations to delete"),
  • src/server.ts:132-156 (registration)
    Registration of the 'delete_relations' tool using server.tool(), including name, description, schema, and handler function.
    server.tool( "delete_relations", "Delete multiple relations from the knowledge graph", { relations: z .array( z.object({ from: z .string() .describe("The name of the entity where the relation starts"), to: z .string() .describe("The name of the entity where the relation ends"), relationType: z.string().describe("The type of the relation"), }) ) .describe("An array of relations to delete"), }, async ({ relations }) => { await knowledgeGraphManager.deleteRelations(relations); return { content: [{ type: "text", text: "Relations deleted successfully" }], }; } );
  • Core helper function in KnowledgeGraphManager that implements the deletion logic by executing SQL DELETE statements within a database transaction for each relation.
    async deleteRelations(relations: Relation[]): Promise<void> { using conn = await this.getConn(); try { // Begin transaction await conn.execute("BEGIN TRANSACTION"); // Delete each relation for (const relation of relations) { await conn.execute( "DELETE FROM relations WHERE from_entity = ? AND to_entity = ? AND relationType = ?", [relation.from, relation.to, relation.relationType] ); } // Commit transaction await conn.execute("COMMIT"); } catch (error: unknown) { // Rollback in case of error await conn.execute("ROLLBACK"); this.logger.error("Error deleting relations", extractError(error)); throw error; } }
  • TypeScript type definition and corresponding Zod schema for a 'Relation' object, used throughout the codebase for relation handling.
    export const RelationObject = z.object({ from: z.string().describe("The name of the entity where the relation starts"), to: z.string().describe("The name of the entity where the relation ends"), relationType: z.string().describe("The type of the relation"), }); export type Relation = { from: string; to: string; relationType: string; };

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/IzumiSy/mcp-duckdb-memory-server'

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