Skip to main content
Glama

Graph Contradictions

graph_contradictions
Read-only

Identify conflicting facts in your memory graph by detecting pairs connected by a CONTRADICTS edge. Use during reviews or before graph decay to surface unresolved contradictions.

Instructions

Find facts that contradict each other in the memory graph — pairs connected by a CONTRADICTS edge. Use during reviews, before a graph_decay run, or when the user asks about conflicting information. Returns {contradictions: [{node_a, node_b, description, detected_date, resolved}], count} ordered by most-recently detected. By default only unresolved pairs are surfaced; set include_resolved=true to audit historical resolutions. Resolve a contradiction by graph_weaken on the wrong edge or by graph_relate with relation=SUPERSEDES on the new fact.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
include_resolvedNoInclude resolved contradictions (default: false)

Implementation Reference

  • Registration of the graph_contradictions tool on the MCP server with input schema (include_resolved), description, and read-only annotation.
    // ─── Tool: graph_contradictions ───
    
    server.registerTool("graph_contradictions", {
      title: "Graph Contradictions",
      description:
        "Find facts that contradict each other in the memory graph — pairs connected by a CONTRADICTS edge. Use during reviews, before a graph_decay run, or when the user asks about conflicting information. Returns `{contradictions: [{node_a, node_b, description, detected_date, resolved}], count}` ordered by most-recently detected. By default only unresolved pairs are surfaced; set include_resolved=true to audit historical resolutions. Resolve a contradiction by graph_weaken on the wrong edge or by graph_relate with relation=SUPERSEDES on the new fact.",
      inputSchema: {
        include_resolved: z.boolean().optional().default(false).describe("Include resolved contradictions (default: false)"),
      },
      annotations: { readOnlyHint: true },
    }, async (args) => {
      try {
        const result = await client.findContradictions(currentTenant(), args.include_resolved ?? false);
        return toolResult(result);
      } catch (err) {
        return toolError(`graph_contradictions failed: ${err instanceof Error ? err.message : String(err)}`);
      }
    });
  • The findContradictions handler method that queries the Neo4j database for CONTRADICTS edges between entities, optionally filtering for unresolved contradictions, ordered by most-recently detected.
    async findContradictions(tenantId: string, includeResolved = false): Promise<{
      contradictions: Array<{
        node_a: { id: string; type: string; name: string };
        node_b: { id: string; type: string; name: string };
        description: string;
        detected_date: string;
        resolved: boolean;
      }>;
      count: number;
    }> {
      const resolvedFilter = includeResolved ? "" : "AND r.resolved = false";
      const rows = await this.run(
        `
        MATCH (a:Entity {tenant_id: $tenantId})-[r:CONTRADICTS]->(b:Entity {tenant_id: $tenantId})
        WHERE 1=1 ${resolvedFilter}
        RETURN a.id AS aId, labels(a) AS aLabels, a.name AS aName,
               b.id AS bId, labels(b) AS bLabels, b.name AS bName,
               r.description AS description, r.detected_date AS detected_date,
               r.resolved AS resolved
        ORDER BY r.detected_date DESC
        `,
        { tenantId },
      );
    
      const contradictions = rows.map((row) => ({
        node_a: {
          id: String(row["aId"]),
          type: (row["aLabels"] as string[]).find((l) => l !== "Entity") ?? "Entity",
          name: String(row["aName"]),
        },
        node_b: {
          id: String(row["bId"]),
          type: (row["bLabels"] as string[]).find((l) => l !== "Entity") ?? "Entity",
          name: String(row["bName"]),
        },
        description: String(row["description"] ?? ""),
        detected_date: toISOString(row["detected_date"]),
        resolved: Boolean(row["resolved"]),
      }));
    
      return { contradictions, count: contradictions.length };
    }
  • Definition of RELATIONSHIP_TYPES including 'CONTRADICTS' (line 23) as a valid relationship type used by the contradictions tool.
    export const RELATIONSHIP_TYPES = [
      "WORKS_ON",
      "PREFERS",
      "KNOWS_ABOUT",
      "DEPENDS_ON",
      "USES_TECH",
      "DECIDED_FOR",
      "SUPERSEDES",
      "CONTRADICTS",
      "RELATED_TO",
      "ALIAS_OF",
      "PARTICIPATED_IN",
      "OCCURRED_DURING",
      "PRODUCED",
      "TRIGGERED_BY",
      "USES",
      "HOSTED_ON",
      "PRODUCED_BY",
      // Reasoning trace edges (Reasoning -> any)
      "LED_TO",       // Reasoning -> Decision/Event/Fact (this thinking led to that outcome)
      "INVOLVED_IN",  // Reasoning -> Person/Project/Concept/Object (these entities took part in the reasoning)
      // Organizational relationships (added 2026-05-06 after claude.ai introduced them)
      "WORKS_AT",     // Person -> Organization (employment / membership)
      "REPORTS_TO",   // Person -> Person (org hierarchy)
      "STAKEHOLDER_IN", // Person -> Decision/Project/Event (interested party, not necessarily decider)
    ] as const;
  • The async handler function that calls client.findContradictions and returns the result via toolResult, with error handling.
    }, async (args) => {
      try {
        const result = await client.findContradictions(currentTenant(), args.include_resolved ?? false);
        return toolResult(result);
      } catch (err) {
Behavior5/5

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

Annotations mark readOnlyHint=true, and description aligns by specifying it returns contradictions without mutations. Adds details on return format and default filtering of unresolved pairs.

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?

Two well-structured sentences: purpose, usage, return format, parameter guidance. No redundant words.

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?

With simple schema (1 param, no output schema), description fully covers purpose, usage, return structure, parameter semantics, and resolution hints.

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

Parameters4/5

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

Schema covers parameter with description. Description adds context: explains default behavior and when to use include_resolved=true (historical audits), building on schema.

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?

Clearly states the tool finds contradictory facts via CONTRADICTS edges. Distinct from sibling tools like graph_audit or graph_search by focusing on contradictions.

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

Usage Guidelines5/5

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

Explicitly states when to use: during reviews, before graph_decay, or when user asks about conflicts. Also suggests resolution tools (graph_weaken, graph_relate) as 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