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")
    });
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states 'delete multiple relations', implying a destructive mutation, but doesn't cover critical aspects like permissions needed, whether deletions are permanent or reversible, error handling for non-existent relations, or rate limits. This leaves significant gaps for a mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero wasted words, clearly front-loading the core action and resource. It's appropriately sized for the tool's complexity, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's destructive nature, lack of annotations, and no output schema, the description is incomplete. It doesn't explain what happens upon deletion (e.g., effects on the graph), return values, or error conditions. For a mutation tool with zero structured coverage, more context is needed to guide safe usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with the schema fully documenting the 'relations' parameter as an array of objects with 'from', 'to', and 'relationType'. The description adds no additional parameter semantics beyond what's in the schema, such as format examples or constraints, so it meets the baseline for high coverage without extra value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'delete' and the resource 'relations from the knowledge graph', making the purpose unambiguous. However, it doesn't differentiate from sibling tools like 'delete_entities' or 'delete_observations', which would require specifying it targets relations specifically rather than other graph components.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'delete_entities' or 'create_relations'. It lacks context about prerequisites, such as whether relations must exist or be deletable, and doesn't mention any exclusions or recommended scenarios for bulk deletion.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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