
mizan
io.github.gamal215/mizan
Verify Quran quotes and hadith citations in Arabic content before publishing. Offline, no API key.
Documentation
Mizan · ميزان
A religious-text checker for Arabic content. Point it at a folder. It tells you which Quran quotes do not match the mushaf, which hadith are quoted with no book, number or grading, and which rakat counts or wudu steps contradict the fiqh table. Then it gives one written decision: accept, needs fix, or reject.
Built for publishing Arabic lessons, fatwa-style posts and Islamic educational content. It also runs as an MCP server, so an AI agent can verify a verse before it writes one.

The problem
Arabic religious content is published with one recurring, expensive mistake: a verse quoted with the wrong word. A single changed letter is no longer a typo, it is a misquote of the Quran, and it stays on the internet after the author forgets about it. The same goes for a hadith quoted with no source, a weak hadith presented as authentic, or a lesson that says "Maghrib is four rakats".
Manual review does not scale. Nobody re-reads 6,236 verses and 34,153 hadith every time a lesson file changes. And when the text is drafted by an AI assistant, wrong wording is not rare, it is normal: models reproduce famous verses from memory and drift.
Mizan makes the check mechanical, and leaves the judgment to a person.
What it does
One command:
node bin/mizan.mjs check ./content
- Extracts every religious text unit from your files (Markdown, plain text, HTML, JSON, JavaScript): verses between ﴿﴾ or «», hadith attributed to the Prophet ﷺ, rakat counts, wudu sequences.
- Matches each verse word for word against the mushaf after stripping diacritics, and prints the difference word by word.
- Documents each hadith: finds it in the six books, gives book, number and grading, and proposes the citation when it is missing.
- Reviews fiqh basics: obligatory rakat counts, wudu step order, adhan phrase count.
- Decides: accept / needs fix / reject, with a dated report naming each reviewer and its sources.
Install
Node.js 18 or newer. No dependencies.
git clone https://github.com/gamal215/mizan.git
cd mizan
node bin/mizan.mjs check ./content
Both corpora ship in the repo, so a fresh clone works offline straight away:
data/quran.json: 6,236 verses, standard spelling plus Uthmani.data/hadith-index.json.gz: 34,153 hadith from the six books, with numbers and gradings.
To rebuild them from source instead:
npm run sources:quran -- quran-simple.json quran-uthmani.json
npm run sources:hadith
Output
Real run on examples/content, English console (--lang en):
mizan 1.1.0 — 16 text units
Quran reviewer: 1 error · 0 review · 0 note · 2 pass (21ms)
Hadith reviewer: 1 error · 0 review · 0 note · 0 pass (2ms)
Fiqh reviewer: 0 error · 2 review · 0 note · 0 pass (2ms)
Decision: REJECTED — 2 errors block publication: mismatch, missing-source
[ERROR] mismatch sample.md:11
quote: وَإِلَى الْأَرْضِ كَيْفَ بُسِطَتْ
reference: الغَاشِيَةِ 88:20
canonical: وَإِلَى الْأَرْضِ كَيْفَ سُطِحَتْ
Quoted verse does not match the mushaf (1 difference)
fix: Use the canonical text: وَإِلَى الْأَرْضِ كَيْفَ سُطِحَتْ
[ERROR] no source sample.md:19
quote: إنما الأعمال بالنيات وإنما لكل امرئ ما نوى
reference: الموجود في المدونة: صحيح البخاري 1
Hadith is in the six books but is quoted with no book, number or grading
fix: Add the citation: book, number and grading
The same report in Arabic, Markdown and JSON:
node bin/mizan.mjs check ./content --md report.md --json report.json --audit audit/
Options
| Option | Meaning |
|---|---|
--md report.md | Full Markdown report |
--json report.json | Full report as JSON |
--audit audit/ | Dated, signed audit trail (JSON + Markdown) |
--only quran,hadith,fiqh | Run selected reviewers only |
--lang ar|en | Console language (default ar) |
--quiet | Print the decision only |
--fail-on-error | Exit 1 on any error, for CI before you publish |
node bin/mizan.mjs committee # list the reviewers and their declared sources
node bin/mizan.mjs sources # status of the bundled source files
MCP server: let an AI verify before it writes
mcp/server.mjs speaks the Model Context Protocol over stdio. No dependencies, no API key, no network: the corpora are local.
In the official MCP Registry as io.github.gamal215/mizan. Install without cloning:
- One-click bundle: mizan.mcpb (6.3 MB, corpora included, works offline) in Claude Desktop or any MCPB client.
- Or from the registry with
mcp-publisher/ any registry-aware client.
To run it from a clone instead:
{
"mcpServers": {
"mizan": {
"command": "node",
"args": ["/absolute/path/to/mizan/mcp/server.mjs"]
}
}
}
That block goes in claude_desktop_config.json (Claude Desktop), .cursor/mcp.json (Cursor), or the equivalent config of any MCP client.
Four tools:
| Tool | What it does |
|---|---|
check_text | Full committee run over a string. Returns the decision and one finding per problem. |
check_path | Same, over a file or folder on the machine running the server. |
verify_verse | One quote against the mushaf. Returns surah:ayah, the canonical wording, and a word-level diff. |
verify_hadith | One hadith against the six books. Returns book, number, grading and canonical text. |
Example, asking any MCP-capable model: "Use mizan to verify this verse before you publish: وإلى الأرض كيف بسطت" returns
{
"status": "mismatch",
"reference": "سورة الغَاشِيَةِ 88:20",
"canonical": "وَإِلَى الْأَرْضِ كَيْفَ سُطِحَتْ",
"purity": 0.75,
"diff": [{ "kind": "word-changed", "reference": "سطحت", "quote": "بسطت" }]
}
Setup details and per-client notes: docs/MCP.md.
Use it from code
import { loadQuran, findQuote } from './src/sources/quran.mjs';
const quran = loadQuran();
const r = findQuote(quran, 'وإلى الأرض كيف سُطِحَت');
// { status: 'exact', surahName: 'الغَاشِيَةِ', surah: 88, ayah: 20, ... }
The committee
| Reviewer | What it checks | Declared sources |
|---|---|---|
| Quran reviewer | Word-for-word match for every Quran quote, catching missing, extra and changed letters | Standard mushaf text plus Uthmani spelling (api.alquran.cloud, pinned in data/quran.json) |
| Hadith reviewer | Book, number and grading, plus wording against the corpus | The six books with their texts and the scholars' gradings (fawazahmed0/hadith-api, sunnah.com texts, 34,153 hadith) |
| Fiqh reviewer | Obligatory rakat counts, wudu order, adhan phrase count | Bidayat al-Mujtahid, al-Majmu', al-Mughni, al-Fiqh 'ala al-Madhahib al-Arba'a, Dar al-Ifta al-Misriyya |
| Coordinator | Collects the reports and issues one decision | The written rule in docs/COMMITTEE.md |
Every report records its date, each reviewer and each source, so the trail survives: who checked, when, and on what basis.
Decision rules
| Decision | When |
|---|---|
| Reject | A verse does not match the mushaf, a hadith has no source/number/grading, or the hadith is not in the six books |
| Needs fix | Something needs a human eye: different hadith wording, a number that does not match the corpus numbering, a rakat count that contradicts (and might be a true/false question) |
| Accept | None of the above |
Limits, stated plainly
- Not a substitute for a scholar. It measures matching and documentation. It does not derive rulings or pick between madhahib.
- Uthmani script: matching runs on the standard spelling, the Uthmani spelling is shown for reference.
- Hadith: "found in the corpus" means the wording exists there. It is not a verdict on authenticity. Gradings are quoted from the corpus with the scholar's name.
- Numbering: corpus numbering can differ from sunnah.com in some books (Muslim especially), so a number mismatch is logged as a review, not an error.
- Fiqh: the table is limited to points the majority agrees on. Disputed points go to human review, never settled automatically.
- Extraction: text not written as an explicit quote (﴿﴾ or «») is found by word matching, so a very short quote can slip through.
- The tool reports, a person decides. It shows the place, the text and the correction. Publishing is your call.
العربية
ميزان لجنة مراجعة آلية للنصوص الدينية: تطابق الآيات حرفيًا مع المصحف، وتوثّق الأحاديث من الكتب الستة، وتراجع الركعات وترتيب الوضوء، وتطلّع قرارًا واحدًا: مقبول / يحتاج تصحيح / مرفوض. تعمل على مجلد محتوى بأمر واحد، وتعمل كذلك MCP server يستخدمه أي مساعد ذكي قبل أن يكتب آية.
node bin/mizan.mjs check ./content
الشرح الكامل بالعربي: README.ar.md · أعضاء اللجنة وقاعدة القرار: docs/COMMITTEE.md · المصادر وحدودها: docs/SOURCES.md
License
MIT. Use it, fork it, publish with it. © جمال أيمن · Gamal Ayman
https://github.com/gamal215/mizan/releases/download/v1.1.0/mizan.mcpb# mcpb: https://github.com/gamal215/mizan/releases/download/v1.1.0/mizan.mcpb