Skip to main content
Glama
modelcontextprotocol

Knowledge Graph Memory Server

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
NameRequiredDescriptionDefault
relationsYesAn array of relations to delete

Implementation Reference

  • 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" } }; }
  • 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() } },
  • 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" } }; } );
  • 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); }
  • 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") });

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/modelcontextprotocol/knowledge-graph-memory-server'

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