Skip to main content
Glama

Graph Contradictions

graph_contradictions
Read-only

Detect pairs of facts connected by a CONTRADICTS edge in your knowledge graph. Use to review unresolved contradictions before consolidation or to audit historical resolutions.

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 with the MCP server, including schema definition (include_resolved flag), description, and readOnlyHint annotation.
    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)}`);
      }
    });
  • Handler function for graph_contradictions — calls client.findContradictions(currentTenant(), includeResolved) and returns the result.
    }, 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 Neo4jClient.findContradictions() method — queries the Neo4j graph for CONTRADICTS edges, optionally filtering to unresolved only, returning node_a, node_b, description, detected_date, and resolved status.
    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 };
    }
  • CONTRADICTS is defined as a relationship type constant in the RELATIONSHIP_TYPES array.
    "CONTRADICTS",
Behavior5/5

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

Annotations (readOnlyHint: true) indicate a read-only operation, and the description adds detailed behavioral traits: returns structured data (contradictions array with fields), ordered by recency, defaults to unresolved, and offers include_resolved option. No contradictions with annotations.

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 concise with three sentences, front-loads the main purpose, then provides usage guidance and parameter detail. No redundant information.

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 covers the return structure, ordering, default behavior, and resolution guidance. It is complete for this simple read-only tool.

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

Parameters5/5

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

The single parameter 'include_resolved' is fully described in the schema with default and description. The description adds context by explaining the default behavior and when to use the parameter (auditing historical resolutions), adding value beyond the 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?

The description clearly defines the tool as finding contradictory fact pairs in the memory graph via CONTRACTS edges. It uses specific verbs and resources, distinguishing from sibling tools like graph_audit or graph_validate.

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 states when to use: during reviews, before graph_decay, or on user request for conflicting info. It also suggests resolution tools (graph_weaken, graph_relate), but does not explicitly state when not to use.

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