Skip to main content
Glama

ISNAD · إسناد

Transmission Integrity Engine. Don't trust the quotation. Trace the transmission.

ISNAD turns 34,457 hadith reports from the six canonical collections into one Relate graph of who heard what from whom, then puts that graph between AI agents and their users: an agent cannot present a quotation as a sourced hadith unless its wording is in a stored report and the report's chain resolves.

▶ Live demo: Relate running as WebAssembly in your browser tab, nothing to install. Open Sahih al-Bukhari 1 directly.

Chain surgery on Sahih al-Bukhari 1: remove Yahya ibn Sa'id and no version survives


Use case

Language models produce fluent, plausible hadith that no collection contains, and attach real-sounding sources to them. Millions of people now ask chatbots about religious texts, and a misattributed saying is not a harmless typo.

Twelve centuries ago, hadith scholars faced the same problem with human transmitters and built a discipline to solve it: isnad criticism. Every report travels with its chain of transmitters; critics check who each transmitter was, whether they could have met, and whether a report travels by more than one route. That discipline is a graph discipline. ISNAD makes it one.

Who it is for

  • People building AI agents that touch religious text: one MCP tool, verify_quote, and the agent can only show text the store holds.

  • Students and researchers of hadith sciences: trace any report's routes across all six books, see where transmission narrows to a single narrator, and run "what if" surgery on a chain, with classical grades shown with the critic who gave them.

  • Anyone handed a quotation: paste it into the live demo and get VERIFIED, ALTERED (with the exact words added) or NOT FOUND.

Which relationships matter

  • Narrator → narrator hops of each recorded chain (who heard from whom, per report and per route).

  • The same hops aggregated into teacher → student links, each with its evidence (attested in the biographical dictionaries / recurring across collections / recorded only) and its chronology (could they have met?).

  • Report → report parallels: the same report in different collections, found by comparing their wording.

  • Narrator → critic grades, so every judgement keeps its author.

Related MCP server: Islamic Content MCP Server

Three questions only the graph can answer

Sahih al-Bukhari opens with "actions are by intentions". ISNAD finds 14 versions of it across all six books, and the graph shows its shape:

The chain tower of Sahih al-Bukhari 1

1. Where is the transmission thin? Generations 1, 2, 5 and 6 are carried by a single narrator each (Umar, Alqama, Muhammad ibn Ibrahim, Yahya ibn Sa'id), then it fans out to 12 narrators. Classically this is a gharib report at those stages, which describes scarcity, not weakness: al-Bukhari opens his Sahih with it.

Removing Malik ibn Anas: 10 of 14 versions survive

2. Whom does the evidence depend on? Remove Yahya ibn Sa'id: 0 of 14 versions keep a route (top image). Remove Malik ibn Anas: 10 of 14 survive, because other students of Yahya carried it too. Bottleneck versus redundancy, as one Cypher query. Corpus-wide, 493 of the 525 reports Yahya appears in rest on him alone.

The gate catching an inserted clause

3. Is this quotation sourced? An AI adds "and the deed most beloved to Allah is fasting" to that hadith. The gate finds the closest stored report and shows exactly which words were added. A synthetic chain-letter sentence returns NOT FOUND, never "fabricated": six books are not every book.

And a fourth the graph answers by itself: 190 teacher → student links are chronologically impossible on the recorded dates. Example: the chains have Qatada (born ~60 AH) hearing from Abu Hurayra (died 57 AH), a link classical critics also treat as broken. isnad flags lists them all.

The narrator galaxy: 6,786 narrators, generations as rings, regions as arms

The narrator galaxy: every narrator is a star. Distance from the centre is generation (Companions at the core), the arm is the region they settled in, size is how many reports pass through them. Read outward and you watch transmission leave the Hijaz for Iraq, al-Sham and Khurasan.

How it uses Relate

  • Mode: directory (data/isnad/), opened read-only by everything that queries it.

  • Why this mode: the store is the deliverable and it lives in git. Relate's directory mode checkpoints to sharded Parquet plus a small manifest: the whole graph is ~75 MB with no file near GitHub's 100 MB limit, a rebuild is a reviewable diff of manifest.json, and judges get it with git clone. The same graph is built as a single-file .rl bundle with ISNAD_STORE=isnad.rl python pipeline/build_store.py. In the browser, Relate's WebAssembly build holds the graph in memory (:memory:), loaded from web/data/, because a static page has no filesystem.

  • What the graph models: 45,016 nodes (Hadith, Narrator, Family, Collection, Compiler, Critic, City) and 574,257 relationships (TRANSMITTED, THROUGH, TAUGHT, ROOT, VERSION_OF, PARALLEL, GRADED, LIVED_IN, ...). Full model: docs/GRAPH_MODEL.md.

graph LR
  H[Hadith 34,457] -- VERSION_OF --> F[Family 3,653]
  H -- "ROOT {route}" --> N[Narrator 6,786]
  H -- "THROUGH {routes}" --> N
  N -- "TRANSMITTED {hadith, route}" --> N
  N -- "TRANSMITTED" --> P[Compiler 6]
  N -- "TAUGHT {evidence, chronology}" --> N
  N -- "GRADED {raw, rank}" --> K[Critic]
  N -- LIVED_IN --> Y[City 106]

Relate features in use

Relate capability

Where

Embedded Python library, read-only open

isnad/store.py: every CLI, MCP and test query

Cypher 25 quantified path patterns

walking one report's chain: (root) (()-[r:TRANSMITTED WHERE r.hadith = $id]->())+ (:Compiler) in queries/trace_routes.cypher

Fulltext indexes + SEARCH ... SCORE AS

the gate's candidate search over folded Arabic and English (queries/search_*.cypher)

WebAssembly build in a Web Worker

web/js/relate-worker.js: the live demo loads 44,902 nodes in seconds and runs the same query files

Directory store with Parquet checkpoints

data/isnad/, built by pipeline/build_store.py

relate CLI with --param and stdin scripts

relate query --read-only -d data/isnad --param ... < queries/x.cypher

MCP

relate serve --mcp for raw Cypher, plus ISNAD's own MCP server (isnad/mcp_server.py) for the gate and analyses

One query pack, every surface. Every analysis is a commented .cypher file in queries/. The Python package, the CLI and the MCP server run all 15, and the official relate binary runs them unchanged. The browser runs the 9 that touch the graph it loads (routes, breadth, pivots, surgery, weakest link, hop evidence, chronology, both searches) on Relate WebAssembly; the other six need data the page does not load (grades as GRADED edges, places, THROUGH).

query

question

trace_routes

every route of a report, root first

hop_evidence

what supports each hop (attested / recurrent / recorded) and whether the dates allow it

weakest_link

lowest-ranked narrator per route, on Ibn Hajar's twelve ranks

transmission_breadth

narrators per generation across all versions

pivot_narrators

narrators on every version (the madar)

chain_surgery

remove a narrator: which versions keep a route?

corpus_dependence

across 34,457 reports, which rest on one narrator alone?

chronology_flags

links the recorded dates cannot support

critics_disagree

narrators Ibn Hajar and al-Dhahabi rank far apart

search_matn_ar, search_text_en

fulltext candidates for the gate

Setup and run

1. Zero install

Open https://mohammad-umar7.github.io/isnad/. Relate (WebAssembly) loads the graph in the tab; the status bar shows each query and its time. Try the Verify samples, then Chain tower, then the surgery chips.

2. Python: CLI, gate and MCP (no API key needed)

Prerequisites: Python 3.10+ and git.

git clone https://github.com/Mohammad-Umar7/isnad && cd isnad
pip install -e ".[mcp]"

isnad stats
isnad trace "bukhari 1"
isnad breadth "bukhari 1"
isnad surgery "bukhari 1" --remove "Yahya ibn Sa'id al-Ansari"   # 0 of 14 survive
isnad surgery "bukhari 1" --remove "Malik ibn Anas"               # 10 of 14 survive
isnad depends "Yahya ibn Sa'id al-Ansari"
isnad verify "The reward of deeds depends upon the intentions and every person will get the reward according to what he has intended."
isnad flags
isnad queries                                       # the query pack
isnad cypher "MATCH (n:Narrator) RETURN count(n) AS narrators"

Add --json to any command for machine-readable output.

3. The explorer locally

node scripts/serve.mjs          # then open http://localhost:8765/web/

4. With the official Relate CLI

Install Relate (curl -sSfL https://relatedb.ai/install.sh | bash, or irm https://relatedb.ai/install.ps1 | iex on Windows), then:

relate --read-only -d data/isnad "MATCH (n:Narrator) RETURN count(n)"
relate query --read-only -d data/isnad --param family=F-SB-HD0001 --param remove=HN08272 < queries/chain_surgery.cypher
relate serve --database data/isnad --read-only --mcp 7475    # Relate's own MCP endpoint

5. In an AI agent (MCP)

The repository ships a .mcp.json, so Claude Code offers the server when you open the folder. Or add it to any MCP client:

claude mcp add isnad -- python -m isnad.mcp_server

Tools: verify_quote, trace_chain, transmission_breadth, chain_surgery, corpus_dependence, narrator_profile, chronology_flags, list_queries, run_named_query, run_cypher (read-only). The server's instructions tell the agent to quote only the stored text the gate returns. An agent skill with the same rules is in skills/isnad/SKILL.md.

6. Optional: the Claude agent demo (needs your API key)

Provider Anthropic, model claude-opus-5-5 (override with ISNAD_MODEL). Put your key in .env:

pip install -e ".[agent]"
cp .env.example .env            # set ANTHROPIC_API_KEY=...
python examples/agent_demo.py --check "The reward of deeds depends upon the intentions, and every person who fasts on Monday will get double the reward."
python examples/agent_demo.py "What did the Prophet say about intentions? Quote it with its source."

The agent must call verify_quote before presenting a hadith, and the quotations printed to the user come from the gate's stored text, never from the model's words.

7. Rebuild everything from the public sources

python pipeline/run_all.py      # about two minutes
pytest                           # 44 tests, including the Bukhari 1 facts and route identity

Where the data lives

path

what

data/isnad/

the persistent Relate store (directory mode): manifest.json, nodes/*.parquet, relationships/*.parquet, wal/

isnad.rl (release asset)

the same graph as a single-file Relate bundle, 131 MB: relate --read-only -d isnad.rl ... or ISNAD_STORE=isnad.rl isnad ...

web/data/*.json

the graph exported from the store for the in-browser explorer

queries/*.cypher

the query pack shared by every surface

data/raw/, data/derived/

downloaded sources and pipeline intermediates (git-ignored, rebuilt by pipeline/run_all.py)

How the graph is built

pipeline/run_all.py runs seven steps; details and every number in docs/METHODOLOGY.md.

  1. Parse SemanticHadith KG v2 (211 MB Turtle): 34,457 reports, 204,792 chain positions, 6,786 narrators.

  2. Parse AR-Sanad: 18,298 dictionary entries with Ibn Hajar's and al-Dhahabi's grades, dates, places and teacher lists.

  3. Link narrators across the two sources with attribute scoring plus a vote from the transmission graph itself (if X heard from Y, X's dictionary entry should list Y): 5,658 narrators linked, covering 93.4% of chain positions. A reviewed sample of 100 links found 89 correct, 11 ambiguous, 0 wrong (docs/VALIDATION.md).

  4. Find report families by comparing matn wording across all six books: 3,653 families, 2,736 spanning several collections.

  5. Repair flattened chains: 3,850 chains that merged several routes with the tahwil mark are split back into 8,927 routes, checked against the Arabic texts.

  6. Build the store with evidence levels and chronology on every link.

  7. Export for the browser.

What ISNAD does not do

  • It does not grade hadith or issue religious rulings. Grades are shown with the critic who gave them (Ibn Hajar, al-Dhahabi). Breadth, pivots and surgery describe the recorded chains in six collections.

  • NOT_FOUND never means fabricated. It means not found in these collections.

  • Paraphrases and other translations are not called alterations; the gate shows the closest stored report instead.

  • Narrator links and route repairs are probabilistic and marked with their confidence; see docs/METHODOLOGY.md § Known limits and docs/VALIDATION.md for what was checked by hand.

Built for the Relate by Neo4j Hackathon

  • New project, started 28 November 2026 during the contest period. No earlier code is reused.

  • Idea credit: "The Isnad Engine" in Michael Hunger's public Relate ideas collection. ISNAD's implementation, data pipeline, verification gate and explorer are original work.

  • Data: SemanticHadith KG v2 and AR-Sanad; licences and credits in DATA_LICENSES.md.

  • Product capabilities used: Relate 1.4.0 embedded Python library, WebAssembly build, CLI, MCP (relate serve --mcp), Cypher 25 quantified path patterns, fulltext indexes and SEARCH, directory store.

  • Third-party tools: three.js (explorer), the MCP Python SDK, the Anthropic Python SDK (optional agent demo), pytest.

  • AI tools used (as the rules ask): development was AI-assisted. Claude (Claude Code) helped write the pipeline, the engine, the explorer and the documentation; ChatGPT was used to critique the idea and the design before building. Every number in this README comes from running the pipeline and is pinned by the test suite. The verification gate itself uses no model.

Repository map

pipeline/      download → parse → link narrators → families → routes → store → web export
isnad/         the engine: store access, analyses, the gate, CLI, MCP server
queries/       the Cypher query pack (one file per question)
data/isnad/    the persistent Relate store
web/           the explorer: Relate WASM worker, three.js galaxy and tower, the gate in JS
examples/      the optional Claude agent demo
skills/isnad/  an agent skill for coding agents
tests/         unit tests for the pipeline, integration tests against the store
docs/          methodology, graph model, screenshots

MIT licensed. Data licences in DATA_LICENSES.md.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables fetching and searching canonical hadith texts (Arabic and English) with cross-references and citation-safe URLs for assistants, built on FastMCP.
      3
      GPL 3.0
    • F
      license
      A
      quality
      B
      maintenance
      A curated Islamic MCP server for AI agents. It returns Quran verses in Arabic with the Pickthall English translation, 440 du'as with source and grading where recorded, and the 99 Names of Allah. Every response instructs the agent to quote sacred text exactly. The server recognises common crisis and abuse phrasing and returns curated support resources alongside the answer.
      4
      180 npm
      -
    • A
      license
      A
      quality
      C
      maintenance
      Enables an assistant to retrieve Quranic verses in Uthmani Arabic with any of hundreds of translations, look up and search ten major hadith collections, and compute prayer times offline from the sun's position. Every quotation comes back with its exact reference so answers can be verified rather than paraphrased from memory.
      7
      MIT