Read graph cypher
read-graph-cypherGRAPH: 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-schemafirst 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_typeRELATED 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
EntryorLineItem. Join UP toTransactionwith OPTIONAL MATCH only if you need it.Source-system attributes (merchant name, due date, reference number, connection) →
Transactionis 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. Areversedoriginal KEEPS its line items: the reversing entry that corrects it is an ordinarypostedrow, 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.draftis 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, filterstatusexplicitly. 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', whoseamountis the account's BALANCE on that day, not a movement) and reconciliation sign-offs. When counting or summing activity, addev.event_class <> 'support', or an account's daily balances are added to its flows.Transaction.is_live⇔status <> 'void'. (Thependingboolean is also still exposed.)Factnodes (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 hasis_parentfalse and noparent_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
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Cypher read query to execute | |
| parameters | No | Optional query parameters |