Skip to main content
Glama

Read graph cypher

read-graph-cypher
Read-onlyIdempotent

GRAPH: private graph kg1a1e72efb317f7f0e470.

Execute read-only Cypher queries against the graph database.

WHEN TO USE:

  • To traverse the graph directly when no typed tool covers the question

  • Call get-graph-schema first to discover node types and relationships

RETURNS: The rows the query RETURNs, as records. Read-only: the write verbs are rejected before execution, and query complexity is monitored.

NOTES:

  • Always include LIMIT clause for large result sets

  • Use WHERE clauses to filter data effectively

  • Check for NULL values: WHERE n.property IS NOT NULL

  • Use CONTAINS for text search: WHERE n.name CONTAINS 'keyword'

  • When joining multiple relationships from the same node, use comma-separated patterns in a SINGLE MATCH clause: MATCH (n)-[:R1]->(a), (n)-[:R2]->(b) (not separate MATCH clauses)

WORKFLOW:

// Count nodes by type
MATCH (n)
WITH labels(n) AS label, count(n) AS count
RETURN label, count ORDER BY count DESC

// Explore node properties
MATCH (n:Entity) RETURN keys(n) LIMIT 1

// Find relationships between node types
MATCH (a)-[r]->(b)
RETURN DISTINCT labels(a)[0] AS from_type, type(r) AS rel_type, labels(b)[0] AS to_type

RELATED TOOLS: get-graph-schema for what is in the graph, and get-example-queries for patterns that already work against it.

⚠️ THE GRAPH LAGS THE BOOKS: this tool reads the materialized graph, which a write reaches only at the next materialization. For current state (an entry, schedule or classification just written, or "did my write land") use the typed reads (get-information-block, get-event-block, list-event-blocks, get-account-register); they read the live ledger. Use Cypher for traversal and analysis the typed reads cannot express, and check get-graph-sync-status when freshness matters.

⚠️ LEDGER TRAVERSAL ANCHOR — start at Entry, not Transaction: Transaction is NOT the top of the ledger and NOT a layer every entry passes through. It exists only where a source system had a record of the thing (QuickBooks, a bank feed) or where a manual journal entry minted one. Entry.transaction_id is nullable by design, and the schedule engine and event handlers create entries with NO parent Transaction at all — every depreciation, amortization, accrual and other period-close adjusting entry is parentless.

So this pattern silently loses data:

  • ❌ MATCH (t:Transaction)-[:TRANSACTION_HAS_ENTRY]->(e:Entry)-[:ENTRY_HAS_LINE_ITEM]->(li)

  • ✅ MATCH (e:Entry)-[:ENTRY_HAS_LINE_ITEM]->(li:LineItem)

It returns rows, raises no error, and omits every parentless entry. On a real tenant this dropped 30 of 77 entries in a month, and a depreciation-expense question anchored on Transaction returned zero rows against a real non-zero answer.

The rule:

  • Amounts, balances, "what was posted", anything accounting → anchor at Entry or LineItem. Join UP to Transaction with OPTIONAL MATCH only if you need it.

  • Source-system attributes (merchant name, due date, reference number, connection) → Transaction is the right node, because those fields live nowhere else.

  • Business occurrences ("how many X happened") → anchor at Event. Events are the canonical layer; transactions are derived from a SUBSET of them. Many events legitimately have no Transaction and no Entry.

Fact queries are unaffected — the hypercube is generated from posted entries already.

⚠️ LEDGER STATUS FILTERING (Event / Entry / Transaction / LineItem): The graph is a faithful mirror of the ledger and KEEPS cancelled and replaced rows — voided/superseded events and draft/reversed entries are NOT removed (they are real audit history). When you COUNT or AGGREGATE ledger-spine data you MUST restrict to live rows, or cancelled amounts inflate the result.

Use the materialized is_live boolean — one rule on EVERY spine node: (e:Entry) WHERE e.is_live, (li:LineItem) WHERE li.is_live, (ev:Event) WHERE ev.is_live, (t:Transaction) WHERE t.is_live. It is the safe default; prefer it over hand-writing per-node status filters (which differ by node and are easy to get wrong).

What is_live means per node (the equivalent status filter, if you need finer control):

  • Entry.is_live ⇔ status IN ('posted','reversed') (∈ {draft, posted, reversed}). Both have landed in the books. A reversed original KEEPS its line items: the reversing entry that corrects it is an ordinary posted row, so the pair nets to zero only if you sum both halves — drop the original and the balance is off by the entry, with the sign flipped. draft is excluded and covers entries of voided events.

  • LineItem.is_live ⇔ its parent Entry has landed. LineItem has no status of its own; the flag is denormalized so you can filter without joining back to Entry.

  • Event.is_live ⇔ status NOT IN ('voided','superseded') (∈ {captured, classified, committed, pending, fulfilled, voided, superseded}). It KEEPS open obligations (pending/committed/fulfilled) — for a specific realized set, filter status explicitly. It also keeps support events (event_class = 'support'): evidence about the books, not activity in them — a bank feed's daily balance readings and statement balances (event_type = 'balance_observed', whose amount is the account's BALANCE on that day, not a movement) and reconciliation sign-offs. When counting or summing activity, add ev.event_class <> 'support', or an account's daily balances are added to its flows.

  • Transaction.is_live ⇔ status <> 'void'. (The pending boolean is also still exposed.)

  • Fact nodes (the XBRL hypercube / published statements) have NO status and are already filtered at generation time — always safe to aggregate. This note applies ONLY to the ledger spine, not to Fact queries. Scope a Fact aggregate by entity ((f)-[:FACT_HAS_ENTITY]->(ent:Entity)) all the same: each entity of the group has its own facts, and a company whose report the graph received has facts under the same concepts. That company's Entity has is_parent false and no parent_entity_id.

⚠️ LEDGER AMOUNTS ARE IN DOLLARS, NOT CENTS: LineItem.debit_amount, LineItem.credit_amount, Transaction.amount and Event.amount are decimal amounts in the ledger's currency: 2835000.0 is $2,835,000.00. Report them as returned and never divide by 100. Only the close and schedule tools (list-period-drafts, schedule and allocation inputs) work in integer cents; that convention does not apply to graph queries.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "query": "<query>"
    },
    "name": "read-graph-cypher"
  }
}

Input Schema

NameRequiredDescriptionDefault
queryYesCypher read query to execute
parametersNoOptional query parameters

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.4/5.0
Behavior4/5

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

Goes well past the annotations: write verbs are rejected pre-execution, complexity is monitored, returned rows are materialized-graph state that lags writes, and cancelled/reversed rows are deliberately retained. The data-semantics disclosures (is_live per node, reversed entries keep line items, support events inflate flows, amounts are dollars not cents) are exactly the kind of context annotations cannot carry. Slightly below top marks because the mandates, while valuable, are extensive enough that the core 'what this call does' signal is diluted.

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

Conciseness4/5

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

Front-loaded with purpose, when-to-use, returns, then escalating pitfalls under clear headers and code blocks; each warning targets a concrete silent-failure mode, so most sentences earn their place. It is nonetheless very long, and the parameter-usage notes could be tightened without losing meaning.

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?

For a free-form query tool with no output schema, the description supplies the return shape (the rows the query RETURNs), the safety profile, the staleness contract, the required anchor nodes, the mandatory live-row filter, and the amount unit convention. Nothing an agent needs to compose a correct query is missing.

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% for both parameters, so query and parameters are already documented structurally. The description adds query-authoring guidance (LIMIT, WHERE, comma-separated patterns in a single MATCH) but nothing about how the optional `parameters` object interacts with the query string, which is the one genuinely under-specified parameter. Baseline 3 applies when the schema does the work.

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?

States a specific verb and resource ('Execute read-only Cypher queries against the graph database') and immediately scopes it: direct traversal for questions no typed tool covers. It is unambiguously distinct from the typed reads it names (get-information-block, get-event-block, list-event-blocks, get-account-register) and from get-graph-schema.

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?

Gives explicit when-to-use ('traverse the graph directly when no typed tool covers the question'), when-not-to-use (typed reads for current state after a write, get-graph-sync-status when freshness matters), and prerequisites (call get-graph-schema first). It even partitions use by question class: accounting amounts → Entry/LineItem, source-system attributes → Transaction, occurrence counts → Event.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.