Find a hadith or the books that carry it
shamela_lookup_hadithHadith. mode=search (default): find a hadith by its wording and trace its takhrij — searches the hadith shelves (Sunnah collections, commentaries, takhrij, hadith sciences) in matn and footnotes, reads hadith keys off the matching pages and lists every collection indexing the same hadith. No offset; if the full text matches nothing, one word is dropped and named in relaxed. Takhrij covers only key_index_books, so few rows is not proof of a weak or rare hadith.
mode=sources: every book recording one hadith_key, with its page_id, one row per book in index order.
A downloaded:false book is catalogued but not installed: use another edition (shamela_get_details(kind='book') same_group). Narrator chains → shamela_lookup_rijal(mode='isnad_search'); general text → shamela_search(match='words').
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "shamela_lookup_hadith"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | No | Selects what the call does: search | sources. Default search. | |
| limit | No | Maximum number of results to return (1-100, default 20). (mode=search only.) | |
| query | No | The hadith text (or a distinctive part of it). AND-combines words across matn + footnotes. Hadith keys come from each matching page's service annotations, takhrij from hadeeth.db. E.g. {query:'إنما الأعمال بالنيات'}. (mode=search only.) | |
| hadith_key | No | Numeric hadith key (the normalized identifier Shamela uses across collections — e.g. 1234). Different collections of the same hadith share this key. Take it from shamela_lookup_hadith(mode='search'), shamela_read(unit='services'), or the `hadeeth_key` of a chain from shamela_lookup_rijal(mode='isnad') / shamela_lookup_rijal(mode='isnad_search') (a string there; pass it as a number). Read from Shamela's pre-built service/hadeeth.db join, for cross-collection research (Bukhari, Muslim, the Sunan and Musnad references of one hadith); read each page with shamela_read(unit='page'). One row per book, in index order; `total` counts all, `returned` only those installed here unless downloaded_only:false. SERVICE_KEY_NOT_FOUND: no book has the key. Example: {hadith_key:1}. (mode=sources only.) | |
| downloaded_only | No | If true (default), only return books whose text is installed on this server. false also lists catalogue-only editions (downloaded:false); `total` counts both either way. (mode=sources only.) | |
| response_format | No | Format of the human-readable text: 'markdown' (default) for display; 'json' the same data as one JSON code block; 'none' only a one-line pointer, leaving structuredContent as the whole answer. structuredContent is always returned, so a caller that parses it should pass 'none': the character budget counts both channels, and the unread copy otherwise spends most of it. Requires the 'response_format.none' capability (see shamela_get_brief). | |
| max_pages_scanned | No | How many top text matches (by relevance) to scan for hadith service keys. This is the only result window: `matches` never exceeds it whatever `limit` says, and there is no offset. Default: 20. Raise it for a common wording. Key-bearing pages come first, then `limit` cuts. (mode=search only.) | |
| search_all_categories | No | Search the ENTIRE library instead of the hadith shelves (كتب السنة، شروح الحديث، التخريج، علوم الحديث). Off by default because unscoped ranking buries the collections under works that merely quote the hadith. Turn on to find who CITES a hadith (e.g. in fiqh or tafsir) rather than who NARRATES it. (mode=search only.) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | No | The query as received. (mode=search only.) | |
| total | No | Distinct books carrying the key, installed or not. (mode=sources only.) | |
| matches | No | Matching pages, key-bearing first: book_id, book_name, page_id, snippet (often showing the printed takhrij, «رواه البخاري ومسلم»), snippet_source ('matn' | 'footnote'), matched_in, hadith_keys (read from the page's service annotations). (mode=search only.) | |
| relaxed | No | Present when the full text matched nothing and one word was dropped. (mode=search only.) | |
| results | No | One row per book, in index order, with its first page for the hadith. (mode=sources only.) | |
| takhrij | No | Cross-collection takhrij per hadith key. Drawn only from key_index_books, so few rows is not proof of a weak or rare hadith. (mode=search only.) | |
| returned | No | Rows in `results` after downloaded_only. (mode=sources only.) | |
| searched | No | 'hadith_shelves' (default) or 'whole_library' (search_all_categories). (mode=search only.) | |
| truncated | No | ||
| hadith_key | No | (mode=sources only.) | |
| rows_dropped | No | ||
| index_entries | No | Raw index rows behind `total`. (mode=sources only.) | |
| pages_scanned | No | Top matches read for hadith keys (<= max_pages_scanned). (mode=search only.) | |
| books_searched | No | Books the text search covered: the hadith shelves (كتب السنة، شروح الحديث، التخريج والأطراف، علوم الحديث), 1,957 here. (mode=search only.) | |
| key_index_books | No | Books hadeeth.db indexes hadith keys for (ten here); takhrij can only come from these, so a hadith on 1,746 pages can still yield takhrij from ten books. (mode=search only.) | |
| total_text_matches | No | Every page matching the text in the searched shelves. (mode=search only.) | |
| truncation_message | No | ||
| takhrij_from_key_index | No | True when the matched pages carried no hadith key and takhrij came from re-running the query inside the key-indexed books. (mode=search only.) |