Skip to main content
Glama
This connector has been deprecated

Search page text (body and footnotes)

shamela_search_pages
Read-onlyIdempotent

بحث في صفحات الكتب

Search the body (matn) and footnotes (الحواشي) of every Shamela page the user has downloaded locally. AND-combines tokens; each token can match in any of the search_in fields. Default scope is the full downloaded library; pass scope (book_ids/author_ids/category_ids/period_*/downloaded_only/madhab/book_type/citable_only) to narrow. scope.madhab ('hanafi'|'maliki'|'shafii'|'hanbali') answers a school-specific fiqh question — it uses Shamela's school categories AND the main author's school, so it reaches مسائل فقهية and الفقه العام where no school is filed; books whose school is unknown are excluded, so leave it unset for comparative questions. scope.book_type excludes what is not an authored book (transcript/thesis/journal/electronic/manuscript), and scope.citable_only keeps only books whose page numbers match a real printed edition — set it whenever the answer will quote a page as a citation. options controls morphology (Arabic root expansion via AlKhalil — NOTE Arabic roots are ambiguous and the analyzer keeps every reading, so «كتب» also searches تبب/توب/وتب, i.e. perdition and repentance; the response returns morphology_expanded_to naming exactly what was searched, and results are a SUPERSET of the word you asked for), wildcards (*/? per token, cannot combine with morphology), and search_in subset (body/foot). Returns total_hits + paginated results with book name, author, printed-page label, and a snippet with ... around matches; coverage rolls up by category/century/book/author — EXACT (every matching page counted) whenever coverage.sample_is_complete is true, and otherwise a top-scoring sample of coverage.sampled_hits of total_hits, whose shares are then indicative rather than a census. by_category/by_century cover the whole sample; by_book/by_author are the largest coverage.top_n only, so they do not sum to it. Plus edition_groups whenever hits landed in two or more catalog entries of one work (several editions of the same book) — read those as one source, not several. preserve_diacritics/_hamza/_digits return OPTION_NOT_SUPPORTED here — use shamela_search_exact for those. Use shamela_search_titles for chapter title search instead. Examples: shamela_search_pages({query:'الكلام'}), shamela_search_pages({query:'استصناع', scope:{category_ids:[17]}}), shamela_search_pages({query:'كلم', options:{morphology:true}}).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of results to return (1-100, default 20).
queryYesArabic search phrase. Multiple words are AND-combined; each can match in body or footnotes. If a word does not exist in the library under the spelling you used, the spelling the books DO use is searched instead and reported in `respelled_terms` — say so when you quote the result, because the source writes the word differently.
scopeNoRestrict the search to specific books, authors, categories, or a Hijri date range. Use shamela_list_categories / shamela_resolve to find IDs.
shapeNoHow much of each hit to return. 'full' (default) is every field on every row, including the snippets — ask for this when the answer will QUOTE the page. 'brief' keeps book_id/page_id, printed_page, match_quality and matched_in_section and hoists book metadata into a top-level `books` dictionary keyed by book_id, but carries NO snippet: it answers which pages these are, how well each matched and how to cite them, for a fraction of the characters, so far more rows survive the budget. 'index' returns book_id/page_id only, for choosing what to read before paying to read it. Requires the 'shape.full_brief_index' capability (see shamela_brief).full
offsetNoNumber of results to skip for pagination. Use with `limit` to page through large result sets. The response includes `has_more` and `next_offset` to drive paging.
optionsNoSearch options: morphology, wildcards, sort, search_in (body/foot), relax_when_empty. Defaults to body+foot, no toggles. preserve_* redirect to shamela_search_exact.
exclude_pagesNoExact pages to keep out — the pages a previous round already returned. Excluding these rather than whole books is what lets a follow-up search find MORE evidence in a book that has already contributed some.
response_formatNoOutput format for the human-readable text. 'markdown' (default) is best for direct display; 'json' returns the same data as a single JSON code block; 'none' skips the rendered text entirely and returns a one-line pointer, leaving `structuredContent` as the whole answer. The structured data is returned in `structuredContent` regardless of this setting, so a caller that parses it should pass 'none' — the character budget is measured over BOTH channels, and the unread copy is otherwise spending most of it. Requires the 'response_format.none' capability (see shamela_brief).markdown
exclude_book_idsNoBook ids to keep out of the results entirely.
exclude_author_idsNoExclude every book by these authors.
exclude_category_idsNoExclude every book on these shelves.
exclude_work_group_idsNoExclude every catalogue entry of these works — all printings at once. This is the one to use after a round returned «صحيح البخاري - ط السلطانية»: excluding that book_id alone leaves the other seven entries of group 1681 free to return the same text again as if it were a second source.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
booksNo
queryNo
offsetNo
resultsNo
coverageNo
has_moreNo
returnedNo
truncatedNo
total_hitsNo
next_offsetNo
scope_countNo
rows_droppedNo
paging_ceilingNo
zero_hit_termsNo
respelled_termsNo
terms_truncatedNo
relaxed_of_termsNo
scope_resolutionNo
normalized_tokensNo
relaxed_min_matchNo
truncation_messageNo
morphology_fallbackNo
unattributable_booksNo
morphology_expanded_toNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.8/5.0
Behavior5/5

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

Annotations already declare readOnly/idempotent/non-destructive, and the description goes well beyond them: it discloses that morphology yields a SUPERSET with ambiguous roots (with the كتب→تبب/توب/وتب example), that coverage is EXACT only when coverage.sample_is_complete and otherwise a top-scoring sample, that by_book/by_author are truncated to top_n so shares are non-censal, and that edition_groups are one work in several printings.

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?

Long but front-loaded, with the core scope statement first and the routing/exclusions after. Nearly every clause carries operational detail an agent needs; the main cost is some duplication of schema text, which is the only thing keeping it from a 5.

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?

With an output schema present, a 100%-covered input schema, and full annotations, the description still covers everything an agent needs to call correctly: scope semantics, morphology/wildcard caveats, citation-citability flag, response shape, coverage interpretation, and cross-tool redirects.

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 coverage is 100%, so the baseline is 3, but the description adds genuine meaning beyond the schema: it summarizes scope keys, explains the interplay of scope.madhab with school categories, warns that wildcards cannot combine with morphology, and notes preserve_* return OPTION_NOT_SUPPORTED here. It largely restates the schema's own parameter text, which caps it below 5.

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?

States a specific verb+resource (search) and scope (body/footnotes of locally downloaded Shamela pages), and explicitly distinguishes itself from siblings by naming shamela_search_exact for preserve_* options and shamela_search_titles for chapter-title search. An agent can route to it without opening another schema.

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?

Gives concrete when-to-use rules: set scope.madhab for school-specific fiqh but leave it unset for comparative questions, set citable_only whenever quoting a page, and route to shamela_search_exact/shamela_search_titles when the wrong tool would be chosen. Alternatives and exclusions are explicit, not implied.

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