Skip to main content
Glama

Graph Unmerge

graph_unmerge
Destructive

Split a falsely merged entity back into two separate entities by moving specified edges to a new entity. Use when entity resolution incorrectly merged distinct entities.

Instructions

Split a falsely merged entity back into two separate entities, redistributing specified edges. Use when entity resolution made a mistake (e.g. merged 'Anna' and 'Anne'). The original entity keeps every edge not listed in edges_to_move; the new entity gets the listed edges plus a fresh embedding stub (re-derive with graph_reembed). Logged to the audit trail with reason. Returns the IDs of both entities.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
entity_idYesThe merged entity ID to split
new_entity_nameYesName for the split-off entity
new_entity_typeYesType label for the split-off entity
edges_to_moveYesEdges to move to the new entity
reasonYesWhy splitting (logged in audit)

Implementation Reference

  • Registration of the graph_unmerge tool on the MCP server, with input schema and handler definition. Calls client.unmerge() to split a falsely merged entity.
    // ─── Tool: graph_unmerge ───
    
    server.registerTool("graph_unmerge", {
      title: "Graph Unmerge",
      description:
        "Split a falsely merged entity back into two separate entities, redistributing specified edges. Use when entity resolution made a mistake (e.g. merged 'Anna' and 'Anne'). The original entity keeps every edge not listed in `edges_to_move`; the new entity gets the listed edges plus a fresh embedding stub (re-derive with graph_reembed). Logged to the audit trail with `reason`. Returns the IDs of both entities.",
      inputSchema: {
        entity_id: z.string().describe("The merged entity ID to split"),
        new_entity_name: z.string().describe("Name for the split-off entity"),
        new_entity_type: z.string().describe("Type label for the split-off entity"),
        edges_to_move: z.array(z.object({
          other_entity_id: z.string().describe("Entity on the other end of the edge"),
          relation_type: z.string().describe("Relationship type (e.g. WORKS_ON)"),
          direction: z.enum(["in", "out"]).describe("Direction relative to the entity being split"),
        })).describe("Edges to move to the new entity"),
        reason: z.string().describe("Why splitting (logged in audit)"),
      },
      annotations: { destructiveHint: true },
    }, async (args) => {
      try {
        const result = await client.unmerge(
          currentTenant(),
          args.entity_id,
          args.new_entity_name,
          args.new_entity_type as EntityType,
          args.edges_to_move.map((e) => ({
            ...e,
            relation_type: e.relation_type as RelationshipType,
          })),
          args.reason,
        );
    
        // Log to merge audit
        try {
          const auditDir = join(GRAPH_MEMORY_HOME, "logs");
          mkdirSync(auditDir, { recursive: true });
          const auditPath = join(auditDir, "merge-audit.jsonl");
          const entry = JSON.stringify({
            action: "unmerge",
            timestamp: new Date().toISOString(),
            ...result,
            reason: args.reason,
          });
          writeFileSync(auditPath, entry + "\n", { flag: "a" });
        } catch { /* audit logging is best-effort */ }
    
        return toolResult({ ...result, audit_logged: true });
      } catch (err) {
        return toolError(`graph_unmerge failed: ${err instanceof Error ? err.message : String(err)}`);
      }
    });
  • Input schema for graph_unmerge: entity_id, new_entity_name, new_entity_type, edges_to_move (array of {other_entity_id, relation_type, direction}), and reason.
    inputSchema: {
      entity_id: z.string().describe("The merged entity ID to split"),
      new_entity_name: z.string().describe("Name for the split-off entity"),
      new_entity_type: z.string().describe("Type label for the split-off entity"),
      edges_to_move: z.array(z.object({
        other_entity_id: z.string().describe("Entity on the other end of the edge"),
        relation_type: z.string().describe("Relationship type (e.g. WORKS_ON)"),
        direction: z.enum(["in", "out"]).describe("Direction relative to the entity being split"),
      })).describe("Edges to move to the new entity"),
      reason: z.string().describe("Why splitting (logged in audit)"),
    },
  • Handler logic for graph_unmerge: calls client.unmerge() with tenant context, then logs to merge-audit.jsonl audit file. Returns both entity IDs.
    }, async (args) => {
      try {
        const result = await client.unmerge(
          currentTenant(),
          args.entity_id,
          args.new_entity_name,
          args.new_entity_type as EntityType,
          args.edges_to_move.map((e) => ({
            ...e,
            relation_type: e.relation_type as RelationshipType,
          })),
          args.reason,
        );
    
        // Log to merge audit
        try {
          const auditDir = join(GRAPH_MEMORY_HOME, "logs");
          mkdirSync(auditDir, { recursive: true });
          const auditPath = join(auditDir, "merge-audit.jsonl");
          const entry = JSON.stringify({
            action: "unmerge",
            timestamp: new Date().toISOString(),
            ...result,
            reason: args.reason,
          });
          writeFileSync(auditPath, entry + "\n", { flag: "a" });
        } catch { /* audit logging is best-effort */ }
    
        return toolResult({ ...result, audit_logged: true });
      } catch (err) {
        return toolError(`graph_unmerge failed: ${err instanceof Error ? err.message : String(err)}`);
      }
    });
Behavior5/5

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

Adds significant context beyond annotations: explains edge redistribution, fresh embedding stub, audit logging, and return value. Consistent with destructiveHint annotation.

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?

Four sentences, front-loaded with purpose, no wasted words. Clear structure: action, use case, behavior detail, return value.

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

Completeness5/5

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

Given no output schema, the description explains return value (IDs of both entities), audit logging, and required post-processing. Fully meets informational needs for an agent.

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 coverage is 100% and parameter descriptions are adequate. The description adds limited extra meaning beyond the schema, so baseline of 3 is appropriate.

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

Purpose5/5

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

The description clearly states the action: 'Split a falsely merged entity back into two separate entities, redistributing specified edges.' It distinguishes from sibling tools like graph_merge and graph_merge_suggestions.

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

Usage Guidelines4/5

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

Explicitly says 'Use when entity resolution made a mistake (e.g. merged 'Anna' and 'Anne')' and mentions subsequent re-embedding. It does not explicitly list when not to use or alternatives.

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

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/stevepridemore/graph-memory'

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