Search and explore the Holy Qur'an with Arabic text, transliteration, and advanced search support.
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent โ or use 1-click editor setup below.
๐ก Paste into ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows)
Alfanous is a Quranic search engine API that provides simple and advanced search capabilities for the Holy Qur'an. It enables developers to build applications that search through Quranic text in Arabic, with support for Buckwalter transliteration, advanced query syntax, and rich metadata.
Install from PyPI using pip:
You can also use the public web service:
Or run your own web service locally (see alfanous_webapi).
Search for phrases:
Boolean search (AND, OR, NOT):
Fielded search:
Wildcard search:
Faceted search (aggregate by fields):
api.search(query, **options) - Search Quran versesapi.do(params) - Unified interface for all actions (search, suggest, show, list_values, correct_query)api.correct_query(query, unit, flags) - Get a spelling-corrected version of a queryapi.get_info(category) - Get metadata informationThe underlying Raw output engine is exposed as Engine in alfanous.api (and re-exported from alfanous directly). Use it as a context manager to ensure index resources are properly released:
Common parameters for api.do() with action="search":
query (str): Search query (required)unit (str): Search unit - "aya", "word", or "translation" (default: "aya")page (int): Page number (default: 1)perpage (int): Results per page, 1-100 (default: 10)sortedby (str): Sort order - "score", "relevance", "mushaf", "tanzil", "ayalength" (default: "score")reverse (bool): Reverse the sort order (default: False)view (str): Output view - "minimal", "normal", "full", "statistic", "linguistic" (default: "normal")highlight (str): Highlight style - "css", "html", "bold", "bbcode" (default: "css")script (str): Text script - "standard" or "uthmani" (default: "standard")vocalized (bool): Include Arabic vocalization (default: True)translation (str): Translation ID to includerecitation (str): Recitation ID to include (1-30, default: "1")fuzzy (bool): Enable fuzzy search โ searches both aya_ (exact) and aya (normalised/stemmed) fields, plus Levenshtein distance matching (default: False). See Exact Search vs Fuzzy Search.fuzzy_maxdist (int): Maximum Levenshtein edit distance for fuzzy term matching โ 1, 2, or 3 (default: 1, only used when fuzzy=True).facets (str): Comma-separated list of fields for faceted searchfilter (dict): Filter results by field valuesFor a complete list of parameters and options, see the detailed documentation.
Alfanous provides two complementary search modes that control which index fields are queried.
fuzzy=False)When fuzzy search is off (the default), queries run against the aya_ field, which stores the fully-vocalized Quranic text with diacritical marks (tashkeel) preserved. This mode is designed for precise, statistical matching:
ู
ููููู and ู
ูุงูููู are treated as different words.fuzzy=True)When fuzzy search is on, queries run against both the aya_ field (exact matches) and the aya field (a separate index built for broad, forgiving search). At index time the aya field is processed through a richer pipeline:
pystemmer), so different morphological forms of the same root match each other.No heavy operations are performed on the query string at search time; all the linguistic enrichment lives in the index.
Additionally, for each Arabic term in the query, a Levenshtein distance search is performed against the aya_ac field (unvocalized, non-stemmed). This catches spelling variants and typos within a configurable edit-distance budget controlled by fuzzy_maxdist.
fuzzy_maxdist | Behaviour |
|---|---|
1 (default) | Catches single-character insertions, deletions, or substitutions |
2 | Broader tolerance โ useful for longer words or noisy input |
3 | Maximum supported โ use with care as recall increases significantly |
Fuzzy mode is particularly useful when:
Note:
pystemmermust be installed for stemming to take effect (pip install pystemmer). If the package is absent the stem filter degrades silently to a no-op, leaving normalisation and stop-word removal still active.
list_values returns every unique indexed value for a given field. Use it to discover the full vocabulary of searchable fields โ for example, all available translation identifiers, part-of-speech tags, or root words โ before composing a query.
Parameters:
field (str): The name of the indexed field whose unique values you want (required).Return value:
A dictionary with a list_values key containing:
field โ the requested field name.values โ sorted list of unique non-empty indexed values.count โ length of the values list.correct_query() uses Whoosh's built-in spell-checker to compare each term in the query against the index vocabulary and replace unknown terms with the closest known alternative. When the query is already valid (all terms appear in the index) the corrected value in the response is identical to the original input.
Parameters:
query (str): The raw query string to correct (required).unit (str): Search unit โ currently only "aya" is supported; other units return None (default: "aya").flags (dict): Optional dictionary of additional flags.Return value:
A dictionary with a correct_query key containing:
original โ the input query string as provided.corrected โ the corrected query string; identical to original when no correction is needed.Alfanous supports advanced query syntax:
"ุงูุญู
ุฏ ููู"+ - ุงูุตูุงุฉ + ุงูุฒูุงุฉ| - ุงูุตูุงุฉ | ุงูุฒูุงุฉ- - ุงูุตูุงุฉ - ุงูุฒูุงุฉ* for multiple chars, ? for single char - *ูุจู*, ูุนู
ุุณูุฑุฉ:ูุณ, ุณุฌุฏุฉ:ูุนู
[X ุงูู Y] - ุฑูู
_ุงูุณูุฑุฉ:[1 ุงูู 5]ุขูุฉ_:'ู
ูู'> - >ุฑุญูู
(searches aya_stem โ corpus-derived stem)>> - >>ุฑุญูู
(searches aya_lemma โ all inflections of the same lexeme)>>> - >>>ู
ูู (searches aya_root โ all words from the same root){root,type} - {ูููุุงุณู
}Control how broadly the search expands morphologically using the derivation_level parameter:
| Level | Value | Index field | Description |
|---|---|---|---|
| 0 | "word" | aya | Exact match only (default) |
| 1 | "stem" | aya_stem | Corpus-derived stem โ words sharing the same morphological stem |
| 2 | "lemma" | aya_lemma | Corpus lemma โ all inflections of the same lexeme |
| 3 | "root" | aya_root | Trilateral root โ all words from the same root |
Each derivation field is pre-indexed at build time so queries run against a compact, pre-computed representation rather than expanding at search time.
The derivation syntax >word, >>word, >>>word maps to levels 1, 2, 3 respectively and can be embedded directly in queries:
unit="word")When unit="word" the engine searches word-level child documents instead of verse-level parent documents. Each word child carries its full morphological annotation โ part-of-speech, lemma, stem, root, pattern, gender, number, person, voice, mood, derivation level, and more.
search_by_word_linguistics)Filter words by any combination of morphological properties using the search_by_word_linguistics action:
Available morphological filter fields include: pos, type, root, lemma, stem, pattern, gender, number, person, voice, mood, state, case, form, aspect, derivation, special, prefix, suffix, segments.
Faceted search allows you to aggregate search results by fields:
Available facet fields:
sura_id - Sura (chapter) number (1-114)juz - Juz (part) number (1-30)hizb - Hizb (section) numberchapter - Main topic/chaptertopic - Subtopicsura_type - Meccan/Medinan classificationFilter search results by field values:
Available fields for fielded search:
ุณูุฑุฉ (sura) - Sura nameุฑูู
_ุงูุณูุฑุฉ (sura_id) - Sura numberุฑูู
_ุงูุขูุฉ (aya_id) - Verse numberุฌุฒุก (juz) - Juz numberุญุฒุจ (hizb) - Hizb numberุตูุญุฉ (page) - Page number in Mushafุณุฌุฏุฉ (sajda) - Has prostrationู
ูุถูุน (subject) - Subject/themeูุตู (chapter) - Chapterุจุงุจ (subtopic) - Subtopicููุน_ุงูุณูุฑุฉ (sura_type) - Sura type (Meccan/Medinan)Word-level fields (use with unit="word"):
englishstate - Nominal state in English (e.g. "Definite state", "Indefinite state")englishmood - Verb mood in English (e.g. "Indicative mood", "Subjunctive mood", "Jussive mood")For the complete field list, call:
Different views provide different levels of detail:
Example:
Get various metadata using the "show" action:
Note: Lemmas are no longer exposed via
show. Useapi.do({"action": "list_values", "field": "lemma"})to retrieve them on demand.
You can extend the local search index with additional Zekr-compatible .trans.zip translation files using index_translations(). This requires the alfanous_import package (included in the repository under src/alfanous_import/).
The function:
*.trans.zip file in source0 means nothing new was added)configs/translations.json so the new translations are immediately visible via api.get_info("translations") and searchable with unit="translation"After indexing, search in the new translation:
See examples/index_translations_example.py for a complete walkthrough.
The examples/ directory contains example scripts demonstrating various features:
See examples/README.md for more information.
Alfanous ships an MCP (Model Context Protocol) server that lets AI assistants (Claude, Copilot, etc.) search and explore the Qur'an directly. See alfanous_mcp/README.md for the full reference.
Quick start:
To connect Claude Desktop, add the following to your claude_desktop_config.json:
Alfanous includes a FastAPI-based web service for RESTful access. See alfanous_webapi/README.md for:
Quick start:
Then visit http://localhost:8000/docs for interactive documentation.
We welcome contributions! See CONTRIBUTING.md for:
Quick development setup:
Alfanous is licensed under the GNU Lesser General Public License v3 or later (LGPLv3+).
See LICENSE for details.
This project handles sacred religious text (the Holy Qur'an) - please treat the data and code with respect.
If you are looking for the legacy Alfanous code, you can find it under the legacy branch.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/alfanous-quranic-search-engine)<a href="https://allmcps.com/mcp/alfanous-quranic-search-engine"><img src="https://allmcps.com/api/badge/alfanous-quranic-search-engine?style=directory" alt="Alfanous Quranic Search Engine on AllMCPs" /></a>