Skip to main content
Glama
j3k0

Elasticsearch Knowledge Graph for MCP

by j3k0

delete_relations

Remove specified relationships between entities in a knowledge graph to maintain accurate and relevant data connections. Supports optional memory zone targeting for precise deletions.

Instructions

Delete relationships from knowledge graph (memory)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
memory_zoneNoOptional memory zone specifier. If provided, relations will be deleted from this zone.
relationsYesList of relations to delete

Implementation Reference

  • Core handler implementation in KnowledgeGraphClient that deletes the Elasticsearch document for the specified relation using its constructed ID.
    async deleteRelation(
      from: string, 
      to: string, 
      relationType: string, 
      fromZone?: string, 
      toZone?: string
    ): Promise<boolean> {
      await this.initialize();
      
      const actualFromZone = fromZone || this.defaultZone;
      const actualToZone = toZone || this.defaultZone;
      
      try {
        const relationId = `relation:${actualFromZone}:${from}:${relationType}:${actualToZone}:${to}`;
        
        await this.client.delete({
          index: KG_RELATIONS_INDEX,
          id: relationId,
          refresh: true
        });
        
        return true;
      } catch (error) {
        if (error.statusCode === 404) {
          return false;
        }
        throw error;
      }
    }
  • MCP server tool dispatch handler that loops over input relations and calls the core deleteRelation method.
    else if (toolName === "delete_relations") {
      const relations = params.relations;
      const zone = params.memory_zone;
      const results = [];
      
      // Delete each relation individually
      for (const relation of relations) {
        const success = await kgClient.deleteRelation(
          relation.from, 
          relation.to, 
          relation.type,
          zone,
          zone
        );
        results.push({ 
          from: relation.from, 
          to: relation.to, 
          type: relation.type,
          deleted: success 
        });
      }
      
      return formatResponse({
        success: true,
        results
      });
    }
  • src/index.ts:297-323 (registration)
    Tool registration including name, description, and input schema in the ListToolsRequestSchema response.
    name: "delete_relations",
    description: "Delete relationships from knowledge graph (memory)",
    inputSchema: {
      type: "object",
      properties: {
        relations: {
          type: "array",
          description: "List of relations to delete",
          items: {
            type: "object",
            properties: {
              from: {type: "string", description: "Source entity name"},
              to: {type: "string", description: "Target entity name"},
              type: {type: "string", description: "Relationship type"}
            },
            required: ["from", "to", "type"]
          }
        },
        memory_zone: {
          type: "string",
          description: "Optional memory zone specifier. If provided, relations will be deleted from this zone."
        }
      },
      required: ["relations"],
      additionalProperties: false,
      "$schema": "http://json-schema.org/draft-07/schema#"
    }
  • Legacy file-based handler in KnowledgeGraphManager that filters and removes matching relations from the in-memory graph and persists to file.
    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);
    }
  • Legacy tool registration and schema.
    {
      name: "delete_relations",
      description: "Delete multiple relations from the knowledge graph",
      inputSchema: {
        type: "object",
        properties: {
          relations: { 
            type: "array", 
            items: {
              type: "object",
              properties: {
                from: { type: "string", description: "The name of the entity where the relation starts" },
                to: { type: "string", description: "The name of the entity where the relation ends" },
                relationType: { type: "string", description: "The type of the relation" },
              },
              required: ["from", "to", "relationType"],
            },
            description: "An array of relations to delete" 
          },
        },
        required: ["relations"],
      },
    },
Behavior2/5

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

With no annotations provided, the description carries full burden but provides minimal behavioral context. It states this is a deletion operation but doesn't mention whether deletions are permanent, reversible, require specific permissions, have side effects on connected entities, or provide confirmation of what was deleted. For a destructive operation with zero annotation coverage, this is insufficient.

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 extremely concise at just 5 words plus a parenthetical clarification. Every element earns its place: 'Delete' specifies the action, 'relationships' specifies what's being deleted, 'from knowledge graph' provides context, and '(memory)' clarifies the domain. No wasted words or redundancy.

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?

For a destructive operation with no annotations and no output schema, the description is inadequate. It doesn't explain what happens after deletion, whether there's confirmation, error conditions, or behavioral constraints. Given the complexity of graph operations and complete lack of structured safety information, more descriptive context is needed.

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%, so the schema fully documents both parameters. The description adds no additional parameter information beyond what's in the schema. The baseline score of 3 reflects adequate parameter documentation through the schema alone, with no value added by the description.

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 action ('Delete') and target ('relationships from knowledge graph'), with parenthetical clarification that this refers to 'memory'. It distinguishes from siblings like 'delete_entities' by specifying relationship deletion rather than entity deletion. However, it doesn't explicitly contrast with 'delete_zone' or other deletion tools.

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?

No guidance is provided about when to use this tool versus alternatives. With siblings like 'delete_entities', 'delete_zone', and 'create_relations', there's no indication of when relationship deletion is appropriate versus entity deletion or zone deletion, or how this differs from other graph modification tools.

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/j3k0/mcp-brain-tools'

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