delete_relations
Remove specified relations between entities in a knowledge graph to update and maintain accurate, organized memory storage for user interactions.
Instructions
Delete multiple relations from the knowledge graph
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| relations | Yes | An array of relations to delete |
Implementation Reference
- src/memory/index.ts:380-386 (handler)The handler function for the delete_relations tool. It calls knowledgeGraphManager.deleteRelations(relations) to perform the deletion and returns a structured success response.async ({ relations }) => { await knowledgeGraphManager.deleteRelations(relations); return { content: [{ type: "text" as const, text: "Relations deleted successfully" }], structuredContent: { success: true, message: "Relations deleted successfully" } }; }
- src/memory/index.ts:369-379 (schema)Input and output schema for the delete_relations tool using Zod validation. Input is an array of relations; output indicates success.{ title: "Delete Relations", description: "Delete multiple relations from the knowledge graph", inputSchema: { relations: z.array(RelationSchema).describe("An array of relations to delete") }, outputSchema: { success: z.boolean(), message: z.string() } },
- src/memory/index.ts:367-387 (registration)Registration of the delete_relations tool with the MCP server, including schema and handler.server.registerTool( "delete_relations", { title: "Delete Relations", description: "Delete multiple relations from the knowledge graph", inputSchema: { relations: z.array(RelationSchema).describe("An array of relations to delete") }, outputSchema: { success: z.boolean(), message: z.string() } }, async ({ relations }) => { await knowledgeGraphManager.deleteRelations(relations); return { content: [{ type: "text" as const, text: "Relations deleted successfully" }], structuredContent: { success: true, message: "Relations deleted successfully" } }; } );
- src/memory/index.ts:160-168 (helper)Implementation of deleteRelations in KnowledgeGraphManager class. Loads the graph, filters out matching relations, and saves the updated graph.async deleteRelations(relations: Relation[]): Promise<void> { const graph = await this.loadGraph(); graph.relations = graph.relations.filter(r => !relations.some(delRelation => r.from === delRelation.from && r.to === delRelation.to && r.relationType === delRelation.relationType )); await this.saveGraph(graph); }
- src/memory/index.ts:233-237 (schema)Zod schema definition for Relation objects used in the delete_relations tool input.const RelationSchema = 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") });