Skip to main content
Glama
This connector has been deprecated

Find a hadith or the books that carry it

shamela_lookup_hadith
Read-onlyIdempotent

Hadith. 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

NameRequiredDescriptionDefault
modeNoSelects what the call does: search | sources. Default search.
limitNoMaximum number of results to return (1-100, default 20). (mode=search only.)
queryNoThe 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_keyNoNumeric 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_onlyNoIf 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_formatNoFormat 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_scannedNoHow 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_categoriesNoSearch 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

NameRequiredDescriptionDefault
queryNoThe query as received. (mode=search only.)
totalNoDistinct books carrying the key, installed or not. (mode=sources only.)
matchesNoMatching 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.)
relaxedNoPresent when the full text matched nothing and one word was dropped. (mode=search only.)
resultsNoOne row per book, in index order, with its first page for the hadith. (mode=sources only.)
takhrijNoCross-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.)
returnedNoRows in `results` after downloaded_only. (mode=sources only.)
searchedNo'hadith_shelves' (default) or 'whole_library' (search_all_categories). (mode=search only.)
truncatedNo
hadith_keyNo (mode=sources only.)
rows_droppedNo
index_entriesNoRaw index rows behind `total`. (mode=sources only.)
pages_scannedNoTop matches read for hadith keys (<= max_pages_scanned). (mode=search only.)
books_searchedNoBooks the text search covered: the hadith shelves (كتب السنة، شروح الحديث، التخريج والأطراف، علوم الحديث), 1,957 here. (mode=search only.)
key_index_booksNoBooks 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_matchesNoEvery page matching the text in the searched shelves. (mode=search only.)
truncation_messageNo
takhrij_from_key_indexNoTrue when the matched pages carried no hadith key and takhrij came from re-running the query inside the key-indexed books. (mode=search only.)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Added

TDQS

A4.8/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With readOnly/idempotent/non-destructive annotations already covering the safety profile, the description adds real behavioral depth: no offset, automatic one-word relaxation surfaced in `relaxed`, takhrij limited to key_index_books, SERVICE_KEY_NOT_FOUND semantics, and the downloaded:false catalogue-vs-installed distinction. These are constraints the agent cannot infer from annotations or schema alone.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loads the mode distinction and the highest-value caveats (no offset, takhrij scope) before the sibling routing. It is dense and slightly clause-heavy in places, and a few lines overlap with schema text, but no sentence is filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For an 8-parameter, dual-mode, read-only lookup with an output schema present, the description covers what the schema cannot: mode semantics, result-window interaction, known error codes, and edition-availability caveats. Return values are correctly left to the output schema, so nothing an agent needs before calling is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is already 100%, so the baseline is 3, but the description contributes genuine cross-parameter reasoning the schema does not: that max_pages_scanned is 'the only result window' and `matches` never exceeds it regardless of `limit`, and that limit only cuts after key-bearing pages come first. It also explains the response_format='none' budget tradeoff between text and structuredContent.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb and resource ('Find a hadith ... trace its takhrij') and splits the tool's two distinct behaviors (mode=search vs mode=sources) with concrete outputs for each. An agent can distinguish it from shamela_search and shamela_lookup_rijal purely from this text, since the description names those siblings and the boundary conditions that select between them.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit routing guidance: narrator chains go to shamela_lookup_rijal(mode='isnad_search'), general text to shamela_search(match='words'), missing editions to shamela_get_details(kind='book'). It also states when to flip search_all_categories (to find who CITES vs who NARRATES) and when the sparse takhrij result should not be over-interpreted.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources