{
  "notice": "bxzxxr MCP archive: a record of what public MCP servers declared when we listed them (we never call their tools). It is data, not a rating: nothing here says a server is safe, secure, verified or trustworthy, and a server can change after we looked. Secrets we detected are redacted; redacted tool lists are withheld and only their hash is shown.",
  "infrastructure": {
    "host": "qurangallery.com",
    "site": "qurangallery.com",
    "addresses": [
      {
        "address": "104.21.90.236",
        "endpoints": 5,
        "shared_infrastructure": false,
        "network": {
          "asn": 13335,
          "name": "CLOUDFLARENET - Cloudflare, Inc.",
          "prefix": "104.21.64.0/19",
          "country": "US"
        }
      },
      {
        "address": "172.67.162.174",
        "endpoints": 5,
        "shared_infrastructure": false,
        "network": {
          "asn": 13335,
          "name": "CLOUDFLARENET - Cloudflare, Inc.",
          "prefix": "172.67.160.0/20",
          "country": "US"
        }
      },
      {
        "address": "2606:4700:3037::6815:5aec",
        "endpoints": 5,
        "shared_infrastructure": false,
        "network": {
          "asn": 13335,
          "name": "CLOUDFLARENET - Cloudflare, Inc.",
          "prefix": "2606:4700:3037::/48",
          "country": "US"
        }
      },
      {
        "address": "2606:4700:3034::ac43:a2ae",
        "endpoints": 5,
        "shared_infrastructure": false,
        "network": {
          "asn": 13335,
          "name": "CLOUDFLARENET - Cloudflare, Inc.",
          "prefix": "2606:4700:3034::/48",
          "country": "US"
        }
      }
    ],
    "addresses_recorded": true,
    "address_history": [
      {
        "addresses": [
          "104.21.90.236",
          "172.67.162.174",
          "2606:4700:3037::6815:5aec",
          "2606:4700:3034::ac43:a2ae"
        ],
        "first_seen": "2026-11-24T16:06:02.483Z",
        "last_seen": "2026-11-24T16:06:02.483Z",
        "checks": 1
      },
      {
        "addresses": [
          "172.67.162.174",
          "104.21.90.236",
          "2606:4700:3034::ac43:a2ae",
          "2606:4700:3037::6815:5aec"
        ],
        "first_seen": "2026-11-22T16:05:06.736Z",
        "last_seen": "2026-11-22T16:05:06.736Z",
        "checks": 1
      }
    ],
    "hosting": [
      {
        "value": "Cloudflare",
        "evidence": "Server header \"cloudflare\""
      }
    ],
    "software": [],
    "server_info": {
      "name": "qurangallery-shamela",
      "version": "0.3.0",
      "protocol_version": "2025-06-18"
    },
    "headers": {
      "via": "1.1 Caddy",
      "server": "cloudflare",
      "access-control-allow-origin": "*"
    },
    "auth": null
  },
  "related": {
    "same_address": {
      "total": 4,
      "sample": [
        {
          "id": "31423",
          "url": "https://probe-evidence.probe-lab.workers.dev/mcp",
          "server_name": "io.github.lexbritten/probe",
          "last_state": "listed",
          "last_checked_at": "2026-11-24T00:58:01.576Z"
        },
        {
          "id": "47800",
          "url": "https://thistripbtw.us/mcp",
          "server_name": "us.thistripbtw/trips",
          "last_state": "listed",
          "last_checked_at": "2026-11-23T23:23:01.425Z"
        },
        {
          "id": "55493",
          "url": "https://mcp.draftless.dev/mcp/public",
          "server_name": "dev.draftless/draftless",
          "last_state": "listed",
          "last_checked_at": "2026-11-23T23:41:02.576Z"
        },
        {
          "id": "52994",
          "url": "https://mcp.draftless.dev/mcp",
          "server_name": "dev.draftless/draftless",
          "last_state": "auth_required",
          "last_checked_at": "2026-11-21T20:45:01.331Z"
        }
      ]
    },
    "same_site": {
      "total": 0,
      "sample": []
    },
    "same_tool_list": {
      "total": 0,
      "sample": []
    },
    "same_publisher": {
      "publisher": "com.qurangallery",
      "total": 0,
      "sample": []
    },
    "same_repository": null,
    "note": "Shared addresses on big platforms (Cloudflare, Vercel and the like) put unrelated servers together; those are marked shared_infrastructure. A match is a pivot, not a link between operators."
  },
  "endpoint": {
    "id": "14794",
    "server_name": "com.qurangallery/mcp",
    "url": "https://qurangallery.com/mcp/shamela",
    "host": "qurangallery.com",
    "transport": "streamable-http",
    "last_checked_at": "2026-11-24T16:06:02.483Z",
    "last_state": "listed",
    "last_detail": null,
    "consecutive_failures": 0,
    "current_sha": "786facefc7ddb6e7e11e1b77a1f55ccfb05fa61adca87a93e7959ce7d00cc8ce",
    "first_listed_at": "2026-11-24T16:06:02.483Z",
    "created_at": "2026-11-21T06:35:05.780Z",
    "resolved_addresses": [
      "104.21.90.236",
      "172.67.162.174",
      "2606:4700:3037::6815:5aec",
      "2606:4700:3034::ac43:a2ae"
    ]
  },
  "server": {
    "name": "com.qurangallery/mcp",
    "title": "Quran Gallery MCP",
    "description": "Classical Islamic library (Shamela, 8,594 books): verbatim Arabic cited by volume and page. No key.",
    "version": "0.3.0",
    "registry_status": "active",
    "repository_url": null,
    "website_url": "https://qurangallery.com/mcp",
    "published_at": "2026-10-16T09:18:29.842Z",
    "updated_at": "2026-10-16T09:18:29.842Z",
    "first_seen": "2026-11-21T06:35:05.116Z"
  },
  "other_endpoints": [],
  "intel": {
    "capabilities": [],
    "evm_addresses": [],
    "chains": [],
    "tokens": [],
    "computed_at": "2026-11-24T16:06:09.100Z"
  },
  "operator": {
    "key": "qurangallery.com",
    "name": "qurangallery.com",
    "platform": false,
    "marketplace": false
  },
  "needs_sign_in": false,
  "reachability": {
    "window_days": 30,
    "checks": 3,
    "answered": 1,
    "answered_percent": 33,
    "avg_listing_latency_ms": 555,
    "first_check_in_window": "2026-11-21T10:32:00.669Z",
    "consecutive_failures_now": 0,
    "days": [
      {
        "day": "2026-11-21",
        "checks": 1,
        "answered": 0,
        "last_state": "error"
      },
      {
        "day": "2026-11-22",
        "checks": 1,
        "answered": 0,
        "last_state": "error"
      },
      {
        "day": "2026-11-24",
        "checks": 1,
        "answered": 1,
        "last_state": "listed"
      }
    ]
  },
  "tool_list": {
    "sha256": "786facefc7ddb6e7e11e1b77a1f55ccfb05fa61adca87a93e7959ce7d00cc8ce",
    "tools": 15,
    "resources": 1,
    "prompts": 3,
    "first_seen": "2026-11-24T16:06:03.042Z",
    "tool_names": [
      "shamela_search_library",
      "search",
      "fetch",
      "shamela_verify_quote",
      "shamela_search",
      "shamela_find",
      "shamela_read",
      "shamela_get_details",
      "shamela_cite",
      "shamela_lookup_quran",
      "shamela_lookup_tafsir",
      "shamela_lookup_hadith",
      "shamela_lookup_rijal",
      "shamela_survey_topic",
      "shamela_get_brief"
    ],
    "declared": {
      "tools": [
        {
          "name": "shamela_search_library",
          "title": "Search the classical Islamic library",
          "description": "Search one named shelf of the classical Islamic library (8,594 works) for quotable passages: verbatim Arabic with book, author, printed volume/page, edition and a link to the page in the Quran Gallery Maktabah reader. The default first search for hadith, tafsir, fiqh or creed. Not for isnads, narrators or diacritic-exact wording. Use shamela_search (match \"words\") to pin books or categories or to page past 10 results, shamela_read (unit \"page\") to read a whole page. Scope is one shelf per call; call again with another shelf to widen. Ranking: exact phrase first, then all the words; a madhhab scope asks that school's own books first; main text before footnote. relaxedToTokens and note flag a weaker match; no passages means absent from that scope, not from the library. A non-Arabic query or unknown scope returns a tool error naming the fix.",
          "inputSchema": {
            "type": "object",
            "required": [
              "query",
              "scope"
            ],
            "properties": {
              "limit": {
                "type": "integer",
                "default": 5,
                "maximum": 10,
                "minimum": 1,
                "description": "Maximum passages to return (max 10)."
              },
              "query": {
                "type": "string",
                "description": "Arabic search text. A quoted wording works best; a topic also works."
              },
              "scope": {
                "enum": [
                  "hadith-primary",
                  "tafsir-canonical",
                  "fiqh-hanafi",
                  "fiqh-maliki",
                  "fiqh-shafii",
                  "fiqh-hanbali",
                  "fiqh-comparative",
                  "aqeedah",
                  "hadith-sciences",
                  "tafsir",
                  "seerah",
                  "lugha"
                ],
                "type": "string",
                "description": "hadith-primary — The eight primary hadith collections, edition-pinned; tafsir-canonical — Canonical tafsir — Ibn Kathir, al-Tabari, Ibn al-Jawzi first; fiqh-hanafi — Hanafi fiqh (+ usul, comparative); fiqh-maliki — Maliki fiqh (+ usul, comparative); fiqh-shafii — Shafi'i fiqh (+ usul, comparative); fiqh-hanbali — Hanbali fiqh (+ usul, comparative); fiqh-comparative — All four schools plus comparative and fatwa collections; aqeedah — Creed and sects; hadith-sciences — Hadith commentary, takhrij and the sciences of hadith; tafsir — The whole tafsir shelf and Quranic sciences; seerah — Prophetic biography, history and biographical dictionaries; lugha — Arabic language, lexicons, grammar and adab"
              }
            },
            "additionalProperties": false
          },
          "outputSchema": {
            "type": "object",
            "properties": {
              "note": {
                "type": "string",
                "description": "Present only when the result needs a caveat; carry it with the passages."
              },
              "scope": {
                "type": "string",
                "description": "The scope searched, as sent."
              },
              "passages": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "book": {
                      "type": "string",
                      "description": "Title including the printing, e.g. \"صحيح البخاري - ط السلطانية\"."
                    },
                    "arabic": {
                      "type": "string",
                      "description": "The passage, verbatim, markup removed; at most 1,600 characters, cut with \"…\"."
                    },
                    "author": {
                      "type": "string"
                    },
                    "bookId": {
                      "type": "integer",
                      "description": "Shamela's book id."
                    },
                    "editor": {
                      "type": "string",
                      "description": "The muhaqqiq; omitted when the library records none."
                    },
                    "pageId": {
                      "type": "integer",
                      "description": "Shamela's page id; with bookId it addresses the page for shamela_read (unit page)."
                    },
                    "edition": {
                      "type": "string",
                      "description": "Omitted when the library records none."
                    },
                    "matchedIn": {
                      "enum": [
                        "body",
                        "footnote",
                        "both",
                        "unknown"
                      ],
                      "type": "string",
                      "description": "Where the words were found. A footnote match is the editor's text, not the author's."
                    },
                    "publisher": {
                      "type": "string",
                      "description": "Omitted when the library records none."
                    },
                    "sourceUrl": {
                      "type": "string",
                      "description": "The same page in the Quran Gallery Maktabah reader."
                    },
                    "authorDied": {
                      "type": [
                        "integer",
                        "null"
                      ],
                      "description": "Year of death in AH, or null."
                    },
                    "printedPage": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Volume and page as that printing paginates it, e.g. \"1/ 6\"; null when the library has no printed pagination."
                    },
                    "matchQuality": {
                      "type": "string",
                      "description": "How the library matched the page, e.g. \"exact_phrase\"."
                    }
                  }
                },
                "description": "Best evidence first: exact phrase before word matches, main text before footnote, the school's own shelf before the wider one. Empty when nothing in the scope matched."
              },
              "totalMatches": {
                "type": [
                  "integer",
                  "null"
                ],
                "description": "Matching pages the library verified in the scope before the limit, or null."
              },
              "booksSearched": {
                "type": [
                  "integer",
                  "null"
                ],
                "description": "Books in the searched scope, or null when the library did not say."
              },
              "relaxedToTokens": {
                "type": "boolean",
                "description": "True when the exact phrase was not found and a looser word search answered."
              }
            }
          },
          "annotations": {
            "readOnlyHint": true,
            "openWorldHint": false,
            "idempotentHint": true,
            "destructiveHint": false
          }
        },
        {
          "name": "search",
          "title": "Quick generic search of the whole library",
          "description": "Search the whole classical Islamic library (8,594 works, no scope) and get up to 10 pages as {id, title, url}; pass an id to `fetch` to read the page. This is the generic one-argument entry (the standard search/fetch pair); the scoped tools answer research questions better. Use shamela_search_library for a hadith, tafsir or fiqh question: unscoped ranking is by term frequency, so a poetry anthology can outrank Sahih al-Bukhari. Use shamela_search (match \"words\", \"phrase\", \"near\", \"exact\" or \"boolean\") to pin books, categories or a madhhab, match an exact or diacritized phrase, or page further; use shamela_cite (mode \"printed_page\") for printed-page citations. Exact phrase first; only when it finds nothing are the words matched separately. Title flags: [footnote match] = only an editor's footnote; [token match] = words occur apart; [near match] = only some words or their roots. Empty results mean no page carries the words. A query without Arabic words returns a tool error.",
          "inputSchema": {
            "type": "object",
            "required": [
              "query"
            ],
            "properties": {
              "query": {
                "type": "string",
                "description": "Arabic search text, e.g. \"إنما الأعمال بالنيات\"; 2-6 words work best. Quote the wording if known, else name the topic."
              }
            },
            "additionalProperties": false
          },
          "outputSchema": {
            "type": "object",
            "properties": {
              "results": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "\"{bookId}:{pageId}\" — pass it to `fetch`."
                    },
                    "url": {
                      "type": "string",
                      "description": "The same page in the Quran Gallery Maktabah reader."
                    },
                    "title": {
                      "type": "string",
                      "description": "\"{book} — {author} ({volume}/{page})\", plus [footnote match], [token match] or [near match] when the match is weaker than the exact phrase in the main text."
                    }
                  }
                },
                "description": "At most 10 pages; empty when no page carries the words."
              }
            }
          },
          "annotations": {
            "readOnlyHint": true,
            "openWorldHint": false,
            "idempotentHint": true,
            "destructiveHint": false
          }
        },
        {
          "name": "fetch",
          "title": "Read a library page",
          "description": "Read one library page whole by the id `search` returned: main text, then its footnotes under their own label (the editor's words, never the author's), with book, author, printed volume/page, edition data and the link to the page in the Quran Gallery Maktabah reader. Use shamela_read instead to read one body part at a time (unit \"page\"), a run of pages (unit \"range\") or a whole chapter (unit \"section\"), and shamela_cite (mode \"printed_page\") to turn a printed volume and page into ids. Not a search. Long pages are cut at 4 body parts of about 4,000 characters (2 without an API key): metadata.complete false, ending with the shamela_read call that continues it. A malformed id, or a page the library does not hold, returns a tool error.",
          "inputSchema": {
            "type": "object",
            "required": [
              "id"
            ],
            "properties": {
              "id": {
                "type": "string",
                "description": "Page id \"{bookId}:{pageId}\", e.g. \"1681:10\" — Shamela internal ids from a `search` result, not printed page numbers. Malformed or unknown ids return a tool error."
              }
            },
            "additionalProperties": false
          },
          "outputSchema": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "description": "\"{bookId}:{pageId}\", normalised."
              },
              "url": {
                "type": "string",
                "description": "The same page in the Quran Gallery Maktabah reader."
              },
              "text": {
                "type": "string",
                "description": "Main text, then the footnotes under their own label (the editor's words). When metadata.complete is false it ends with the shamela_read(unit='page') call that continues it."
              },
              "title": {
                "type": "string",
                "description": "\"{book} — {author} ({volume}/{page})\"."
              },
              "metadata": {
                "type": "object",
                "properties": {
                  "book": {
                    "type": "string"
                  },
                  "author": {
                    "type": "string"
                  },
                  "bookId": {
                    "type": "integer"
                  },
                  "editor": {
                    "type": "string",
                    "description": "Omitted when the library records none."
                  },
                  "pageId": {
                    "type": "integer"
                  },
                  "edition": {
                    "type": "string",
                    "description": "Omitted when the library records none."
                  },
                  "complete": {
                    "type": "boolean",
                    "description": "False when the page was longer than `fetch` reads in one call."
                  },
                  "publisher": {
                    "type": "string",
                    "description": "Omitted when the library records none."
                  },
                  "authorDied": {
                    "type": [
                      "integer",
                      "null"
                    ],
                    "description": "Year of death in AH, or null."
                  },
                  "printedPage": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Volume and page as the printing paginates it, or null."
                  },
                  "hasFootnotes": {
                    "type": "boolean"
                  }
                }
              }
            }
          },
          "annotations": {
            "readOnlyHint": true,
            "openWorldHint": false,
            "idempotentHint": true,
            "destructiveHint": false
          }
        },
        {
          "name": "shamela_verify_quote",
          "title": "Check whether a quotation occurs in the library",
          "description": "Checks whether an Arabic quotation occurs in the classical library and where: book, author, printed volume/page, edition, and whether the words are in the main text or in an editor's footnote. Use it on a passage an assistant quoted from memory. Matching ignores diacritics, tatweel and alef forms; exact says whether the page spells the words as given, and differences says how they differ. \"not_found\" means not found in the searched scope (the scope or bookId is named in the answer), not that the quotation is false or appears nowhere. matchedIn \"foot\" is the editor's words, not the author's. It reports where words are printed; it is not a ruling and does not say whether a passage is authentic. Needs at least 3 Arabic words; a shorter or non-Arabic quote returns a tool error naming the fix. Give scope or bookId to narrow it; with neither, the whole library is searched.",
          "inputSchema": {
            "type": "object",
            "required": [
              "quote"
            ],
            "properties": {
              "limit": {
                "type": "integer",
                "default": 5,
                "maximum": 10,
                "minimum": 1,
                "description": "Maximum matching pages to return (max 10)."
              },
              "quote": {
                "type": "string",
                "description": "The Arabic wording to look for, at least 3 words, as quoted; diacritics are optional."
              },
              "scope": {
                "enum": [
                  "hadith-primary",
                  "tafsir-canonical",
                  "fiqh-hanafi",
                  "fiqh-maliki",
                  "fiqh-shafii",
                  "fiqh-hanbali",
                  "fiqh-comparative",
                  "aqeedah",
                  "hadith-sciences",
                  "tafsir",
                  "seerah",
                  "lugha"
                ],
                "type": "string",
                "description": "Optional shelf to search. Ignored when bookId is given. hadith-primary — The eight primary hadith collections, edition-pinned; tafsir-canonical — Canonical tafsir — Ibn Kathir, al-Tabari, Ibn al-Jawzi first; fiqh-hanafi — Hanafi fiqh (+ usul, comparative); fiqh-maliki — Maliki fiqh (+ usul, comparative); fiqh-shafii — Shafi'i fiqh (+ usul, comparative); fiqh-hanbali — Hanbali fiqh (+ usul, comparative); fiqh-comparative — All four schools plus comparative and fatwa collections; aqeedah — Creed and sects; hadith-sciences — Hadith commentary, takhrij and the sciences of hadith; tafsir — The whole tafsir shelf and Quranic sciences; seerah — Prophetic biography, history and biographical dictionaries; lugha — Arabic language, lexicons, grammar and adab"
              },
              "bookId": {
                "type": "integer",
                "minimum": 1,
                "description": "Optional: search this one book (Shamela's book id, as in a result's bookId). Wins over scope."
              }
            },
            "additionalProperties": false
          },
          "outputSchema": {
            "type": "object",
            "properties": {
              "note": {
                "type": "string",
                "description": "The caveats to carry with the verdict."
              },
              "matches": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "book": {
                      "type": "string"
                    },
                    "docId": {
                      "type": "string",
                      "description": "\"{bookId}:{pageId}\" — pass it to `fetch`."
                    },
                    "exact": {
                      "type": "boolean",
                      "description": "True when the page's characters equal the quotation's, whitespace aside. False when only the normalised forms match."
                    },
                    "author": {
                      "type": "string"
                    },
                    "bookId": {
                      "type": "integer"
                    },
                    "pageId": {
                      "type": "integer"
                    },
                    "volume": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Printed volume (the part before the slash), or null."
                    },
                    "edition": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "The printing's edition, or null when the library records none."
                    },
                    "snippet": {
                      "type": "string",
                      "description": "The page's own text around the words."
                    },
                    "matchedIn": {
                      "enum": [
                        "body",
                        "foot"
                      ],
                      "type": "string",
                      "description": "foot: the words are in the editor's or commentator's footnote, not the author's text."
                    },
                    "sourceUrl": {
                      "type": "string",
                      "description": "The same page in the Quran Gallery Maktabah reader."
                    },
                    "differences": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "What normalisation ignored or folded; empty when exact."
                    },
                    "printedPage": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Printed page (the part after the slash), or null."
                    }
                  }
                },
                "description": "Up to `limit` pages, in the library's order; empty when not_found."
              },
              "verdict": {
                "enum": [
                  "found",
                  "not_found"
                ],
                "type": "string",
                "description": "found: pages in the searched scope carry the words in this order. not_found: none does, in that scope only; never a statement that the quotation is false."
              },
              "searched": {
                "type": "object",
                "properties": {
                  "scope": {
                    "type": "string"
                  },
                  "bookId": {
                    "type": "integer"
                  },
                  "ignoredScope": {
                    "type": "string",
                    "description": "A scope that was sent with bookId and set aside."
                  },
                  "wholeLibrary": {
                    "type": "boolean",
                    "description": "True when neither scope nor bookId was given."
                  },
                  "normalisation": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "description": "What was searched. Carry it with any not_found."
              }
            }
          },
          "annotations": {
            "readOnlyHint": true,
            "openWorldHint": false,
            "idempotentHint": true,
            "destructiveHint": false
          }
        },
        {
          "name": "shamela_search",
          "title": "Search page text (words, phrase, exact, boolean, batch)",
          "description": "Full-text search inside the pages (matn and footnotes) of installed books. `match` picks how the query is read:\n- words (default): every word required, ranked by relevance; options add morphology, wildcards, chronological sort. An all-words miss retries with fewer words (relaxed_min_match).\n- phrase: the words consecutively (a quotation). near: all words within `distance`, any order. Both verified in the full page text.\n- exact: diacritics, hamza/alef forms or digit systems kept distinct («أحمد» not «احمد», «عِلْم» not «عَلَم», ٢٥٥ not 255); set at least one `preserve` flag.\n- boolean: every all_of term, one or more any_of, no none_of (الوقف with المسجد or المقبرة, without البيع); one query over the whole index, so total_hits is exact and exclusion exhaustive.\n- batch: 1–24 scoped `queries` run at once, merged and deduped by page (probe_ids); no paging, cut at max_total_passages.\nRules: a parameter of another match value is refused. Page with limit/offset until has_more is false. scope.madhab drops books of unknown school: omit it for comparative questions; set scope.citable_only before quoting a page number. Follow-up rounds: exclude_pages / exclude_work_group_ids keep out pages already used and other printings of the same work. EMPTY_SCOPE: the scope matched no book.\nInstead: chapter headings → shamela_find(kind='heading'); titles → shamela_find(kind='book'); verses → shamela_lookup_quran(mode='search'); a hadith's wording → shamela_lookup_hadith(mode='search').\nExample: {query:'استصناع', scope:{category_ids:[17]}}.",
          "inputSchema": {
            "type": "object",
            "$schema": "http://json-schema.org/draft-07/schema#",
            "properties": {
              "limit": {
                "type": "integer",
                "maximum": 100,
                "minimum": 1,
                "description": "Maximum number of results to return (1-100, default 20). (match=words|phrase|near|exact|boolean only.)"
              },
              "match": {
                "enum": [
                  "words",
                  "phrase",
                  "near",
                  "exact",
                  "boolean",
                  "batch"
                ],
                "type": "string",
                "description": "Selects what the call does: words | phrase | near | exact | boolean | batch. Default words."
              },
              "query": {
                "type": "string",
                "minLength": 1,
                "description": "[match=words] Arabic words, ANDed; each may match in body or footnotes, e.g. {query:'الكلام'}. A word the library lacks in your spelling is searched in the spelling the books use and reported in `respelled_terms`: say so when you quote. [match=phrase] The words as a consecutive phrase, e.g. {query:'خيار المجلس'}. [match=near] The words within `distance` of each other, in any order. Phrase and near candidates come from an AND search and are verified in the full page text up to 1,500 pages or 12 s, so `total_verified` is not a library total; narrow `scope` when `candidate_cap_hit`. [match=exact] The exact string, typed WITH the diacritics / hamza form / digit system to enforce (it is not auto-diacritized) and matched as written; `preserve` decides which distinctions count. An AND search gathers at most 100 candidate pages and each is checked against the book's raw text; results keep candidate-relevance order. (match=words|phrase|near|exact only.)"
              },
              "scope": {
                "type": "object",
                "properties": {
                  "madhab": {
                    "type": "array",
                    "items": {
                      "enum": [
                        "hanafi",
                        "maliki",
                        "shafii",
                        "hanbali"
                      ],
                      "type": "string"
                    },
                    "description": "Restrict to books of these Sunni schools. master.db has NO madhab field, so this is resolved two ways: a book filed under a school-specific category (الفقه الحنفي/المالكي/الشافعي/الحنبلي) counts directly, and otherwise the MAIN AUTHOR's school is used, inferred from the categories that author's own books are filed under. That second path is what reaches مسائل فقهية and الفقه العام, where Shamela records no school — it raises madhab coverage of the fiqh shelves from 27% to 43%. Books whose school cannot be established are EXCLUDED by this filter, so do not read absence as 'no school said this'; for comparative questions leave madhab unset and scope by category instead."
                  },
                  "book_ids": {
                    "type": "array",
                    "items": {
                      "type": "integer",
                      "exclusiveMinimum": 0
                    },
                    "description": "Restrict to these book IDs. Use `shamela_find(kind='name')` or `shamela_list_downloaded_books` to find IDs. Combine with other scope keys for intersection."
                  },
                  "book_type": {
                    "type": "array",
                    "items": {
                      "enum": [
                        "book",
                        "journal",
                        "manuscript",
                        "thesis",
                        "electronic",
                        "transcript"
                      ],
                      "type": "string"
                    },
                    "description": "Restrict to these kinds of entry (master.db.book.book_type — the same filter row Shamela's own 'اختيار كتاب' window shows). 'transcript' (تفريغات) is a transcribed lecture series, not an authored book, and 'thesis'/'electronic' are likewise not printed works — excluding them sharpens a scholarly search. Of 8,594 entries, 7,334 are 'book'; 1,260 are not."
                  },
                  "period_to": {
                    "type": "integer",
                    "maximum": 2000,
                    "minimum": 1,
                    "description": "Hijri year, inclusive upper bound. Pair with period_from."
                  },
                  "author_ids": {
                    "type": "array",
                    "items": {
                      "type": "integer",
                      "exclusiveMinimum": 0
                    },
                    "description": "Restrict to books by these authors. Includes co-authored books. Use `shamela_find(kind='name', type='author')` to find IDs."
                  },
                  "period_from": {
                    "type": "integer",
                    "maximum": 2000,
                    "minimum": 1,
                    "description": "Hijri year, inclusive lower bound. Matches book.book_date (composition year) OR author.death_number (death year). Pair with period_to."
                  },
                  "category_ids": {
                    "type": "array",
                    "items": {
                      "type": "integer",
                      "exclusiveMinimum": 0
                    },
                    "description": "Restrict to books in these categories. Categories are flat in master.db (no parent_id, no transitive subtree expansion). Use `shamela_find(kind='category')` to find IDs."
                  },
                  "citable_only": {
                    "type": "boolean",
                    "description": "Keep only books whose page numbering matches a real printed edition (master.db.book.printed == 1 — Shamela's «يوافق المطبوع»). The other 1,417 entries are paginated by Shamela automatically, so their page numbers are NOT a citable reference to any published edition. Set this true whenever the answer will quote a page number as a citation. Default: false."
                  },
                  "downloaded_only": {
                    "type": "boolean",
                    "description": "Restrict to books actually downloaded on this user's machine (master.db.book.major_ondisk > 0). Critical for honest research scoping when using `shamela_search(match='words')` — only downloaded books have searchable content. Default: false."
                  }
                },
                "description": "Restrict to books, authors, categories, a Hijri period or the other filters below; get ids from shamela_find(kind='category') or shamela_find(kind='name'). Strongly recommended on common words for match=phrase|near (verification stops after 1,500 candidate pages or 12 s) and match=exact (at most 100 candidate pages are verified): a narrow scope is what lets that window cover the topic. match=boolean: an unscoped search over a large library is exhaustive but slow, so scope narrows the question and speeds it up. (match=words|phrase|near|exact|boolean only.)",
                "additionalProperties": false
              },
              "shape": {
                "enum": [
                  "full",
                  "brief",
                  "index"
                ],
                "type": "string",
                "description": "How much of each hit to return. 'full' (default): every field, snippets included — ask for it when the answer will QUOTE the page. 'brief': book_id/page_id, printed_page, match_quality and matched_in_section, book metadata hoisted into a top-level `books` keyed by book_id, NO snippet — which pages, how well each matched and how to cite them, for a fraction of the characters, so far more rows survive the budget. 'index': book_id/page_id only, to choose what to read before paying to read it. Requires the 'shape.full_brief_index' capability (see shamela_get_brief). (match=words|phrase|near|batch only.)"
              },
              "all_of": {
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1
                },
                "description": "The three lists are ONE Lucene BooleanQuery over the whole index: all_of MUST, any_of SHOULD (at least one), none_of MUST_NOT. AND — terms that must ALL appear on the page; a multi-word term is itself AND-searched (its words co-occur; not a phrase). Leave empty to rely on any_of, but not both: BAD_ARG. Results are ranked by relevance. E.g. {match:'boolean', all_of:['الوقف'], any_of:['المسجد','المقبرة'], none_of:['البيع'], scope:{category_ids:[17]}}. (match=boolean only.)"
              },
              "any_of": {
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1
                },
                "description": "OR — at least ONE of these terms must appear on the page. Union of every term's hit set, then intersected with the all_of result. Leave empty to rely on all_of. (match=boolean only.)"
              },
              "offset": {
                "type": "integer",
                "minimum": 0,
                "description": "Number 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. Default: 0. (match=words|phrase|near|exact|boolean only.)"
              },
              "none_of": {
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1
                },
                "description": "NOT — pages containing ANY of these terms are excluded, across the whole index (a MUST_NOT clause, not a subtraction inside a sampled window). Optional. (match=boolean only.)"
              },
              "options": {
                "type": "object",
                "properties": {
                  "sort": {
                    "enum": [
                      "relevance",
                      "chronological"
                    ],
                    "type": "string",
                    "description": "Result order. 'relevance' (default) ranks by how well the page matches — the right answer to 'find me X'. 'chronological' orders by the author's death year, then book, then page, so the EARLIEST sources come first — the right answer to 'who says this first' or 'how does this idea travel through the tradition'. Undated books sort last."
                  },
                  "search_in": {
                    "type": "array",
                    "items": {
                      "enum": [
                        "body",
                        "foot"
                      ],
                      "type": "string"
                    },
                    "description": "Which page sections to search. 'body' = matn (المتن), 'foot' = footnotes (الحواشي). Default is both. Reader comments (التعليقات) are NOT searchable — Shamela keeps them in database/user/data.db, outside the Lucene index, so passing 'comment' returns OPTION_NOT_SUPPORTED rather than silently matching nothing. To search chapter titles use the separate `shamela_find(kind='heading')` tool."
                  },
                  "wildcards": {
                    "type": "boolean",
                    "description": "Interpret `*` (zero-or-more characters) and `?` (exactly-one character) within tokens. Examples: `صيا*` matches صيام/صيامهم, `ص?م` matches صام/صوم/صمم. Leading wildcards (`*ابن`) are slow. Cannot combine with `morphology`. With this OFF, `*` and `?` are treated as ordinary punctuation and split the word, so a stray one no longer zeroes the search. CAVEAT on prefixes: the index folds some words as a WHOLE — «مائة» is stored as «ميه», «داوود» as «داود» — and a wildcard stem is folded without the letters the wildcard replaced, so `مائ*` becomes `ماي*` and reaches مائع/مائدة but NOT مائة. When a prefix search returns less than you expect for a word like these, search the full word without a wildcard instead. Default: false."
                  },
                  "morphology": {
                    "type": "boolean",
                    "description": "Search Arabic root forms via the AlKhalil morphological analyzer. Useful when looking for all word forms (يكتب، كاتب، مكتوب…) of a root (كتب). Cannot be combined with `wildcards`. Default: false."
                  },
                  "preserve_hamza": {
                    "type": "boolean",
                    "description": "Returns OPTION_NOT_SUPPORTED here — the index folds ٱآأإ→ا before storing. Use `shamela_search(match='exact', {preserve:{preserve_hamza:true}})` to distinguish «أحمد» from «احمد». Default: false."
                  },
                  "preserve_digits": {
                    "type": "boolean",
                    "description": "Returns OPTION_NOT_SUPPORTED here — the index unifies Arabic-Indic and Western digits. Use `shamela_search(match='exact', {preserve:{preserve_digits:true}})` to distinguish ٢٥٥ from 255. Default: false."
                  },
                  "relax_when_empty": {
                    "type": "boolean",
                    "description": "When the AND of every term matches no page, retry requiring only the largest number of your terms that some page does carry, and report it in `relaxed_min_match`. Only ever fires on a result that would otherwise be empty, and never drops below half your terms. Set false to keep a strict all-terms-or-nothing search. Default: true."
                  },
                  "preserve_diacritics": {
                    "type": "boolean",
                    "description": "Returns OPTION_NOT_SUPPORTED here — the index itself stores no diacritics, so this search cannot honor them. Use `shamela_search(match='exact', {preserve:{preserve_diacritics:true}})`, which re-checks each candidate against the book's raw text. Default: false."
                  }
                },
                "description": "Search options: morphology, wildcards, sort, search_in (body/foot), relax_when_empty. Defaults to body+foot, no toggles. preserve_* redirect to shamela_search(match='exact'). E.g. {query:'كلم', options:{morphology:true}}. (match=words only.)",
                "additionalProperties": false
              },
              "queries": {
                "type": "array",
                "items": {
                  "type": "object",
                  "required": [
                    "query",
                    "scope"
                  ],
                  "properties": {
                    "id": {
                      "type": "string",
                      "maxLength": 32,
                      "minLength": 1,
                      "description": "Your label for this probe, echoed back on every row it found (`probe_ids`). Defaults to the probe's index, e.g. 'p0'."
                    },
                    "mode": {
                      "enum": [
                        "and",
                        "phrase",
                        "near"
                      ],
                      "type": "string",
                      "description": "'and' (default) = the regular all-terms page search. 'phrase' = the words as a CONSECUTIVE phrase — use it when the caller is holding a quotation. 'near' = within `distance` words, any order."
                    },
                    "limit": {
                      "type": "integer",
                      "maximum": 50,
                      "minimum": 1,
                      "description": "Rows this probe may contribute before dedupe; `max_total_passages` then caps the merged total. Default: 10."
                    },
                    "query": {
                      "type": "string",
                      "minLength": 1,
                      "description": "Arabic search text. In mode='and' every word is required (each may match body or footnotes); in mode='phrase' the words must be consecutive; in mode='near' within `distance` words in any order."
                    },
                    "scope": {
                      "type": "object",
                      "properties": {
                        "madhab": {
                          "$ref": "#/properties/scope/properties/madhab"
                        },
                        "book_ids": {
                          "$ref": "#/properties/scope/properties/book_ids"
                        },
                        "book_type": {
                          "$ref": "#/properties/scope/properties/book_type"
                        },
                        "period_to": {
                          "$ref": "#/properties/scope/properties/period_to"
                        },
                        "author_ids": {
                          "$ref": "#/properties/scope/properties/author_ids"
                        },
                        "period_from": {
                          "$ref": "#/properties/scope/properties/period_from"
                        },
                        "category_ids": {
                          "$ref": "#/properties/scope/properties/category_ids"
                        },
                        "citable_only": {
                          "$ref": "#/properties/scope/properties/citable_only"
                        },
                        "downloaded_only": {
                          "$ref": "#/properties/scope/properties/downloaded_only"
                        }
                      },
                      "description": "REQUIRED. Must carry at least one of book_ids / author_ids / category_ids / madhab. An unscoped probe is rejected: term-frequency ranking over all 8,594 books returns whichever book repeats the word most («التيمم» puts a poetry anthology ahead of the fiqh manuals), which is not the question being asked.",
                      "additionalProperties": false
                    },
                    "distance": {
                      "type": "integer",
                      "maximum": 50,
                      "minimum": 1,
                      "description": "For mode='near' only: maximum word span from the FIRST to the LAST query word, inclusive (1 = adjacent). Ignored for 'and' and 'phrase'. Default: 5."
                    },
                    "exclude_pages": {
                      "$ref": "#/properties/exclude_pages",
                      "description": "Exact 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."
                    },
                    "exclude_book_ids": {
                      "$ref": "#/properties/exclude_book_ids",
                      "description": "Book ids to keep out of the results entirely."
                    },
                    "exclude_author_ids": {
                      "$ref": "#/properties/exclude_author_ids",
                      "description": "Exclude every book by these authors."
                    },
                    "exclude_category_ids": {
                      "$ref": "#/properties/exclude_category_ids",
                      "description": "Exclude every book on these shelves."
                    },
                    "exclude_work_group_ids": {
                      "$ref": "#/properties/exclude_work_group_ids",
                      "description": "Exclude 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."
                    }
                  },
                  "additionalProperties": false
                },
                "maxItems": 24,
                "minItems": 1,
                "description": "Several wordings of one question, run concurrently to assemble its evidence; results are merged, deduped by (book_id, page_id) and attributed to the probes that found each page (`probe_ids`): a page several probes found is corroboration across wordings, not a duplicate. Every probe's scope must carry book_ids, author_ids, category_ids or madhab, else the whole call is BAD_ARG. A probe that errors or outlasts deadline_ms is reported in its own slot and sets `incomplete`: a thin result is then not the library being silent. E.g. {queries:[{query:'الوتر واجب', scope:{category_ids:[14,19]}}, {query:'حكم صلاة الوتر', mode:'near', scope:{madhab:['hanafi']}}]}. (match=batch only.)"
              },
              "distance": {
                "type": "integer",
                "maximum": 50,
                "minimum": 1,
                "description": "For match='near': maximum word span from the FIRST to the LAST query word, counted inclusively — 1 = adjacent, 2 allows one word between two query words. Ignored for match='phrase'. Suits fiqh terms that sit close but not adjacent: {match:'near', query:'بيع قبض', distance:5, scope:{category_ids:[17]}}. Default: 5. (match=phrase|near only.)"
              },
              "preserve": {
                "type": "object",
                "properties": {
                  "preserve_hamza": {
                    "type": "boolean",
                    "description": "Enforce hamza/alef forms exactly: «أحمد» will not match «احمد»; ٱآأإ, ؤ, ئ, ء, ى, ة are all kept distinct. Default: false."
                  },
                  "preserve_digits": {
                    "type": "boolean",
                    "description": "Distinguish digit systems: Arabic-Indic «٢٥٥» will not match Western «255» (and vice-versa). Default: false."
                  },
                  "preserve_diacritics": {
                    "type": "boolean",
                    "description": "Enforce التشكيل exactly: «عِلْم» will not match «عَلَم». The query's own diacritics are honored verbatim. Default: false."
                  }
                },
                "description": "Which distinctions to enforce when each candidate is verified; at least one must be true (none = BAD_ARG), and every unset feature folds. E.g. {query:'أحمد', preserve:{preserve_hamza:true}}, {query:'عِلْم', preserve:{preserve_diacritics:true}}. (match=exact only.)",
                "additionalProperties": false
              },
              "search_in": {
                "type": "array",
                "items": {
                  "enum": [
                    "body",
                    "foot"
                  ],
                  "type": "string"
                },
                "description": "[match=phrase|near] Which page sections to verify the phrase in: body (matn), foot (footnotes). Default both; a hit's `matched_in_section` says where it was found. [match=boolean] Which page sections every clause (all_of, any_of and none_of alike) looks in: body (matn), foot (footnotes). Default ['body','foot']. (match=phrase|near|boolean only.)"
              },
              "deadline_ms": {
                "type": "integer",
                "maximum": 60000,
                "minimum": 1,
                "description": "Wall-clock budget for the whole batch. Probes still running when it expires are reported with status='timeout' and contribute nothing. A timeout is NOT a negative finding — it means the question was not fully asked. Default: 8000. (match=batch only.)"
              },
              "exclude_pages": {
                "type": "array",
                "items": {
                  "type": "object",
                  "required": [
                    "book_id",
                    "page_id"
                  ],
                  "properties": {
                    "book_id": {
                      "type": "integer",
                      "exclusiveMinimum": 0
                    },
                    "page_id": {
                      "type": "integer",
                      "minimum": 0
                    }
                  },
                  "additionalProperties": false
                },
                "description": "Exact 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. (match=words|phrase|near only.)"
              },
              "response_format": {
                "enum": [
                  "markdown",
                  "json",
                  "none"
                ],
                "type": "string",
                "description": "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)."
              },
              "exclude_book_ids": {
                "type": "array",
                "items": {
                  "type": "integer",
                  "exclusiveMinimum": 0
                },
                "description": "Book ids to keep out of the results entirely. (match=words|phrase|near only.)"
              },
              "exclude_author_ids": {
                "type": "array",
                "items": {
                  "type": "integer",
                  "exclusiveMinimum": 0
                },
                "description": "Exclude every book by these authors. (match=words|phrase|near only.)"
              },
              "max_total_passages": {
                "type": "integer",
                "maximum": 200,
                "minimum": 1,
                "description": "Hard cap on merged rows returned. Rows are ordered by match quality then probe agreement before the cut, so the cap drops the weakest evidence rather than an arbitrary tail. `truncated` says whether it fired. Default: 60. (match=batch only.)"
              },
              "exclude_category_ids": {
                "type": "array",
                "items": {
                  "type": "integer",
                  "exclusiveMinimum": 0
                },
                "description": "Exclude every book on these shelves. (match=words|phrase|near only.)"
              },
              "exclude_work_group_ids": {
                "type": "array",
                "items": {
                  "type": "integer",
                  "exclusiveMinimum": 0
                },
                "description": "Exclude 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. (match=words|phrase|near only.)"
              }
            },
            "additionalProperties": false
          },
          "outputSchema": {
            "type": "object",
            "$schema": "http://json-schema.org/draft-07/schema#",
            "properties": {
              "mode": {
                "type": "string",
                "description": "'phrase' or 'near', as searched. (match=phrase|near only.)"
              },
              "books": {
                "type": "object",
                "description": "shape 'brief' only: book metadata keyed by book_id, hoisted off the rows. (match=words|phrase|near|batch only.)",
                "additionalProperties": {
                  "type": "object",
                  "additionalProperties": {}
                }
              },
              "notes": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Caveats about how the expression was evaluated. (match=boolean only.)"
              },
              "query": {
                "type": "string",
                "description": "The query as received. (match=words|phrase|near|exact only.)"
              },
              "all_of": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "AND terms, as searched. (match=boolean only.)"
              },
              "any_of": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "OR terms, as searched. (match=boolean only.)"
              },
              "offset": {
                "type": "number",
                "description": "Offset this page started at. (match=words|phrase|near|exact|boolean only.)"
              },
              "probes": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Probe label, as echoed in `probe_ids`."
                    },
                    "mode": {
                      "type": "string",
                      "description": "'and', 'phrase' or 'near'."
                    },
                    "error": {
                      "type": "string",
                      "description": "Why the probe failed, when status is 'error'."
                    },
                    "query": {
                      "type": "string",
                      "description": "The probe's query."
                    },
                    "status": {
                      "type": "string",
                      "description": "'ok', 'error' or 'timeout'. Only 'ok' means the probe was actually searched."
                    },
                    "returned": {
                      "type": "number",
                      "description": "Rows this probe contributed before dedupe."
                    },
                    "qualifiers": {
                      "type": "object",
                      "properties": {
                        "coverage": {
                          "anyOf": [
                            {
                              "type": "object",
                              "additionalProperties": {}
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "exclusion": {
                          "anyOf": [
                            {
                              "type": "object",
                              "additionalProperties": {}
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "paging_ceiling": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "zero_hit_terms": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "respelled_terms": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "additionalProperties": {}
                          }
                        },
                        "terms_truncated": {
                          "type": "boolean"
                        },
                        "scope_resolution": {
                          "anyOf": [
                            {
                              "$ref": "#/properties/scope_resolution"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "candidate_cap_hit": {
                          "type": [
                            "boolean",
                            "null"
                          ]
                        },
                        "unattributable_books": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "zero_due_to_exclusion": {
                          "type": "boolean"
                        }
                      },
                      "description": "status 'ok' only: the same caveats a single search returns (null = not applicable to this probe's mode or scope). A probe without qualifiers was not searched: never read its silence as the library's.",
                      "additionalProperties": true
                    },
                    "total_hits": {
                      "type": "number",
                      "description": "Matches this probe found in its scope."
                    },
                    "scope_count": {
                      "type": "number",
                      "description": "Books in this probe's resolved scope."
                    },
                    "match_quality": {
                      "type": "string",
                      "description": "Best match_quality among this probe's rows."
                    }
                  },
                  "additionalProperties": true
                },
                "description": "One report per probe, in request order. (match=batch only.)"
              },
              "by_book": {
                "type": "object",
                "description": "Returned rows per book name. (match=batch only.)",
                "additionalProperties": {
                  "type": "number"
                }
              },
              "none_of": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "NOT terms, as searched. (match=boolean only.)"
              },
              "results": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": {}
                },
                "description": "[match=words|phrase|near] Matching pages. shape 'full': book_id, book_name, author_name, category, book_date, work_group_id, madhab fields, page_id, printed_page, matched_in, match_quality ('exact_phrase' | 'near' | 'all_terms' | 'relaxed': a near miss is not a located quotation), matched_in_section ('body' | 'footnote' | 'both'; 'footnote' = the editor's voice, not the author's), snippet_body/snippet_foot (<mark> around matches). shape 'brief' drops book metadata into `books`; 'index' keeps ids only. [match=exact] Verified pages: book_id, book_name, author_name, category, book_date, page_id, printed_page, matched_in (sections holding the exact form), snippet. [match=boolean] Matching pages: book_id, book_name, author_name, category, book_date, madhab fields, page_id, printed_page, matched_in, matched_terms, snippet_body, snippet_foot. [match=batch] Merged page rows (as shamela_search(match='words'), per `shape`) plus probe_ids (every probe that found the page), ordered by match_quality then probe agreement. A 'footnote' matched_in_section is the editor's voice."
              },
              "coverage": {
                "type": "object",
                "description": "Roll-up of hits by_category and by_century (the whole sample), by_book and by_author (the largest top_n only, so they do not sum to it) and edition_groups (one work under several catalogue entries: one source, not corroboration). A census only when sample_is_complete; otherwise a top-scoring sample of sampled_hits. (match=words only.)",
                "additionalProperties": {}
              },
              "distance": {
                "type": "number",
                "description": "Word span used for mode 'near'. (match=phrase|near only.)"
              },
              "has_more": {
                "type": "boolean",
                "description": "True when another page exists; call again with `next_offset`. (match=words|phrase|near|exact|boolean only.)"
              },
              "preserve": {
                "type": "object",
                "description": "The preserve_* flags enforced on this call. (match=exact only.)",
                "additionalProperties": {
                  "type": "boolean"
                }
              },
              "returned": {
                "type": "number",
                "description": "Rows in `results` on this call. (match=words|phrase|near|exact|boolean only.)"
              },
              "exclusion": {
                "type": "object",
                "properties": {
                  "books": {
                    "type": "number",
                    "description": "Distinct books excluded."
                  },
                  "pages": {
                    "type": "number",
                    "description": "Exact pages excluded."
                  },
                  "unknown": {
                    "type": "object",
                    "description": "Excluded ids the catalogue does not hold, per dimension.",
                    "additionalProperties": {
                      "type": "array",
                      "items": {
                        "type": "number"
                      }
                    }
                  }
                },
                "description": "What the `exclude_*` parameters removed. Present only when used. (match=words|phrase|near only.)",
                "additionalProperties": true
              },
              "truncated": {
                "type": "boolean"
              },
              "incomplete": {
                "type": "boolean",
                "description": "True when any probe errored or timed out: a thin result is then not the library being silent. (match=batch only.)"
              },
              "total_hits": {
                "type": "number",
                "description": "[match=words] Every match in scope, not just the rows returned. [match=boolean] Exact count of pages matching the whole expression. (match=words|boolean only.)"
              },
              "next_offset": {
                "type": "number",
                "description": "Offset of the next page. Absent on the last page. (match=words|phrase|near|exact|boolean only.)"
              },
              "scope_count": {
                "type": "number",
                "description": "Books in the resolved scope; -1 when unscoped. (match=words|phrase|near|boolean only.)"
              },
              "rows_dropped": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "of": {
                      "type": "number"
                    },
                    "kept": {
                      "type": "number"
                    },
                    "field": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": true
                }
              },
              "edition_groups": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": {}
                },
                "description": "Works present under several catalogue entries in these rows: read each as one source. (match=batch only.)"
              },
              "paging_ceiling": {
                "type": "number",
                "description": "Deepest offset paging can reach. Present only when the request went past it: narrow the scope instead of paging further. (match=words|boolean only.)"
              },
              "total_verified": {
                "type": "number",
                "description": "Matches confirmed within the scanned window, not a library total. (match=phrase|near|exact only.)"
              },
              "zero_hit_terms": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Query words with no entry in the library as spelled. A zero then reflects spelling, not the topic. (match=words|phrase|near|exact|boolean only.)"
              },
              "respelled_terms": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": {}
                },
                "description": "{typed, searched_instead, hits}: a word absent as typed was searched in the spelling the books use. (match=words only.)"
              },
              "terms_truncated": {
                "type": "boolean",
                "description": "True when the query had more words than are searched. (match=words only.)"
              },
              "relaxed_of_terms": {
                "type": "number",
                "description": "Word count the relaxed match is measured against. (match=words only.)"
              },
              "scope_resolution": {
                "type": "object",
                "properties": {
                  "dropped": {
                    "type": "array",
                    "items": {
                      "type": "number"
                    }
                  },
                  "resolved": {
                    "type": "array",
                    "items": {
                      "type": "number"
                    }
                  },
                  "requested": {
                    "type": "array",
                    "items": {
                      "type": "number"
                    }
                  }
                },
                "description": "Requested book_ids split into resolved and `dropped` (not in the catalogue, never searched). (match=words|phrase|near only.)",
                "additionalProperties": true
              },
              "candidate_cap_hit": {
                "type": "boolean",
                "description": "True when the candidate window filled up: more matches may exist outside it; narrow the scope. (match=phrase|near|exact only.)"
              },
              "normalized_tokens": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "The query after Arabic folding, as actually searched. (match=words only.)"
              },
              "relaxed_min_match": {
                "type": "number",
                "description": "Set when no page held every word: hits carry at least this many of `relaxed_of_terms`. (match=words only.)"
              },
              "truncation_message": {
                "type": "string"
              },
              "morphology_fallback": {
                "type": "boolean",
                "description": "True when the literal search found nothing and was re-run with morphology (root forms). (match=words only.)"
              },
              "unattributable_books": {
                "type": "number",
                "description": "Books excluded by scope.madhab because no school can be established for them. (match=words|phrase|near only.)"
              },
              "total_unique_passages": {
                "type": "number",
                "description": "Distinct pages found across all probes, before the max_total_passages cut. (match=batch only.)"
              },
              "zero_due_to_exclusion": {
                "type": "boolean",
                "description": "True when pages matched but every one was excluded: not evidence of absence. (match=words|phrase|near only.)"
              },
              "morphology_expanded_to": {
                "type": "object",
                "description": "options.morphology only: exactly what was searched, per word. Roots are ambiguous and every reading is kept («كتب» also searches تبب/توب/وتب, perdition and repentance), so results are a SUPERSET of the word asked for. (match=words only.)",
                "additionalProperties": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              },
              "total_candidates_scanned": {
                "type": "number",
                "description": "Candidate pages verified against the page text. (match=phrase|near|exact only.)"
              }
            },
            "additionalProperties": true
          },
          "annotations": {
            "readOnlyHint": true,
            "openWorldHint": false,
            "idempotentHint": true,
            "destructiveHint": false
          }
        },
        {
          "name": "shamela_find",
          "title": "Find books, headings, authors, categories or names",
          "description": "Catalogue lookup — which books, headings, authors and shelves exist, not page text. `kind`:\n- book (default): titles, authors, publication lines, subject descriptions → book_ids, installed or not. no_title_match: not proof the book is held. downloaded:false → another edition (shamela_get_details(kind='book') same_group) or catalogue metadata only.\n- heading: chapter/section headings, i.e. where books treat a topic; open with shamela_read(unit='section', book_id, title_id). No hits = no heading carries the words: drop words or use shamela_search(match='words').\n- author: names and biographies → author_id, Hijri death year, book count; no scope. Empty is not absence: retry kunya, nisba or shuhra (ابن قدامة / الموفق / المقدسي).\n- category: the 41 flat shelves with catalogue and installed counts → scope.category_ids. A subject spans ids (Qur'anic studies 3 tafsir, 4 Qur'anic sciences/usul al-tafsir, 5 tajwid/qira'at; fiqh 14–17 by madhab): pass all that apply. downloaded_only:true when choosing shelves to search or read.\n- work: verify a cited title (optional author, edition); refuses rather than guesses; catalogue only, text need not be installed.\n- name: fuzzy best guess over book/author names, for an id; always answers, so never use it to verify a citation.\n- period: books by Hijri window, bounds ANDed (scope.period_* on searches unions them).\nRules: a parameter of another kind is refused; book/heading/author/period page with limit/offset until has_more is false. Instead: page text → shamela_search; a printed page → shamela_cite(mode='printed_page'); one book's headings → shamela_read(unit='toc').",
          "inputSchema": {
            "type": "object",
            "$schema": "http://json-schema.org/draft-07/schema#",
            "properties": {
              "kind": {
                "enum": [
                  "book",
                  "heading",
                  "author",
                  "category",
                  "work",
                  "name",
                  "period"
                ],
                "type": "string",
                "description": "Selects what the call does: book | heading | author | category | work | name | period. Default book."
              },
              "type": {
                "enum": [
                  "any",
                  "book",
                  "author"
                ],
                "type": "string",
                "description": "'book' matches catalogue titles only, 'author' author names only, 'any' (default) both, returned as separate books[] and authors[] lists. Reads the s_book/ and s_author/ n-gram indexes (fast partial matching). Example: {query:'ابن قدامة', type:'author'}. (kind=name only.)"
              },
              "limit": {
                "type": "integer",
                "maximum": 100,
                "minimum": 1,
                "description": "[kind=book|heading|author|period] Maximum number of results to return (1-100, default 20). [kind=work] Maximum candidates to report (1-50, default 20). [kind=name] Maximum results per list (1–20, default 5): with type 'any' you get up to `limit` books AND up to `limit` authors. (kind=book|heading|author|work|name|period only.)"
              },
              "query": {
                "type": "string",
                "minLength": 1,
                "description": "[kind=book] Arabic words matched against book name + author + bibliography and the editorial subject description; each hit's `matched_in` says which. 1,729 entries carry a description (~1,500 characters on average), which finds a book by SUBJECT: «الرجز» matches 0 titles and 2 descriptions; {query:'البيوع'} also returns books whose description carries it. E.g. {query:'الأصول'}. [kind=heading] Arabic words matched against chapter / section title text, e.g. 'باب الصيام', or 'تعريف' with scope:{book_ids:[id]}. [kind=author] Arabic words matched against name + biography in the ~3,200-author catalogue, e.g. 'ابن قدامة'. [kind=name] An Arabic name fragment: 'ابن قدامة' resolves Ibn Qudamah, 'روضة الناظر' the book, 'الروضة' the books with that word in their title; «title لِauthor» is split into title and author. Every kind reads pre-built indexes: no download needed. (kind=book|heading|author|name only.)"
              },
              "scope": {
                "type": "object",
                "properties": {
                  "madhab": {
                    "type": "array",
                    "items": {
                      "enum": [
                        "hanafi",
                        "maliki",
                        "shafii",
                        "hanbali"
                      ],
                      "type": "string"
                    },
                    "description": "Restrict to books of these Sunni schools. master.db has NO madhab field, so this is resolved two ways: a book filed under a school-specific category (الفقه الحنفي/المالكي/الشافعي/الحنبلي) counts directly, and otherwise the MAIN AUTHOR's school is used, inferred from the categories that author's own books are filed under. That second path is what reaches مسائل فقهية and الفقه العام, where Shamela records no school — it raises madhab coverage of the fiqh shelves from 27% to 43%. Books whose school cannot be established are EXCLUDED by this filter, so do not read absence as 'no school said this'; for comparative questions leave madhab unset and scope by category instead."
                  },
                  "book_ids": {
                    "type": "array",
                    "items": {
                      "type": "integer",
                      "exclusiveMinimum": 0
                    },
                    "description": "Restrict to these book IDs. Use `shamela_find(kind='name')` or `shamela_list_downloaded_books` to find IDs. Combine with other scope keys for intersection."
                  },
                  "book_type": {
                    "type": "array",
                    "items": {
                      "enum": [
                        "book",
                        "journal",
                        "manuscript",
                        "thesis",
                        "electronic",
                        "transcript"
                      ],
                      "type": "string"
                    },
                    "description": "Restrict to these kinds of entry (master.db.book.book_type — the same filter row Shamela's own 'اختيار كتاب' window shows). 'transcript' (تفريغات) is a transcribed lecture series, not an authored book, and 'thesis'/'electronic' are likewise not printed works — excluding them sharpens a scholarly search. Of 8,594 entries, 7,334 are 'book'; 1,260 are not."
                  },
                  "period_to": {
                    "type": "integer",
                    "maximum": 2000,
                    "minimum": 1,
                    "description": "Hijri year, inclusive upper bound. Pair with period_from."
                  },
                  "author_ids": {
                    "type": "array",
                    "items": {
                      "type": "integer",
                      "exclusiveMinimum": 0
                    },
                    "description": "Restrict to books by these authors. Includes co-authored books. Use `shamela_find(kind='name', type='author')` to find IDs."
                  },
                  "period_from": {
                    "type": "integer",
                    "maximum": 2000,
                    "minimum": 1,
                    "description": "Hijri year, inclusive lower bound. Matches book.book_date (composition year) OR author.death_number (death year). Pair with period_to."
                  },
                  "category_ids": {
                    "type": "array",
                    "items": {
                      "type": "integer",
                      "exclusiveMinimum": 0
                    },
                    "description": "Restrict to books in these categories. Categories are flat in master.db (no parent_id, no transitive subtree expansion). Use `shamela_find(kind='category')` to find IDs."
                  },
                  "citable_only": {
                    "type": "boolean",
                    "description": "Keep only books whose page numbering matches a real printed edition (master.db.book.printed == 1 — Shamela's «يوافق المطبوع»). The other 1,417 entries are paginated by Shamela automatically, so their page numbers are NOT a citable reference to any published edition. Set this true whenever the answer will quote a page number as a citation. Default: false."
                  },
                  "downloaded_only": {
                    "type": "boolean",
                    "description": "Restrict to books actually downloaded on this user's machine (master.db.book.major_ondisk > 0). Critical for honest research scoping when using `shamela_search(match='words')` — only downloaded books have searchable content. Default: false."
                  }
                },
                "description": "[kind=book] Restrict to authors, categories, a Hijri period (period_from/period_to) or downloaded_only (books whose text is installed); scope.book_ids is not accepted. E.g. {query:'فقه', scope:{category_ids:[17], downloaded_only:true}}. [kind=heading] The same filter as shamela_search(match='words'); scope.book_ids with one id searches only that book's headings. EMPTY_SCOPE: the scope matched no book. (kind=book|heading only.)",
                "additionalProperties": false
              },
              "title": {
                "type": "string",
                "minLength": 1,
                "description": "The work's title as cited, e.g. «صحيح البخاري», «المغني», «فتح الباري». Leading words only — the title, not a description of it. You may include the catalogue's own edition tail, with the « - » («صحيح البخاري - ط السلطانية») or without it («مسند أحمد ط الرسالة»), and it will be read as `edition`. An author name appended instead («صحيح البخاري محمد بن إسماعيل البخاري», «الهداية للمرغيناني») is read as `author`. Where a title is held by more than one author, a trailing edition is NOT read as one until you also pass `author` — «صحيح البخاري ت البغا» alone is refused, «صحيح البخاري ت البغا» + author «البخاري» resolves. The title must be a PREFIX of the entry's own: «شرح صحيح البخاري», «المدخل إلى صحيح البخاري» and «عمدة القاري شرح صحيح البخاري» contain the work's name and none IS the work. A commentary is rejected (listed in rejected[]): quoting it as the work would attribute its author's words to al-Bukhari. Example: {title:'المغني', author:'ابن قدامة'}. (kind=work only.)"
              },
              "author": {
                "type": "string",
                "description": "The author as cited, when known. This is a FILTER, not a hint: a candidate whose author cannot be reconciled with it is rejected rather than ranked down, because that is exactly how a commentary gets returned as the work it comments on. (kind=work only.)"
              },
              "offset": {
                "type": "integer",
                "minimum": 0,
                "description": "Number 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. Default: 0. (kind=book|heading|author|period only.)"
              },
              "died_to": {
                "type": "integer",
                "maximum": 2000,
                "minimum": 1,
                "description": "Hijri year, inclusive UPPER bound on the MAIN AUTHOR's death year (author.death_number). Pair with died_from. (kind=period only.)"
              },
              "edition": {
                "type": "string",
                "description": "A specific printing, as the catalogue names it: 'ط السلطانية', 'ت البغا', 'ط التأصيل'. If no entry carries it you get status='not_found' with reason='edition_not_found' and the editions that DO exist — never a different book. (kind=work only.)"
              },
              "options": {
                "type": "object",
                "properties": {
                  "sort": {
                    "enum": [
                      "relevance",
                      "chronological"
                    ],
                    "type": "string",
                    "description": "Result order. 'relevance' (default) ranks by how well the page matches — the right answer to 'find me X'. 'chronological' orders by the author's death year, then book, then page, so the EARLIEST sources come first — the right answer to 'who says this first' or 'how does this idea travel through the tradition'. Undated books sort last."
                  },
                  "search_in": {
                    "type": "array",
                    "items": {
                      "enum": [
                        "body",
                        "foot"
                      ],
                      "type": "string"
                    },
                    "description": "Ignored here. Default: ['body','foot']."
                  },
                  "wildcards": {
                    "type": "boolean",
                    "description": "Interpret `*` (zero-or-more characters) and `?` (exactly-one character) within tokens. Examples: `صيا*` matches صيام/صيامهم, `ص?م` matches صام/صوم/صمم. Leading wildcards (`*ابن`) are slow. Cannot combine with `morphology`. With this OFF, `*` and `?` are treated as ordinary punctuation and split the word, so a stray one no longer zeroes the search. CAVEAT on prefixes: the index folds some words as a WHOLE — «مائة» is stored as «ميه», «داوود» as «داود» — and a wildcard stem is folded without the letters the wildcard replaced, so `مائ*` becomes `ماي*` and reaches مائع/مائدة but NOT مائة. When a prefix search returns less than you expect for a word like these, search the full word without a wildcard instead. Default: false."
                  },
                  "morphology": {
                    "type": "boolean",
                    "description": "Search Arabic root forms via the AlKhalil morphological analyzer. Useful when looking for all word forms (يكتب، كاتب، مكتوب…) of a root (كتب). Cannot be combined with `wildcards`. Default: false."
                  },
                  "preserve_hamza": {
                    "type": "boolean",
                    "description": "Returns OPTION_NOT_SUPPORTED here. Default: false."
                  },
                  "preserve_digits": {
                    "type": "boolean",
                    "description": "Returns OPTION_NOT_SUPPORTED here. Default: false."
                  },
                  "relax_when_empty": {
                    "type": "boolean",
                    "description": "When the AND of every word of the title matches no catalogue entry, retry requiring only the largest number of them some entry does carry, and report it in `relaxed_min_match`. A title is usually quoted the way people cite it («فتح الباري لابن حجر») rather than the way the catalogue spells it («فتح الباري بشرح البخاري - ط السلفية»), and the strict AND then reports the library does not hold the book at all. Default: true."
                  },
                  "preserve_diacritics": {
                    "type": "boolean",
                    "description": "Returns OPTION_NOT_SUPPORTED here. Default: false."
                  }
                },
                "description": "[kind=book] morphology / wildcards / sort / relax_when_empty. [kind=heading] morphology / wildcards / sort ('chronological' = earliest author first); headings are matched in folded form only. [kind=author] morphology / wildcards / sort ('relevance' by default; 'chronological' = by Hijri death year, earliest first, undated last), e.g. {query:'الشافعي', options:{wildcards:false}}. preserve_* return OPTION_NOT_SUPPORTED; search_in is ignored (catalogue entries have no body or footnotes; a heading is a single field). Results are ranked by relevance unless sort says otherwise. (kind=book|heading|author only.)",
                "additionalProperties": false
              },
              "died_from": {
                "type": "integer",
                "maximum": 2000,
                "minimum": 1,
                "description": "Hijri year, inclusive LOWER bound on the MAIN AUTHOR's death year (author.death_number). A different column from composed_*, but the same number on 98.5% of dated books. Pair with died_to. At least one of composed_from/composed_to/died_from/died_to is required (BAD_ARG); a missing side is open-ended, and undated books drop out under any bound set. E.g. died_from:700, died_to:800 = 8th-century-Hijri authors. A composed-vs-died question («written in the 8th century by authors who died in the 9th») cannot be answered from this data: a near-empty result means the distinction is unavailable, not that no such book exists. (kind=period only.)"
              },
              "category_id": {
                "type": "integer",
                "description": "Optional: restrict to one category (use shamela_find(kind='category') for IDs). Categories are flat in master.db. Example: {died_from:600, died_to:700, category_id:17}. (kind=period only.)",
                "exclusiveMinimum": 0
              },
              "composed_to": {
                "type": "integer",
                "maximum": 2000,
                "minimum": 1,
                "description": "Hijri year, inclusive UPPER bound on book.book_date («تاريخ الكتاب»; see composed_from — it is not a composition year). Pair with composed_from. (kind=period only.)"
              },
              "composed_from": {
                "type": "integer",
                "maximum": 2000,
                "minimum": 1,
                "description": "Hijri year, inclusive LOWER bound on book.book_date — Shamela's «تاريخ الكتاب». NOT an independent composition year: it holds the main author's death year on 98.5% of dated books (8,461/8,587), so pairing it with died_* almost never narrows anything. Pair with composed_to. (kind=period only.)"
              },
              "include_counts": {
                "type": "boolean",
                "description": "If true (default), include book_count for each category; false returns book_count 0. Costs nothing either way — counts are precomputed. downloaded_count is always filled. (kind=category only.)"
              },
              "downloaded_only": {
                "type": "boolean",
                "description": "[kind=category] If true, list only categories with at least one book installed on this server. Useful to see where the installed library is concentrated across the 41 categories. Default: false. [kind=period] If true, restrict to books whose text is installed on this server — the only ones with searchable page content. Default false lists the whole catalogue. (kind=category|period only.)"
              },
              "response_format": {
                "enum": [
                  "markdown",
                  "json",
                  "none"
                ],
                "type": "string",
                "description": "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)."
              }
            },
            "additionalProperties": false
          },
          "outputSchema": {
            "type": "object",
            "$schema": "http://json-schema.org/draft-07/schema#",
            "properties": {
              "books": {
                "description": "[kind=name] Book matches, best first. [kind=period] book_id, book_name, main author + death year, book_date, category, downloaded; sorted by book_id. (kind=name|period only.)"
              },
              "match": {
                "type": "object",
                "properties": {
                  "work": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The work's title without the edition tail."
                  },
                  "book_id": {
                    "type": [
                      "number",
                      "null"
                    ],
                    "description": "Catalogue book id."
                  },
                  "citable": {
                    "type": [
                      "boolean",
                      "null"
                    ],
                    "description": "False when page numbers are Shamela's own, not a printed edition's."
                  },
                  "edition": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Edition tail of the catalogue title, e.g. 'ط السلطانية'; null when none."
                  },
                  "author_id": {
                    "type": [
                      "number",
                      "null"
                    ],
                    "description": "Main author id."
                  },
                  "book_date": {
                    "type": [
                      "number",
                      "null"
                    ],
                    "description": "Shamela «تاريخ الكتاب», Hijri; usually the author's death year."
                  },
                  "book_name": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Catalogue title of the book (Arabic)."
                  },
                  "downloaded": {
                    "type": [
                      "boolean",
                      "null"
                    ],
                    "description": "True when the text is installed on this server."
                  },
                  "author_name": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Main author name."
                  },
                  "work_group_id": {
                    "type": [
                      "number",
                      "null"
                    ],
                    "description": "Group id shared by every catalogue entry of the same work."
                  }
                },
                "description": "The single entry, when status is 'exact'. (kind=work only.)",
                "additionalProperties": true
              },
              "notes": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Guidance on using the result. (kind=work only.)"
              },
              "query": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The query as received. (kind=book|heading|author|name only.)"
              },
              "title": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Title as parsed from the request. (kind=work only.)"
              },
              "total": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "[kind=category] Categories listed. [kind=period] Books satisfying every bound. (kind=category|period only.)"
              },
              "author": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Author filter applied; null when none. (kind=work only.)"
              },
              "filter": {
                "type": "object",
                "properties": {
                  "died_to": {
                    "anyOf": [
                      {
                        "type": "integer"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "died_from": {
                    "anyOf": [
                      {
                        "type": "integer"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "category_id": {
                    "anyOf": [
                      {
                        "type": "integer"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "composed_to": {
                    "anyOf": [
                      {
                        "type": "integer"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "composed_from": {
                    "anyOf": [
                      {
                        "type": "integer"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "downloaded_only": {
                    "type": "boolean"
                  }
                },
                "description": "Echo of the applied constraints. (kind=period only.)",
                "additionalProperties": true
              },
              "offset": {
                "type": "number",
                "description": "[kind=book|heading|author] Offset this page started at. [kind=period] Rows skipped before this page. (kind=book|heading|author|period only.)"
              },
              "reason": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "When not_found: 'no_title_match', 'author_mismatch' or 'edition_not_found'. (kind=work only.)"
              },
              "status": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "'exact' — use `match`; 'ambiguous' — see `ambiguity`; 'not_found' — read `reason` (and available_editions for an unknown edition). (kind=work only.)"
              },
              "authors": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "score": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Name-match rank, not a probability: 1000 = folded name identical to the query; 800-900 = the name contains the whole query in order; below 800 = partial overlap."
                    },
                    "author_id": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Author id."
                    },
                    "book_count": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Catalogue books by the author."
                    },
                    "death_year": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Hijri death year."
                    },
                    "author_name": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Author name."
                    }
                  },
                  "additionalProperties": true
                },
                "description": "Author matches, best first. (kind=name only.)"
              },
              "edition": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Edition requested; null when none. (kind=work only.)"
              },
              "results": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": {}
                },
                "description": "[kind=book] Catalogue entries: book_id, book_name, author_name, category, book_date, downloaded (false = text not installed on this server), snippet, matched_in ('bibliography' | 'description' | null). [kind=heading] Matching headings: book_id, book_name, author_name, title_id (pass to shamela_read(unit='section')), title_text, parent_id (enclosing heading, null at top level). [kind=author] Authors: author_id, author_name, death_year (Hijri, null when unknown), book_count, snippet. (kind=book|heading|author only.)"
              },
              "book_ids": {
                "type": "array",
                "items": {
                  "type": "integer"
                },
                "description": "This page's ids, ready for scope.book_ids. (kind=period only.)"
              },
              "coverage": {
                "type": "object",
                "description": "Hits rolled up by_category and by_century. (kind=book only.)",
                "additionalProperties": {}
              },
              "has_more": {
                "type": "boolean",
                "description": "[kind=book|heading|author] True when another page exists; call again with `next_offset`. [kind=period] True when more rows exist past this page. (kind=book|heading|author|period only.)"
              },
              "rejected": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "detail": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Why it was rejected."
                    },
                    "reason": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "'different_author' or 'not_the_work'."
                    },
                    "book_id": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Catalogue book id."
                    },
                    "book_name": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Catalogue title of the book (Arabic)."
                    },
                    "author_name": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Main author name."
                    }
                  },
                  "additionalProperties": true
                },
                "description": "Entries that matched the words but are not the cited work. (kind=work only.)"
              },
              "returned": {
                "type": "number",
                "description": "[kind=book|heading|author] Rows in `results` on this call. [kind=period] Rows in this response. (kind=book|heading|author|period only.)"
              },
              "ambiguity": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "When ambiguous: 'edition' — one work in several printings: search them as one scope, cite one; 'work' — different books that nothing may choose between («المغني»: al-Dhahabi's book of weak narrators and Ibn Qudama's fiqh): the user must choose. (kind=work only.)"
              },
              "truncated": {
                "type": "boolean"
              },
              "candidates": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "work": {
                      "$ref": "#/properties/match/properties/work"
                    },
                    "book_id": {
                      "$ref": "#/properties/match/properties/book_id"
                    },
                    "citable": {
                      "$ref": "#/properties/match/properties/citable"
                    },
                    "edition": {
                      "$ref": "#/properties/match/properties/edition"
                    },
                    "author_id": {
                      "$ref": "#/properties/match/properties/author_id"
                    },
                    "book_date": {
                      "$ref": "#/properties/match/properties/book_date"
                    },
                    "book_name": {
                      "$ref": "#/properties/match/properties/book_name"
                    },
                    "downloaded": {
                      "$ref": "#/properties/match/properties/downloaded"
                    },
                    "author_name": {
                      "$ref": "#/properties/match/properties/author_name"
                    },
                    "work_group_id": {
                      "$ref": "#/properties/match/properties/work_group_id"
                    }
                  },
                  "additionalProperties": true
                },
                "description": "Entries that carry the requested title. (kind=work only.)"
              },
              "categories": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "book_count": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Catalogue books in the category; 0 when include_counts is false."
                    },
                    "category_id": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Pass to scope.category_ids or category_id."
                    },
                    "category_name": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Category name (Arabic)."
                    },
                    "downloaded_count": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Books in the category installed on this server."
                    }
                  },
                  "additionalProperties": true
                },
                "description": "Categories by id. (kind=category only.)"
              },
              "total_hits": {
                "type": "number",
                "description": "Every match in scope, not just the rows returned. (kind=book|heading|author only.)"
              },
              "next_offset": {
                "type": "number",
                "description": "[kind=book|heading|author] Offset of the next page. Absent on the last page. [kind=period] Offset for the next page; present only when has_more is true. (kind=book|heading|author|period only.)"
              },
              "rows_dropped": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "of": {
                      "type": "number"
                    },
                    "kept": {
                      "type": "number"
                    },
                    "field": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": true
                }
              },
              "no_title_match": {
                "type": "boolean",
                "description": "True when no returned title carries every query word: hits match by some words or by description, not proof the book is held. (kind=book only.)"
              },
              "paging_ceiling": {
                "type": "number",
                "description": "Deepest offset paging can reach. Present only when the request went past it: narrow the scope instead of paging further. (kind=book|heading|author only.)"
              },
              "terms_truncated": {
                "type": "boolean",
                "description": "True when the query had more words than are searched. (kind=book|heading|author only.)"
              },
              "downloaded_total": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Books installed on this server, whole library. (kind=category only.)"
              },
              "relaxed_of_terms": {
                "type": "number",
                "description": "Word count the relaxed match is measured against. (kind=book only.)"
              },
              "normalized_tokens": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "[kind=book|heading|author] The query after Arabic folding, as actually searched. [kind=name] Tokens after Arabic normalisation. (kind=book|heading|author|name only.)"
              },
              "relaxed_min_match": {
                "type": "number",
                "description": "Set when no entry held every word: hits carry at least this many of `relaxed_of_terms`. (kind=book only.)"
              },
              "available_editions": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "work": {
                      "$ref": "#/properties/match/properties/work"
                    },
                    "book_id": {
                      "$ref": "#/properties/match/properties/book_id"
                    },
                    "citable": {
                      "$ref": "#/properties/match/properties/citable"
                    },
                    "edition": {
                      "$ref": "#/properties/match/properties/edition"
                    },
                    "author_id": {
                      "$ref": "#/properties/match/properties/author_id"
                    },
                    "book_date": {
                      "$ref": "#/properties/match/properties/book_date"
                    },
                    "book_name": {
                      "$ref": "#/properties/match/properties/book_name"
                    },
                    "downloaded": {
                      "$ref": "#/properties/match/properties/downloaded"
                    },
                    "author_name": {
                      "$ref": "#/properties/match/properties/author_name"
                    },
                    "work_group_id": {
                      "$ref": "#/properties/match/properties/work_group_id"
                    }
                  },
                  "additionalProperties": true
                },
                "description": "When edition_not_found: the printings the catalogue does carry, shaped like candidates. (kind=work only.)"
              },
              "no_confident_match": {
                "type": "object",
                "properties": {
                  "note": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Why no match is trustworthy."
                  }
                },
                "description": "Present when nothing reached score 800 (no name carries the whole query): treat the hits as suggestions. (kind=name only.)",
                "additionalProperties": true
              },
              "truncation_message": {
                "type": "string"
              }
            },
            "additionalProperties": true
          },
          "annotations": {
            "readOnlyHint": true,
            "openWorldHint": false,
            "idempotentHint": true,
            "destructiveHint": false
          }
        },
        {
          "name": "shamela_read",
          "title": "Read pages, sections and tables of contents",
          "description": "Read an installed book's text and structure by internal ids. `unit`:\n- page (default): one page_id → body (author's matn), foot (editor's footnotes), printed page label, prev/next page ids, enclosing headings.\n- range: up to 20 consecutive pages from start_page_id, each with text, footnotes, printed page — to read on past a hit or through a span.\n- section: one chapter by title_id with its sub-headings, up to the next heading outside it.\n- toc: headings with their title_ids; top level by default, parent_id/depth expand, containing_page_id gives the chain enclosing a page.\n- parts: volumes — part label, page count, first/last page_id.\n- services: what one page cites (aya ids, hadith keys, isnad markers, as stored) → shamela_lookup_quran(mode='aya'), shamela_lookup_hadith(mode='sources'), shamela_lookup_rijal(mode='isnad').\nRules: a parameter of another unit is refused. page_id is not the printed page and ids have gaps: step with prev_page_id/next_page_id, not ±1; for a printed «vol./page» call shamela_cite(mode='printed_page') first. A size budget cuts long text: follow body_has_more (body_part+1) or next_start_page_id. Errors: PAGE_NOT_FOUND (also a range start past the end), TITLE_NOT_FOUND, BOOK_NOT_FOUND, BOOK_NOT_DOWNLOADED (catalogued, not installed: use an installed edition from shamela_get_details(kind='book') same_group).\nInstead: a heading by its words → shamela_find(kind='heading'); books of untitled «فصل» headings → shamela_search(match='words') scoped to the book; any catalogued book's metadata → shamela_get_details(kind='book').",
          "inputSchema": {
            "type": "object",
            "$schema": "http://json-schema.org/draft-07/schema#",
            "properties": {
              "unit": {
                "enum": [
                  "page",
                  "range",
                  "section",
                  "toc",
                  "parts",
                  "services"
                ],
                "type": "string",
                "description": "Selects what the call does: page | range | section | toc | parts | services. Default page."
              },
              "count": {
                "type": "integer",
                "maximum": 20,
                "minimum": 1,
                "description": "How many consecutive pages to fetch (1–20, default 5). Fewer come back when the ~12,000-character budget is reached; has_more then stays true. Use shamela_read(unit='section') for full chapter reads. Faster than looping unit='page'. E.g. {unit:'range', book_id, start_page_id:1, count:5}. (unit=range only.)"
              },
              "depth": {
                "type": "integer",
                "maximum": 5,
                "minimum": 1,
                "description": "Levels below parent_id to include (1–5, default 1); deeper levels arrive nested in `children`. Ignored when containing_page_id is set. E.g. {unit:'toc', book_id, depth:1} lists the top-level chapters. (unit=toc only.)"
              },
              "book_id": {
                "type": "integer",
                "description": "The book id, from shamela_find(kind='book'), shamela_find(kind='work') or shamela_find(kind='name'). Installed ids: shamela_list_downloaded_books.",
                "exclusiveMinimum": 0
              },
              "page_id": {
                "type": "integer",
                "description": "[unit=page] Internal page id, as search hits, shamela_read(unit='toc') and shamela_cite(mode='printed_page') return it; not the printed page number. Ids have gaps, so take neighbours from prev_page_id/next_page_id. [unit=services] Shamela's internal page id (from a search hit or reader tool), not the printed page number. Example: {unit:'services', book_id:1681, page_id:10}. (unit=page|services only.)",
                "exclusiveMinimum": 0
              },
              "title_id": {
                "type": "integer",
                "description": "The title id of the chapter / section to fetch, from shamela_read(unit='toc') or shamela_find(kind='heading'). Its sub-headings are included. (unit=section only.)",
                "exclusiveMinimum": 0
              },
              "body_part": {
                "type": "integer",
                "minimum": 1,
                "description": "For long pages: when the body exceeds ~4000 characters it is split into parts. Pass the 1-based part to read (default 1). The response reports body_part/body_total_parts/body_has_more; request the next part by incrementing. The footnote/comment are returned with part 1. (unit=page only.)"
              },
              "keep_html": {
                "type": "boolean",
                "description": "[unit=page] If true, preserve inline HTML markers (e.g. <span data-type='title'>). Default false strips them for plain Arabic display. [unit=range|section] If true, keep Shamela's inline markup: <span data-type='title'> headings, <a href=\"inr://man-<narrator_id>\"> narrator links, <hadeeth-N> markers. Default false strips them for plain Arabic display. (unit=page|range|section only.)"
              },
              "max_pages": {
                "type": "integer",
                "maximum": 100,
                "minimum": 1,
                "description": "Cap on pages to read (1–100, default 30). The ~12,000-character budget can stop the read earlier; either way truncated:true and next_start_page_id say where to resume with shamela_read(unit='range'). (unit=section only.)"
              },
              "parent_id": {
                "type": "integer",
                "minimum": 0,
                "description": "Title id whose children to list; 0 (default) = top-level chapters. Ignored when containing_page_id is set. (unit=toc only.)"
              },
              "start_page_id": {
                "type": "integer",
                "description": "First page id to read (inclusive). To continue a range that was cut short, pass the previous response's next_start_page_id. (unit=range only.)",
                "exclusiveMinimum": 0
              },
              "response_format": {
                "enum": [
                  "markdown",
                  "json",
                  "none"
                ],
                "type": "string",
                "description": "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)."
              },
              "containing_page_id": {
                "type": "integer",
                "description": "Page id. Switches to ancestor-chain mode: returns the headings that enclose this page, root to leaf, in `ancestor_chain`; parent_id and depth are then ignored. E.g. containing_page_id:17 gives the chapter holding page 17. (unit=toc only.)",
                "exclusiveMinimum": 0
              }
            },
            "additionalProperties": false
          },
          "outputSchema": {
            "type": "object",
            "$schema": "http://json-schema.org/draft-07/schema#",
            "properties": {
              "raw": {
                "description": "The raw service record, for debugging. (unit=services only.)"
              },
              "ayat": {
                "type": "array",
                "items": {
                  "type": "number"
                },
                "description": "Cumulative aya ids (1-6236, 262 = 2:255) cited on the page, as stored; pass to shamela_lookup_quran(mode='aya'). (unit=services only.)"
              },
              "body": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Main text (matn), or the requested body_part of it. (unit=page only.)"
              },
              "foot": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Footnotes (editor's words, not the author's); returned with body_part 1 only. (unit=page only.)"
              },
              "mode": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "'subtree' (parent_id/depth) or 'ancestor_chain' (containing_page_id). (unit=toc only.)"
              },
              "part": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Volume/part label, e.g. '4'; null for single-volume books. (unit=page only.)"
              },
              "count": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Pages actually returned (may be fewer than requested). (unit=range only.)"
              },
              "depth": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Levels expanded in subtree mode; null in ancestor_chain mode. (unit=toc only.)"
              },
              "esnad": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Raw isnad markers, one string per chain: «<zero-padded hadith key> s <narrator ids, Companion first, collector last>». Ids, not names; resolve with shamela_lookup_rijal(mode='isnad'). (unit=services only.)"
              },
              "pages": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "body": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Main text (matn) of the page."
                    },
                    "foot": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Footnotes: the editor's or commentator's words, not the author's."
                    },
                    "part": {
                      "$ref": "#/properties/part",
                      "description": "Volume/part label, e.g. '4'; null for single-volume books."
                    },
                    "comment": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "User annotation stored with the page, usually empty."
                    },
                    "page_id": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Internal page id."
                    },
                    "printed_page": {
                      "$ref": "#/properties/printed_page",
                      "description": "Printed page label as Shamela renders it, e.g. '4/ 405'; null when the page has no printed number."
                    }
                  },
                  "additionalProperties": true
                },
                "description": "Pages in reading order. (unit=range|section only.)"
              },
              "parts": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "part": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Part label as citations print it."
                    },
                    "page_count": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Page records in the part."
                    },
                    "last_page_id": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Last page id of the part."
                    },
                    "first_page_id": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "First page id of the part."
                    }
                  },
                  "additionalProperties": true
                },
                "description": "Volumes in reading order: whether a citation needs a part designator. Empty for a single-volume book unless its pages carry one part label (kept: citations print it). (unit=parts only.)"
              },
              "titles": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "page_id": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Page id where the heading starts."
                    },
                    "children": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": {}
                      },
                      "description": "Sub-headings with this same shape, present when depth reached them."
                    },
                    "title_id": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Title id; pass to shamela_read(unit='section')."
                    },
                    "parent_id": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Parent title id; 0 at top level."
                    },
                    "title_text": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Heading text."
                    },
                    "has_children": {
                      "type": [
                        "boolean",
                        "null"
                      ],
                      "description": "True when the heading has sub-headings."
                    }
                  },
                  "additionalProperties": true
                },
                "description": "Subtree mode: the headings, nested via children. Empty under a leaf. (unit=toc only.)"
              },
              "book_id": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Catalogue book id."
              },
              "comment": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "User annotation; returned with body_part 1 only. (unit=page only.)"
              },
              "hadeeth": {
                "type": "array",
                "items": {
                  "type": "number"
                },
                "description": "Numeric hadith keys, as stored; pass to shamela_lookup_hadith(mode='sources'). (unit=services only.)"
              },
              "page_id": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "[unit=page] Internal page id that was read. [unit=services] Page id. (unit=page|services only.)"
              },
              "_display": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Advice on presenting a long text (show in parts, or ask the user how); null when the text is short. (unit=page|range|section only.)"
              },
              "has_more": {
                "type": [
                  "boolean",
                  "null"
                ],
                "description": "True when pages exist after the last one returned. (unit=range only.)"
              },
              "title_id": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Heading that was read. (unit=section only.)"
              },
              "body_part": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "1-based part of the body returned. (unit=page only.)"
              },
              "book_name": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Catalogue title of the book (Arabic). (unit=page|range|section|toc|parts only.)"
              },
              "parent_id": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Parent expanded in subtree mode; null in ancestor_chain mode. (unit=toc only.)"
              },
              "truncated": {
                "type": [
                  "boolean",
                  "null"
                ],
                "description": "True when fewer pages were returned than the section has."
              },
              "title_text": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Heading text. (unit=section only.)"
              },
              "author_name": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Main author name. (unit=page|range|section only.)"
              },
              "end_page_id": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Last page id of the section. (unit=section only.)"
              },
              "esnad_count": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Number of isnad markers. (unit=services only.)"
              },
              "total_pages": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Page records in the book. (unit=parts only.)"
              },
              "has_services": {
                "type": [
                  "boolean",
                  "null"
                ],
                "description": "False when the page carries no markers (common outside hadith works). (unit=services only.)"
              },
              "next_page_id": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Next existing page id; null at the end. (unit=page only.)"
              },
              "prev_page_id": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Previous existing page id (ids have gaps); null at the start. (unit=page only.)"
              },
              "printed_page": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Printed page label as Shamela renders it, e.g. '4/ 405'; null when the page has no printed number. (unit=page only.)"
              },
              "rows_dropped": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "of": {
                      "type": "number"
                    },
                    "kept": {
                      "type": "number"
                    },
                    "field": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": true
                }
              },
              "body_has_more": {
                "type": [
                  "boolean",
                  "null"
                ],
                "description": "True when another body_part follows. (unit=page only.)"
              },
              "category_path": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Category names, broadest first. (unit=page only.)"
              },
              "start_page_id": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "[unit=range] First page id requested. [unit=section] First page id of the section. (unit=range|section only.)"
              },
              "ancestor_chain": {
                "type": "array",
                "items": {
                  "$ref": "#/properties/titles/items"
                },
                "description": "ancestor_chain mode: headings enclosing the page, root to leaf. (unit=toc only.)"
              },
              "is_multi_volume": {
                "type": [
                  "boolean",
                  "null"
                ],
                "description": "True when the pages carry more than one part label. (unit=parts only.)"
              },
              "body_total_parts": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "How many parts the body is split into. (unit=page only.)"
              },
              "containing_titles": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "page_id": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Page id of the heading."
                    },
                    "title_id": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Title id."
                    },
                    "title_text": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Heading text."
                    }
                  },
                  "additionalProperties": true
                },
                "description": "Chapter headings enclosing the page, root to leaf. (unit=page only.)"
              },
              "next_start_page_id": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "[unit=range] Where to continue when the size budget cut the range short; null otherwise. [unit=section] Continue with shamela_read(unit='range') from here; null when the section is complete. (unit=range|section only.)"
              },
              "truncation_message": {
                "type": "string"
              },
              "total_pages_in_section": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Pages the whole section spans. (unit=section only.)"
              }
            },
            "additionalProperties": true
          },
          "annotations": {
            "readOnlyHint": true,
            "openWorldHint": false,
            "idempotentHint": true,
            "destructiveHint": false
          }
        },
        {
          "name": "shamela_get_details",
          "title": "Get book or author details",
          "description": "Catalogue record for one book (kind=book, default) or one author (kind=author), installed or not.\n- book: authors, category, type, printed-edition flag, whether the text is installed here, the scanned printing and the other editions of the same work (same_group). When a reader tool says BOOK_NOT_DOWNLOADED, pick an installed entry from same_group or answer from this record. Read book_date, edition, editor and publisher per their field notes: never supply a missing one.\n- author: name, Hijri death year (null = unknown or living) and every catalogued book they wrote or co-wrote, each flagged installed or not.\nVolumes → shamela_read(unit='parts'); a book by title or subject → shamela_find(kind='book'). Errors: BOOK_NOT_FOUND, AUTHOR_NOT_FOUND.",
          "inputSchema": {
            "type": "object",
            "$schema": "http://json-schema.org/draft-07/schema#",
            "properties": {
              "kind": {
                "enum": [
                  "book",
                  "author"
                ],
                "type": "string",
                "description": "Selects what the call does: book | author. Default book."
              },
              "book_id": {
                "type": "integer",
                "description": "The book id (e.g. 9942). (kind=book only.)",
                "exclusiveMinimum": 0
              },
              "author_id": {
                "type": "integer",
                "description": "The author id (e.g. 474 for Ibn Qudama, 57 for Ibn Uthaymeen), from shamela_find(kind='name') with type 'author' or a book's authors[]. A catalogue id, not a death year or book id; shamela_find(kind='author') also gives it. (kind=author only.)",
                "exclusiveMinimum": 0
              },
              "include_books": {
                "type": "boolean",
                "description": "If true (default), include every catalogued book by this author, main or co-author, ordered by book_id. False returns name and death year only. (kind=author only.)"
              },
              "include_cover": {
                "type": "boolean",
                "description": "Attach the book's cover image as an MCP image block when Shamela ships one (1,368 of 8,594 books). The picture is a ~310x460 thumbnail of the scanned printing's title page, so it costs roughly 190 image tokens. Set false to keep the reply text-only; `cover.available` still reports whether one exists. Default: true. (kind=book only.)"
              },
              "response_format": {
                "enum": [
                  "markdown",
                  "json",
                  "none"
                ],
                "type": "string",
                "description": "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)."
              }
            },
            "additionalProperties": false
          },
          "outputSchema": {
            "type": "object",
            "$schema": "http://json-schema.org/draft-07/schema#",
            "properties": {
              "scan": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "urls": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        },
                        "description": "Resolved download URLs."
                      },
                      "file_count": {
                        "type": [
                          "number",
                          "null"
                        ],
                        "description": "Number of PDF files."
                      },
                      "size_bytes": {
                        "type": [
                          "number",
                          "null"
                        ],
                        "description": "Total size in bytes."
                      },
                      "shamela_paths": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        },
                        "description": "Shamela-hosted paths, when any."
                      }
                    },
                    "additionalProperties": true
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The scanned printing Shamela holds; null when none. (kind=book only.)"
              },
              "books": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "book_id": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Catalogue book id."
                    },
                    "book_date": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Shamela «تاريخ الكتاب», Hijri."
                    },
                    "book_name": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Catalogue title of the book (Arabic)."
                    },
                    "downloaded": {
                      "type": [
                        "boolean",
                        "null"
                      ],
                      "description": "True when installed on this server."
                    }
                  },
                  "additionalProperties": true
                },
                "description": "The author's books by ascending book_id; empty when include_books is false. (kind=author only.)"
              },
              "cover": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "bytes": {
                        "type": [
                          "number",
                          "null"
                        ],
                        "description": "JPEG size."
                      },
                      "width": {
                        "type": [
                          "number",
                          "null"
                        ],
                        "description": "Pixels."
                      },
                      "height": {
                        "type": [
                          "number",
                          "null"
                        ],
                        "description": "Pixels."
                      },
                      "attached": {
                        "type": [
                          "boolean",
                          "null"
                        ],
                        "description": "True when it was attached as an image block."
                      },
                      "available": {
                        "type": [
                          "boolean",
                          "null"
                        ],
                        "description": "True when a cover image exists."
                      }
                    },
                    "additionalProperties": true
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "Title-page thumbnail of the scanned printing; null when none. Says nothing about the real binding or whether a scan exists (377 books have a `scan` but no cover): read `scan`. (kind=book only.)"
              },
              "notes": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Caveats, including citation fields the catalogue lacks. (kind=book only.)"
              },
              "editor": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Editor (محقق) from the front matter; null when absent. (kind=book only.)"
              },
              "authors": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "role": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "'main' or 'co'."
                    },
                    "author_id": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Author id; pass to shamela_get_details(kind='author')."
                    },
                    "death_year": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Hijri death year; null when unknown."
                    },
                    "author_name": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Author name."
                    }
                  },
                  "additionalProperties": true
                },
                "description": "Authors, main author first. (kind=book only.)"
              },
              "book_id": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Catalogue book id. (kind=book only.)"
              },
              "edition": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Edition read from the book's front matter; null when absent. Never invent one. (kind=book only.)"
              },
              "printed": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "1 when page numbers follow a printed edition; otherwise Shamela numbers the pages itself. (kind=book only.)"
              },
              "category": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Category name. (kind=book only.)"
              },
              "author_id": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Author id. (kind=author only.)"
              },
              "available": {
                "type": [
                  "boolean",
                  "null"
                ],
                "description": "True when Shamela offers the book for download. (kind=book only.)"
              },
              "book_date": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Shamela «تاريخ الكتاب», Hijri; on 98.5% of dated books the main author's death year, not a composition year: never cite it as one. (kind=book only.)"
              },
              "book_name": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Catalogue title of the book (Arabic). (kind=book only.)"
              },
              "book_type": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Numeric book type. (kind=book only.)"
              },
              "pdf_links": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Raw scan descriptor from the catalogue; prefer `scan`. (kind=book only.)"
              },
              "publisher": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Publisher from the front matter; null when absent. (kind=book only.)"
              },
              "sub_books": {
                "type": "array",
                "items": {
                  "type": "number"
                },
                "description": "Catalogue ids of books bound inside this one. (kind=book only.)"
              },
              "truncated": {
                "type": "boolean"
              },
              "book_count": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Number of catalogue books (main or co-author). (kind=author only.)"
              },
              "death_text": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Death date as display text. (kind=author only.)"
              },
              "death_year": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Hijri death year; null when unknown or living. (kind=author only.)"
              },
              "downloaded": {
                "type": [
                  "boolean",
                  "null"
                ],
                "description": "True only when the text is installed on this server and has pages. (kind=book only.)"
              },
              "same_group": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "book_id": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Catalogue book id."
                    },
                    "printed": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "1 when paginated after a printed edition."
                    },
                    "book_name": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Catalogue title of the book (Arabic)."
                    },
                    "downloaded": {
                      "type": [
                        "boolean",
                        "null"
                      ],
                      "description": "True when installed on this server."
                    }
                  },
                  "additionalProperties": true
                },
                "description": "Other catalogue entries of the same work (editions, abridgments: Sahih al-Bukhari is 8, five editions and three abridgments). Quotes from two of them are one source. (kind=book only.)"
              },
              "author_name": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Author name. (kind=author only.)"
              },
              "category_id": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Category id (see shamela_find(kind='category')). (kind=book only.)"
              },
              "rows_dropped": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "of": {
                      "type": "number"
                    },
                    "kept": {
                      "type": "number"
                    },
                    "field": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": true
                }
              },
              "content_status": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "'readable', 'downloaded_no_pages' or 'not_downloaded'. (kind=book only.)"
              },
              "book_type_label": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Book type in Arabic: printed, manuscript, journal, thesis, electronic or audio. (kind=book only.)"
              },
              "publication_date": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Hijri publication date, DDMMYYYY, from meta_data, when recorded. (kind=book only.)"
              },
              "truncation_message": {
                "type": "string"
              }
            },
            "additionalProperties": true
          },
          "annotations": {
            "readOnlyHint": true,
            "openWorldHint": false,
            "idempotentHint": true,
            "destructiveHint": false
          }
        },
        {
          "name": "shamela_cite",
          "title": "Format a citation or resolve a printed page",
          "description": "Citations. mode=citation (default): build one for a book, optionally a page and quoted text — Shamela's copy format, short inline, full with death year, or BibTeX/RIS. Call it whenever you attribute a quote; it needs only the catalogue, plus the installed text for a page's printed number. Read page_resolved, components.auto_numbered and notes[] before presenting.\nmode=printed_page: map a printed citation («vol. 4, p. 405») to the page_ids carrying it — no arithmetic relates the two, and one printed page often spans several ids: read them all, in order, with shamela_read(unit='page'). Resolve the work with shamela_find(kind='work') first; holding a page_id already, skip this. Failures come back as `status`; citable:false = Shamela's own numbering. Error: BOOK_NOT_FOUND.",
          "inputSchema": {
            "type": "object",
            "$schema": "http://json-schema.org/draft-07/schema#",
            "properties": {
              "mode": {
                "enum": [
                  "citation",
                  "printed_page"
                ],
                "type": "string",
                "description": "Selects what the call does: citation | printed_page. Default citation."
              },
              "page": {
                "type": "integer",
                "minimum": 1,
                "description": "The PRINTED page number as the citation gives it (e.g. 405). Example: {book_id:6910, part:'4', page:405}; {book_id:1681, part:'1', page:6}. (mode=printed_page only.)"
              },
              "part": {
                "type": "string",
                "description": "The volume/part label as the book uses it, usually a bare number ('4'). Omit when the citation names no volume or the work is single-volume: the search then runs across every part and the response reports which parts matched, so an ambiguous page number is visible rather than silently resolved to the first volume. (mode=printed_page only.)"
              },
              "text": {
                "type": "string",
                "description": "Optional quoted text. Used by the 'shamela' style only, which then prints a two-line block: «<book>» (<part>/ <page>):\n«<text>». Other styles ignore it. (mode=citation only.)"
              },
              "style": {
                "enum": [
                  "shamela",
                  "short",
                  "full",
                  "bibtex",
                  "ris"
                ],
                "type": "string",
                "description": "Citation style. 'shamela' replicates Shamela's UI copy-with-citation format (default). 'short' is a one-line inline reference. 'full' is the long form including author death year and book year, with notes listing missing fields (publisher/edition/etc are not in master.db). 'bibtex' and 'ris' are machine-readable exports for Zotero/EndNote/Mendeley (Western digits, Arabic UTF-8, stable cite key shamela<book_id>p<page_id>); they carry only fields master.db has, with the same missing-field notes[]. 'short' reads <author>، <book>، ص <page>. Every style but bibtex/ris uses Arabic-Indic digits. (mode=citation only.)"
              },
              "book_id": {
                "type": "integer",
                "description": "[mode=citation] The book id, from shamela_find(kind='book'), shamela_find(kind='work') or shamela_find(kind='name'). [mode=printed_page] The book. Resolve a cited title with shamela_find(kind='work') first — and note that different printings of one work paginate differently, so the book_id must be the printing the citation came from.",
                "exclusiveMinimum": 0
              },
              "page_id": {
                "type": "integer",
                "description": "Optional page_id. When omitted, the citation references the book without a specific page and page_resolved is null. A page id that is missing, has no printed number, or belongs to a book whose text is not installed here yields a book-level citation with page_resolved:false and a note. Example: {book_id:1681, page_id:10}, or with text:'<quoted passage>', style:'shamela'. (mode=citation only.)",
                "exclusiveMinimum": 0
              },
              "response_format": {
                "enum": [
                  "markdown",
                  "json",
                  "none"
                ],
                "type": "string",
                "description": "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)."
              }
            },
            "additionalProperties": false
          },
          "outputSchema": {
            "type": "object",
            "$schema": "http://json-schema.org/draft-07/schema#",
            "properties": {
              "notes": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "[mode=citation] Missing citation fields and fallbacks; never fill them in. [mode=printed_page] Guidance on reading the result."
              },
              "style": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "'shamela', 'short', 'full', 'bibtex' or 'ris'. (mode=citation only.)"
              },
              "status": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "'ok', 'book_not_downloaded', 'no_printed_pagination' (Shamela paginates this entry itself: no printed page exists), 'part_not_found' or 'page_not_in_part'. (mode=printed_page only.)"
              },
              "book_id": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Catalogue book id. (mode=printed_page only.)"
              },
              "citable": {
                "type": [
                  "boolean",
                  "null"
                ],
                "description": "False when the numbers are Shamela's own, not a printed edition's. (mode=printed_page only.)"
              },
              "matches": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "page": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Printed page number."
                    },
                    "part": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Part label."
                    },
                    "page_id": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Page id."
                    },
                    "printed_page": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Label as the page tools render it, e.g. '4/ 405'."
                    }
                  },
                  "additionalProperties": true
                },
                "description": "One row per page id. (mode=printed_page only.)"
              },
              "page_ids": {
                "type": "array",
                "items": {
                  "type": "number"
                },
                "description": "Every page id carrying the printed page, in reading order; read them all. Shamela splits a long printed page across records, so one page routinely has several ids (part '1', page 6 of book 1681 = ids 9, 10, 11 in the fixture). (mode=printed_page only.)"
              },
              "book_name": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Catalogue title of the book (Arabic). (mode=printed_page only.)"
              },
              "formatted": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The citation text in the requested style. (mode=citation only.)"
              },
              "truncated": {
                "type": "boolean"
              },
              "components": {
                "type": "object",
                "properties": {
                  "part": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Volume label."
                  },
                  "book_id": {
                    "type": [
                      "number",
                      "null"
                    ],
                    "description": "Catalogue book id."
                  },
                  "author_id": {
                    "type": [
                      "number",
                      "null"
                    ],
                    "description": "Main author id."
                  },
                  "book_date": {
                    "type": [
                      "number",
                      "null"
                    ],
                    "description": "Shamela «تاريخ الكتاب», Hijri."
                  },
                  "book_name": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Catalogue title of the book (Arabic)."
                  },
                  "death_year": {
                    "type": [
                      "number",
                      "null"
                    ],
                    "description": "Author's Hijri death year."
                  },
                  "author_name": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Main author name."
                  },
                  "printed_page": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Printed page label."
                  },
                  "auto_numbered": {
                    "type": [
                      "boolean",
                      "null"
                    ],
                    "description": "True when page numbers are Shamela's own («بترقيم الشاملة آليا»), not a printed edition's: say so whenever you present the citation, never as a printed page."
                  }
                },
                "description": "The parts the citation was built from. (mode=citation only.)",
                "additionalProperties": true
              },
              "page_range": {
                "type": "object",
                "properties": {
                  "max": {
                    "type": [
                      "number",
                      "null"
                    ],
                    "description": "Highest printed page."
                  },
                  "min": {
                    "type": [
                      "number",
                      "null"
                    ],
                    "description": "Lowest printed page."
                  }
                },
                "description": "On page_not_in_part: the printed range that exists in that part. (mode=printed_page only.)",
                "additionalProperties": true
              },
              "rows_dropped": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "of": {
                      "type": "number"
                    },
                    "kept": {
                      "type": "number"
                    },
                    "field": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": true
                }
              },
              "page_resolved": {
                "type": [
                  "boolean",
                  "null"
                ],
                "description": "True when the page and its printed number were found; false when the citation fell back to book level (see notes) and must not be presented as a page reference; null when no page_id was given. (mode=citation only.)"
              },
              "parts_matched": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Distinct parts matched; more than one means the number is ambiguous across volumes. (mode=printed_page only.)"
              },
              "requested_page": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Printed page requested. (mode=printed_page only.)"
              },
              "requested_part": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Part label requested; null when omitted. (mode=printed_page only.)"
              },
              "available_parts": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "On part_not_found: the part labels the book uses. (mode=printed_page only.)"
              },
              "truncation_message": {
                "type": "string"
              }
            },
            "additionalProperties": true
          },
          "annotations": {
            "readOnlyHint": true,
            "openWorldHint": false,
            "idempotentHint": true,
            "destructiveHint": false
          }
        },
        {
          "name": "shamela_lookup_quran",
          "title": "Search the Quran or get an ayah",
          "description": "Qur'an text. mode=search (default): find verses by Arabic words, typed in إملائي spelling or pasted in Uthmani rasm; words ANDed, results in mushaf order (aya_id 1–6236), not relevance. Zero hits usually means a misspelling: drop a word or use options.wildcards.\nmode=aya: fetch verses you can already cite, by aya_id OR surah + aya (never both or neither: BAD_ARG); `count` gives a run that continues across surahs and stops at the last verse. Each verse in three renderings (body = the spelling search matches, amiri for display). AYA_NOT_FOUND names the valid range.\nCommentary → shamela_lookup_tafsir; the words inside books → shamela_search(match='words').",
          "inputSchema": {
            "type": "object",
            "$schema": "http://json-schema.org/draft-07/schema#",
            "properties": {
              "aya": {
                "type": "integer",
                "minimum": 1,
                "description": "Aya number within the surah, 1..N. Pair with `surah`. (mode=aya only.)"
              },
              "mode": {
                "enum": [
                  "search",
                  "aya"
                ],
                "type": "string",
                "description": "Selects what the call does: search | aya. Default search."
              },
              "count": {
                "type": "integer",
                "maximum": 20,
                "minimum": 1,
                "description": "How many consecutive verses to return, starting at the one resolved above (1-20, default 1). Use it for a passage — «the last two verses of al-Baqara» is surah=2, aya=285, count=2, and a short surah comes back in one call. The response always reports `surah_ayat`, that surah's total verse count, so you never have to guess how many to ask for. Verses continue across the surah boundary; each carries its own surah/aya. E.g. {surah:112, aya:1, count:4} = all of al-Ikhlas. (mode=aya only.)"
              },
              "limit": {
                "type": "integer",
                "maximum": 100,
                "minimum": 1,
                "description": "Maximum number of results to return (1-100, default 20). (mode=search only.)"
              },
              "query": {
                "type": "string",
                "minLength": 1,
                "description": "Arabic text of a verse or part of one. Matched against all 6,236 verses in BOTH orthographies — the Egyptian إملائي spelling a user types from memory AND the Uthmani rasm that mushaf apps, quran.com and PDFs copy (ٱ, dagger alef, ﴿﴾, full tashkeel are all handled), so paste the verse exactly as you received it. Every word is ANDed. Single-word queries also match prefixed forms (e.g. «الصبر» matches «بالصبر») AND the same word with «ال» stripped («الملك» is also searched as «ملك»/«للملك»), which widens the answer past the word you typed — the response names those forms in `stem_expanded_to`, tags each hit with the `matched_form` it came in on, and reports in `query_form_hits` how many verses match your word itself. Results come back in mushaf order (aya_id), not by relevance. Hafs from Asim text, pre-built aya/ Lucene index. (mode=search only.)"
              },
              "surah": {
                "type": "integer",
                "maximum": 114,
                "minimum": 1,
                "description": "Surah number 1..114. Pair with `aya`. E.g. {surah:55, aya:1} = Ar-Rahman 1. (mode=aya only.)"
              },
              "aya_id": {
                "type": "integer",
                "maximum": 6236,
                "minimum": 1,
                "description": "Cumulative aya id, 1..6236. Mutually exclusive with surah/aya. E.g. 1 = al-Fatiha 1 (the basmala). (mode=aya only.)"
              },
              "offset": {
                "type": "integer",
                "minimum": 0,
                "description": "Number 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. Default: 0. (mode=search only.)"
              },
              "options": {
                "type": "object",
                "properties": {
                  "wildcards": {
                    "type": "boolean",
                    "description": "Interpret `*` (zero-or-more characters) and `?` (exactly-one character) within tokens. Examples: `صيا*` matches صيام/صيامهم, `ص?م` matches صام/صوم/صمم. Leading wildcards (`*ابن`) are slow. Cannot combine with `morphology`. With this OFF, `*` and `?` are treated as ordinary punctuation and split the word, so a stray one no longer zeroes the search. CAVEAT on prefixes: the index folds some words as a WHOLE — «مائة» is stored as «ميه», «داوود» as «داود» — and a wildcard stem is folded without the letters the wildcard replaced, so `مائ*` becomes `ماي*` and reaches مائع/مائدة but NOT مائة. When a prefix search returns less than you expect for a word like these, search the full word without a wildcard instead. Default: false."
                  }
                },
                "description": "Currently only the `wildcards` flag is honored. The Quranic index ships pre-built and zero-config. `*` stands for any letters, `?` for one: {query:'الرحم*', options:{wildcards:true}} finds 57 verses. (mode=search only.)",
                "additionalProperties": false
              },
              "response_format": {
                "enum": [
                  "markdown",
                  "json",
                  "none"
                ],
                "type": "string",
                "description": "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)."
              }
            },
            "additionalProperties": false
          },
          "outputSchema": {
            "type": "object",
            "$schema": "http://json-schema.org/draft-07/schema#",
            "properties": {
              "aya": {
                "type": "integer",
                "description": "Verse number within the surah. (mode=aya only.)"
              },
              "body": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Standard Egyptian imla'i spelling, Hafs from Asim — the form text search matches. (mode=aya only.)"
              },
              "amiri": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Uthmani-script rendering (Amiri), for display to the reader. (mode=aya only.)"
              },
              "majma": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "KFQPC Mushaf rendering. (mode=aya only.)"
              },
              "query": {
                "type": "string",
                "description": "The query as received. (mode=search only.)"
              },
              "surah": {
                "type": "integer",
                "description": "Surah number, 1..114. (mode=aya only.)"
              },
              "aya_id": {
                "type": "integer",
                "description": "Cumulative verse id, 1..6236. (mode=aya only.)"
              },
              "offset": {
                "type": "number",
                "description": "Offset this page started at. (mode=search only.)"
              },
              "verses": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "aya": {
                      "$ref": "#/properties/aya",
                      "description": "Verse number within the surah."
                    },
                    "body": {
                      "$ref": "#/properties/body",
                      "description": "Standard Egyptian imla'i spelling, Hafs from Asim — the form text search matches."
                    },
                    "amiri": {
                      "$ref": "#/properties/amiri",
                      "description": "Uthmani-script rendering (Amiri), for display to the reader."
                    },
                    "majma": {
                      "$ref": "#/properties/majma",
                      "description": "KFQPC Mushaf rendering."
                    },
                    "surah": {
                      "$ref": "#/properties/surah",
                      "description": "Surah number, 1..114."
                    },
                    "aya_id": {
                      "$ref": "#/properties/aya_id",
                      "description": "Cumulative verse id, 1..6236."
                    },
                    "surah_name": {
                      "$ref": "#/properties/surah_name",
                      "description": "Arabic surah name."
                    }
                  },
                  "additionalProperties": true
                },
                "description": "The requested run in order; the top-level fields repeat verses[0]. (mode=aya only.)"
              },
              "results": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": {}
                },
                "description": "Verses in mushaf order: aya_id (1-6236), surah, surah_name, aya, body (full verse), snippet_body (<mark>…</mark> around matches), matched_orthography, matched_form (single-word queries: the searched form the verse came in on; one listed in stem_expanded_to means the stem matched, not your word, e.g. مَٰلِكِ in 1:4 for «الملك»). (mode=search only.)"
              },
              "has_more": {
                "type": "boolean",
                "description": "True when another page exists; call again with `next_offset`. (mode=search only.)"
              },
              "returned": {
                "type": "number",
                "description": "[mode=search] Rows in `results` on this call. [mode=aya] Number of verses in `verses`."
              },
              "truncated": {
                "type": "boolean"
              },
              "surah_ayat": {
                "type": "integer",
                "description": "Total verses in the first verse's surah, so you can ask for the rest with `count`. (mode=aya only.)"
              },
              "surah_name": {
                "type": "string",
                "description": "Arabic surah name. (mode=aya only.)"
              },
              "total_hits": {
                "type": "number",
                "description": "Every match in scope, not just the rows returned. (mode=search only.)"
              },
              "next_offset": {
                "type": "number",
                "description": "Offset of the next page. Absent on the last page. (mode=search only.)"
              },
              "rows_dropped": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "of": {
                      "type": "number"
                    },
                    "kept": {
                      "type": "number"
                    },
                    "field": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": true
                }
              },
              "paging_ceiling": {
                "type": "number",
                "description": "Deepest offset paging can reach. Present only when the request went past it: narrow the scope instead of paging further. (mode=search only.)"
              },
              "query_form_hits": {
                "type": "number",
                "description": "Verses matching the word as typed (or its prefixed forms) rather than the stem: «الملك» returns 60 verses, 28 of them this way. (mode=search only.)"
              },
              "terms_truncated": {
                "type": "boolean",
                "description": "True when the query had more words than are searched. (mode=search only.)"
              },
              "stem_expanded_to": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Single-word queries: the extra forms searched beyond the word as typed. (mode=search only.)"
              },
              "normalized_tokens": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "The query after Arabic folding, as actually searched. (mode=search only.)"
              },
              "truncation_message": {
                "type": "string"
              },
              "total_hits_complete": {
                "type": "boolean",
                "description": "False when total_hits is a lower bound. (mode=search only.)"
              }
            },
            "additionalProperties": true
          },
          "annotations": {
            "readOnlyHint": true,
            "openWorldHint": false,
            "idempotentHint": true,
            "destructiveHint": false
          }
        },
        {
          "name": "shamela_lookup_tafsir",
          "title": "Tafsir coverage and texts for an ayah",
          "description": "Tafsir on one verse (aya_id OR surah + aya, else BAD_ARG). mode=coverage (default): which tafsir books cover it, fetching no text — shelves 3 (tafsir) and 4 (Qur'anic sciences; not 5, tajwid and qira'at) crossed with Shamela's curated tafsir index, plus index hits from other shelves (in_tafsir_categories:false). Status per book: indexed_covers (with page_id), indexed_no_entry_for_this_aya, or not_indexed_coverage_unknown — NOT evidence the book is silent.\nmode=texts: the commentary from several books in one call, each attributed (book, author, death year, printed page), read only from pages the index maps to the verse, never a text-search guess. Each source's `note` names the next call when its text continues. Example: {surah:2, aya:255, book_ids:[1503, 639]}.",
          "inputSchema": {
            "type": "object",
            "$schema": "http://json-schema.org/draft-07/schema#",
            "properties": {
              "aya": {
                "type": "integer",
                "minimum": 1,
                "description": "Verse number within the surah, 1..N; requires `surah`."
              },
              "mode": {
                "enum": [
                  "coverage",
                  "texts"
                ],
                "type": "string",
                "description": "Selects what the call does: coverage | texts. Default coverage."
              },
              "surah": {
                "type": "integer",
                "maximum": 114,
                "minimum": 1,
                "description": "Surah number 1..114; requires `aya`. Alternative to aya_id."
              },
              "aya_id": {
                "type": "integer",
                "maximum": 6236,
                "minimum": 1,
                "description": "Cumulative verse id, 1..6236 (e.g. 262 = 2:255). Give this OR surah + aya, not both; a reference that disagrees with surah/aya is BAD_ARG."
              },
              "book_ids": {
                "type": "array",
                "items": {
                  "type": "integer",
                  "exclusiveMinimum": 0
                },
                "description": "Restrict to these tafsir books, read in the order given (omit it and the installed indexed books are read earliest author first). Books not present in the curated index for this aya are reported with an explicit status instead of text. Use shamela_lookup_tafsir(mode='coverage') to see which books the index covers. (mode=texts only.)"
              },
              "max_sources": {
                "type": "integer",
                "maximum": 10,
                "minimum": 1,
                "description": "Maximum number of sources to fetch text for (1-10, default 5). The response-size budget can stop earlier; `remaining_book_ids` lists the sources not read, to pass as book_ids next. (mode=texts only.)"
              },
              "downloaded_only": {
                "type": "boolean",
                "description": "If true (default), list only books whose text is installed on this server. false also lists books the curated index maps to this aya whose text is not installed (downloaded:false) — still useful as catalogue references. (mode=coverage only.)"
              },
              "response_format": {
                "enum": [
                  "markdown",
                  "json",
                  "none"
                ],
                "type": "string",
                "description": "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)."
              }
            },
            "additionalProperties": false
          },
          "outputSchema": {
            "type": "object",
            "$schema": "http://json-schema.org/draft-07/schema#",
            "properties": {
              "aya": {
                "type": "integer"
              },
              "note": {
                "type": "string",
                "description": "Caveat: the index is curated, so unknown status is not absence."
              },
              "books": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "description": "indexed_covers (page_id/printed_page point at the commentary) | indexed_no_entry_for_this_aya | not_indexed_coverage_unknown (absence from the curated index is not evidence the book is silent: many tafsirs carry no per-page aya markers, and on some installs the index holds only al-Tabari; reach it through shamela_read(unit='toc'))."
                    },
                    "book_id": {
                      "type": "integer"
                    },
                    "page_id": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Commentary page; set only when status is indexed_covers."
                    },
                    "book_name": {
                      "type": "string"
                    },
                    "death_year": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Author's death year AH."
                    },
                    "downloaded": {
                      "type": "boolean"
                    },
                    "author_name": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "category_id": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "printed_page": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "category_name": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "in_tafsir_categories": {
                      "type": "boolean",
                      "description": "False for index hits on other shelves: the tafsir shelves crossed here are categories 3 (tafsir) and 4 (Qur'anic sciences)."
                    }
                  },
                  "additionalProperties": true
                },
                "description": "Every tafsir-shelf book plus index hits, ordered by status, installed first, then book_id; a long list is cut (rows_dropped). (mode=coverage only.)"
              },
              "surah": {
                "type": "integer"
              },
              "total": {
                "type": "integer",
                "description": "Distinct books the index maps to this verse, installed or not. (mode=coverage only.)"
              },
              "aya_id": {
                "type": "integer",
                "description": "Cumulative verse id, 1..6236."
              },
              "totals": {
                "type": "object",
                "properties": {
                  "indexed_covers": {
                    "type": "integer"
                  },
                  "not_indexed_coverage_unknown": {
                    "type": "integer"
                  },
                  "indexed_no_entry_for_this_aya": {
                    "type": "integer"
                  }
                },
                "description": "Count of books in each coverage status. (mode=coverage only.)",
                "additionalProperties": true
              },
              "fetched": {
                "type": "integer",
                "description": "Sources whose text was read. (mode=texts only.)"
              },
              "results": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "book_id": {
                      "type": "integer"
                    },
                    "page_id": {
                      "type": "integer",
                      "description": "Page the index points to in this book."
                    },
                    "book_name": {
                      "type": "string"
                    },
                    "downloaded": {
                      "type": "boolean",
                      "description": "True when the book's text is installed on this server."
                    },
                    "author_name": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "additionalProperties": true
                },
                "description": "The index hits alone, repeating books[] rows; filtered by downloaded_only (false adds hits whose text is not installed, downloaded:false). (mode=coverage only.)"
              },
              "sources": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "foot": {
                      "type": "string",
                      "description": "Footnotes — the editor's words, not the author's."
                    },
                    "note": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "The exact follow-up call, when one is needed."
                    },
                    "text": {
                      "type": "string",
                      "description": "Commentary text (matn)."
                    },
                    "status": {
                      "type": "string",
                      "description": "ok | ok_unpaginated | not_indexed | no_entry_for_this_aya | not_downloaded; only ok* carry text."
                    },
                    "book_id": {
                      "type": "integer"
                    },
                    "page_id": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "book_name": {
                      "type": "string"
                    },
                    "text_part": {
                      "type": "integer"
                    },
                    "death_year": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "author_name": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "next_page_id": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Following page id, to read on with shamela_read(unit='page')."
                    },
                    "printed_page": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "text_has_more": {
                      "type": "boolean",
                      "description": "True when the commentary continues past this part; `note` names the exact next call."
                    },
                    "text_total_parts": {
                      "type": "integer"
                    },
                    "continued_page_id": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "The page joined onto `text`; a «[— بداية …]» line in `text` marks where it starts."
                    },
                    "verse_located_in_page": {
                      "type": "boolean",
                      "description": "False when the whole page was returned (with a note) because the verse could not be pinned, e.g. a refrain like «فبأي آلاء ربكما تكذبان» quoted several times on the page with no printed verse number to settle which copy — never a neighbouring verse's commentary instead."
                    },
                    "continued_on_next_page": {
                      "type": "boolean"
                    },
                    "continued_printed_page": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Printed page of the joined page — cite this, not `printed_page`, for text after the marker."
                    }
                  },
                  "additionalProperties": true
                },
                "description": "Read only from pages the curated service/tafseer.db maps to this verse; there is no text-search fallback, which misattributes verses through shared phrases and the basmala. (mode=texts only.)"
              },
              "_display": {
                "type": [
                  "string",
                  "null"
                ],
                "description": " (mode=texts only.)"
              },
              "returned": {
                "type": "integer",
                "description": "Rows in `results`. (mode=coverage only.)"
              },
              "truncated": {
                "type": "boolean"
              },
              "surah_name": {
                "type": "string"
              },
              "rows_dropped": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "of": {
                      "type": "number"
                    },
                    "kept": {
                      "type": "number"
                    },
                    "field": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": true
                }
              },
              "coverage_note": {
                "type": "string",
                "description": " (mode=coverage only.)"
              },
              "index_entries": {
                "type": "integer",
                "description": "Raw index rows; exceeds `total` when commentary spans pages. (mode=coverage only.)"
              },
              "total_indexed": {
                "type": "integer",
                "description": "Books the curated index maps to this verse. (mode=texts only.)"
              },
              "remaining_book_ids": {
                "type": "array",
                "items": {
                  "type": "integer"
                },
                "description": "Indexed sources not read in this call; pass as book_ids to continue. (mode=texts only.)"
              },
              "truncation_message": {
                "type": "string"
              }
            },
            "additionalProperties": true
          },
          "annotations": {
            "readOnlyHint": true,
            "openWorldHint": false,
            "idempotentHint": true,
            "destructiveHint": false
          }
        },
        {
          "name": "shamela_lookup_hadith",
          "title": "Find a hadith or the books that carry it",
          "description": "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.\nmode=sources: every book recording one hadith_key, with its page_id, one row per book in index order.\nA 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').",
          "inputSchema": {
            "type": "object",
            "$schema": "http://json-schema.org/draft-07/schema#",
            "properties": {
              "mode": {
                "enum": [
                  "search",
                  "sources"
                ],
                "type": "string",
                "description": "Selects what the call does: search | sources. Default search."
              },
              "limit": {
                "type": "integer",
                "maximum": 100,
                "minimum": 1,
                "description": "Maximum number of results to return (1-100, default 20). (mode=search only.)"
              },
              "query": {
                "type": "string",
                "minLength": 1,
                "description": "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": {
                "type": "integer",
                "description": "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.)",
                "exclusiveMinimum": 0
              },
              "downloaded_only": {
                "type": "boolean",
                "description": "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": {
                "enum": [
                  "markdown",
                  "json",
                  "none"
                ],
                "type": "string",
                "description": "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": {
                "type": "integer",
                "maximum": 50,
                "minimum": 1,
                "description": "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": {
                "type": "boolean",
                "description": "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.)"
              }
            },
            "additionalProperties": false
          },
          "outputSchema": {
            "type": "object",
            "$schema": "http://json-schema.org/draft-07/schema#",
            "properties": {
              "query": {
                "type": "string",
                "description": "The query as received. (mode=search only.)"
              },
              "total": {
                "type": "integer",
                "description": "Distinct books carrying the key, installed or not. (mode=sources only.)"
              },
              "matches": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": {}
                },
                "description": "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": {
                "type": "object",
                "properties": {
                  "dropped_term": {
                    "type": "string"
                  },
                  "searched_query": {
                    "type": "string"
                  }
                },
                "description": "Present when the full text matched nothing and one word was dropped. (mode=search only.)",
                "additionalProperties": true
              },
              "results": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "book_id": {
                      "type": "integer"
                    },
                    "page_id": {
                      "type": "integer",
                      "description": "Page the index points to in this book."
                    },
                    "book_name": {
                      "type": "string"
                    },
                    "downloaded": {
                      "type": "boolean",
                      "description": "True when the book's text is installed on this server."
                    },
                    "author_name": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "additionalProperties": true
                },
                "description": "One row per book, in index order, with its first page for the hadith. (mode=sources only.)"
              },
              "takhrij": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "books": {
                      "type": "array",
                      "items": {
                        "$ref": "#/properties/matches/items"
                      },
                      "description": "Collections narrating it: book_id, book_name, author_name, page_id, downloaded (false = text not installed on this server)."
                    },
                    "hadith_key": {
                      "type": "number",
                      "description": "Hadith key found on a matched page."
                    },
                    "index_entries": {
                      "type": "number",
                      "description": "Indexed pages behind this key."
                    }
                  },
                  "additionalProperties": true
                },
                "description": "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": {
                "type": "integer",
                "description": "Rows in `results` after downloaded_only. (mode=sources only.)"
              },
              "searched": {
                "type": "string",
                "description": "'hadith_shelves' (default) or 'whole_library' (search_all_categories). (mode=search only.)"
              },
              "truncated": {
                "type": "boolean"
              },
              "hadith_key": {
                "type": "integer",
                "description": " (mode=sources only.)"
              },
              "rows_dropped": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "of": {
                      "type": "number"
                    },
                    "kept": {
                      "type": "number"
                    },
                    "field": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": true
                }
              },
              "index_entries": {
                "type": "integer",
                "description": "Raw index rows behind `total`. (mode=sources only.)"
              },
              "pages_scanned": {
                "type": "number",
                "description": "Top matches read for hadith keys (<= max_pages_scanned). (mode=search only.)"
              },
              "books_searched": {
                "type": "number",
                "description": "Books the text search covered: the hadith shelves (كتب السنة، شروح الحديث، التخريج والأطراف، علوم الحديث), 1,957 here. (mode=search only.)"
              },
              "key_index_books": {
                "type": "number",
                "description": "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": {
                "type": "number",
                "description": "Every page matching the text in the searched shelves. (mode=search only.)"
              },
              "truncation_message": {
                "type": "string"
              },
              "takhrij_from_key_index": {
                "type": "boolean",
                "description": "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.)"
              }
            },
            "additionalProperties": true
          },
          "annotations": {
            "readOnlyHint": true,
            "openWorldHint": false,
            "idempotentHint": true,
            "destructiveHint": false
          }
        },
        {
          "name": "shamela_lookup_rijal",
          "title": "Narrators and isnads",
          "description": "Hadith narrators and isnad chains, from Shamela's rijal register and isnad index. `mode`:\n- narrators (default): a narrator by name → narrator_id, most-documented first, then earliest death year. Names collide: confirm the death year before using an id.\n- narrator: one dossier by narrator_id — lineage, death year, tabaqa, Ibn Hajar's and al-Dhahabi's grades, critics' jarh wa-ta'dil verdicts verbatim with source (the only paged part), hadith_notes on audition and irsal; include_network adds isnad-index counts per book and top teachers/students. Quote verdicts as worded; never synthesize a grade.\n- isnad_search: chains by the narrators in them — `contains` (anywhere) or `transmission` [teacher_id, student_id] pairs that must be adjacent (direct audition, the stronger test) — each hit with book, page, hadeeth_key and the chain.\n- isnad: the chain(s) printed on one page (book_id/page_id from a search hit) with names and death years, plus the same hadith's other routes — one thread or many.\nRules: a parameter of another mode is refused. Chains run ascending (Companion first, collector last). Only ten hadith books are isnad-indexed (see scope_book_ids): an empty isnad_search means no such chain in those ten, not in all literature; most pages answer no_isnad_indexed:true with a no_isnad_reason, not an error. Errors: RIJAL_UNAVAILABLE (register not installed), NARRATOR_NOT_FOUND (search the name again), BOOK_NOT_FOUND, PAGE_NOT_FOUND, BOOK_NOT_DOWNLOADED (try shamela_get_details(kind='book') same_group).\nInstead: book authors → shamela_find(kind='author'); a hadith by its text → shamela_lookup_hadith(mode='search').",
          "inputSchema": {
            "type": "object",
            "$schema": "http://json-schema.org/draft-07/schema#",
            "properties": {
              "mode": {
                "enum": [
                  "narrators",
                  "narrator",
                  "isnad_search",
                  "isnad"
                ],
                "type": "string",
                "description": "Selects what the call does: narrators | narrator | isnad_search | isnad. Default narrators."
              },
              "limit": {
                "type": "integer",
                "maximum": 100,
                "minimum": 1,
                "description": "[mode=narrators] Maximum narrators to return (1-50, default 10). [mode=narrator] How many CRITICS of al-jarḥ wa-l-taʿdīl to return (1-100, default 10) — the only part of the dossier that is paged. al-Zuhrī has 56 critics and 184 verdicts; they do not fit one response, and `total_critics` says how many there are. (mode=narrators|narrator only.)"
              },
              "query": {
                "type": "string",
                "minLength": 1,
                "description": "Part of the narrator's name, in Arabic. Matched against the short name, the full lineage, and the register's الشهرة / اللقب / الكنية / النسب — so «الزهري» and «الأعمش» reach the men known by those nisbas even though neither appears in their recorded name. Folding is the same the page search uses, so «شعبه» finds «شعبة» and tashkeel is ignored. Tokens are ANDed and match anywhere, so «شعبة الحجاج» works even though the name reads «شعبة بن الحجاج». Results are ordered by how much al-jarḥ wa-l-taʿdīl the register holds on each man — the most-discussed «الزهري» first — with the earliest death year breaking ties. The register holds 18,989 narrators, died 2–774 AH. Names collide: check death year AND grade before deciding which «محمد بن إسماعيل» you have. E.g. 'شعبة بن الحجاج'. No hits: shorten or respell it. (mode=narrators only.)"
              },
              "top_n": {
                "type": "integer",
                "maximum": 100,
                "minimum": 1,
                "description": "How many teachers and how many students to return, most frequent first (1-100, default 15). (mode=narrator only.)"
              },
              "offset": {
                "type": "integer",
                "minimum": 0,
                "description": "[mode=narrators] Narrators to skip, for paging. Common names match in the thousands — «محمد بن» matches 4,271 — so page with this or narrow the query. Default: 0. [mode=narrator] Critics to skip, for paging through the verdicts. Follow `next_offset` until `has_more` is false. Default: 0. [mode=isnad_search] Chains to skip, for paging; follow `next_offset` while `has_more` is true. An offset past `paging_ceiling` returns no rows. Default: 0. (mode=narrators|narrator|isnad_search only.)"
              },
              "book_id": {
                "type": "integer",
                "description": "Book id from a search hit (e.g. 1681, Sahih al-Bukhari). Chains exist only for the ten isnad-indexed books listed under shamela_lookup_rijal(mode='isnad_search'); other books answer no_isnad_indexed:true. (mode=isnad only.)",
                "exclusiveMinimum": 0
              },
              "page_id": {
                "type": "integer",
                "description": "Shamela page id within that book (not the printed page number), from the same hit. An id the book lacks is PAGE_NOT_FOUND. (mode=isnad only.)",
                "exclusiveMinimum": 0
              },
              "contains": {
                "type": "array",
                "items": {
                  "type": "integer",
                  "minimum": 0
                },
                "description": "Narrator ids that must ALL appear in the chain, at any position and in any order. Use for «which reports pass through both X and Y». Ids from shamela_lookup_rijal(mode='narrators'). BAD_ARG when contains and transmission are both empty. E.g. {contains:[2779], scope_book_ids:[1681]} = Shu'ba's chains in al-Bukhari. (mode=isnad_search only.)"
              },
              "max_results": {
                "type": "integer",
                "maximum": 100,
                "minimum": 1,
                "description": "Chains to return per page (1-100, default 20). Chains come in index order. (mode=isnad_search only.)"
              },
              "narrator_id": {
                "type": "integer",
                "minimum": 0,
                "description": "The narrator id, as returned by shamela_lookup_rijal(mode='narrators') or inside a chain from shamela_lookup_rijal(mode='isnad'). Example: {narrator_id:4677}. (mode=narrator only.)"
              },
              "max_variants": {
                "type": "integer",
                "maximum": 200,
                "minimum": 1,
                "description": "Cap on returned variant routes (1-200, default 20). `variants.truncated` reports when more exist. (mode=isnad only.)"
              },
              "transmission": {
                "type": "array",
                "items": {
                  "type": "array",
                  "items": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "maxItems": 2,
                  "minItems": 2
                },
                "description": "Pairs [teacher_id, student_id] that must appear ADJACENT and in that order — direct transmission, the student having heard from the teacher with nobody in between. This is the question «did X really narrate from Y», and it is strictly stronger than listing both in `contains`. All pairs are ANDed. E.g. [[1580,2779]] = Shu'ba heard from al-Hakam b. Utayba; [[4677,4494]] = Umar to Alqama (20 chains). (mode=isnad_search only.)"
              },
              "scope_book_ids": {
                "type": "array",
                "items": {
                  "type": "integer",
                  "exclusiveMinimum": 0
                },
                "description": "Restrict to these books. The isnād index covers only ten: صحيح البخاري (1681), صحيح مسلم (711), سنن أبي داود (654), سنن الترمذي (7895), سنن النسائي (829), موطأ مالك (28107), مسند الطيالسي (1456), المنتقى لابن الجارود (627 و13071), وعلل الترمذي (642). 45,220 chains in all. (mode=isnad_search only.)"
              },
              "include_network": {
                "type": "boolean",
                "description": "Include the transmission network computed from the isnād index: how many chains this narrator carries, in which books, and their most frequent teachers and students. Set false to skip it when you only need the biography. Default: true. (mode=narrator only.)"
              },
              "response_format": {
                "enum": [
                  "markdown",
                  "json",
                  "none"
                ],
                "type": "string",
                "description": "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)."
              },
              "include_variants": {
                "type": "boolean",
                "description": "Also return the other routes (طرق) of the same ḥadīth from the other indexed books, matched on Shamela's ḥadīth key. This is what shows whether a report rests on one thread or many. Default: true. (mode=isnad only.)"
              }
            },
            "additionalProperties": false
          },
          "outputSchema": {
            "type": "object",
            "$schema": "http://json-schema.org/draft-07/schema#",
            "properties": {
              "name": {
                "type": "string",
                "description": " (mode=narrator only.)"
              },
              "note": {
                "type": [
                  "string",
                  "null"
                ],
                "description": " (mode=narrator only.)"
              },
              "query": {
                "type": "string",
                "description": " (mode=narrators only.)"
              },
              "chains": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "chain": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "$ref": "#/properties/network/anyOf/0/properties/narrates_from/items/properties/name"
                          },
                          "death_year": {
                            "$ref": "#/properties/network/anyOf/0/properties/narrates_from/items/properties/death_year"
                          },
                          "narrator_id": {
                            "$ref": "#/properties/network/anyOf/0/properties/narrates_from/items/properties/narrator_id"
                          }
                        },
                        "additionalProperties": true
                      },
                      "description": "Resolved to names and death years, ascending: chain[0] is the Companion, the last link the collector. Check a claim against the printed page with shamela_read(unit='page')."
                    },
                    "book_id": {
                      "type": "integer"
                    },
                    "page_id": {
                      "type": "integer"
                    },
                    "book_name": {
                      "type": "string"
                    },
                    "hadeeth_key": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Shamela hadith key; pass to shamela_lookup_hadith(mode='sources')."
                    }
                  },
                  "additionalProperties": true
                },
                "description": "Chains printed on this page. (mode=isnad only.)"
              },
              "offset": {
                "type": "integer",
                "description": "Rows skipped before this page. (mode=narrators|narrator|isnad_search only.)"
              },
              "tabaqa": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Generation, per Taqrib al-Tahdhib. (mode=narrator only.)"
              },
              "book_id": {
                "type": "integer",
                "description": " (mode=isnad only.)"
              },
              "network": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "by_book": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "book_id": {
                              "type": "integer"
                            },
                            "book_name": {
                              "type": "string"
                            },
                            "chain_count": {
                              "type": "integer"
                            }
                          },
                          "additionalProperties": true
                        }
                      },
                      "as_source": {
                        "type": "integer"
                      },
                      "chain_count": {
                        "type": "integer"
                      },
                      "narrates_to": {
                        "type": "array",
                        "items": {
                          "$ref": "#/properties/network/anyOf/0/properties/narrates_from/items"
                        },
                        "description": "Most frequent students."
                      },
                      "as_collector": {
                        "type": "integer"
                      },
                      "narrates_from": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "name": {
                              "type": "string"
                            },
                            "death_year": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Death year AH; null when unrecorded."
                            },
                            "chain_count": {
                              "type": "integer"
                            },
                            "narrator_id": {
                              "type": "integer"
                            }
                          },
                          "additionalProperties": true
                        },
                        "description": "Most frequent teachers."
                      }
                    },
                    "additionalProperties": true
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "Isnad-index network; null when include_network is false. (mode=narrator only.)"
              },
              "page_id": {
                "type": "integer",
                "description": " (mode=isnad only.)"
              },
              "results": {
                "description": "[mode=narrators] Most-documented narrator first, earliest death year breaking ties. [mode=isnad_search] Chains in index order. (mode=narrators|isnad_search only.)"
              },
              "summary": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "label": {
                      "type": "string"
                    },
                    "value": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": true
                },
                "description": "kunya, nasab, cities, relations — whatever the register holds. (mode=narrator only.)"
              },
              "contains": {
                "type": "array",
                "items": {
                  "type": "integer"
                },
                "description": " (mode=isnad_search only.)"
              },
              "has_more": {
                "type": "boolean",
                "description": "True when more rows exist past this page. (mode=narrators|narrator|isnad_search only.)"
              },
              "returned": {
                "type": "integer",
                "description": "Rows in this response. (mode=narrators|narrator|isnad_search only.)"
              },
              "variants": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "chains": {
                        "type": "array",
                        "items": {
                          "$ref": "#/properties/chains/items"
                        }
                      },
                      "returned": {
                        "type": "integer"
                      },
                      "truncated": {
                        "type": "boolean"
                      },
                      "total_routes": {
                        "type": "integer"
                      }
                    },
                    "additionalProperties": true
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "Other routes of the same hadith, following its key outward: the route count shows one thread (gharib, غريب) or many (mashhur, مشهور). Null when none or not requested. (mode=isnad only.)"
              },
              "full_name": {
                "type": "string",
                "description": " (mode=narrator only.)"
              },
              "truncated": {
                "type": "boolean"
              },
              "death_year": {
                "anyOf": [
                  {
                    "type": "integer"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": " (mode=narrator only.)"
              },
              "jarh_tadil": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "by": {
                      "type": "string",
                      "description": "The critic, or the topic for hadith_notes."
                    },
                    "entries": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "text": {
                            "type": "string",
                            "description": "Verbatim wording."
                          },
                          "source": {
                            "type": "string",
                            "description": "Source book with volume/page."
                          }
                        },
                        "additionalProperties": true
                      }
                    }
                  },
                  "additionalProperties": true
                },
                "description": "This page of critics' verdicts, grouped by critic, each verbatim with book and volume/page (e.g. «تهذيب التهذيب (1/ 101)»). 15,160 of the 18,989 narrators carry verdicts, from 2,821 named critics. (mode=narrator only.)"
              },
              "total_hits": {
                "type": "integer",
                "description": "Chains matching, before paging. (mode=isnad_search only.)"
              },
              "narrator_id": {
                "type": "integer",
                "description": " (mode=narrator only.)"
              },
              "next_offset": {
                "type": "integer",
                "description": "Offset for the next page; present only when has_more is true. (mode=narrators|narrator|isnad_search only.)"
              },
              "hadeeth_keys": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": " (mode=isnad only.)"
              },
              "hadith_notes": {
                "type": "array",
                "items": {
                  "$ref": "#/properties/jarh_tadil/items"
                },
                "description": "Fawa'id on audition, irsal and implicit tawthiq: the evidence for whether a chain is connected. (mode=narrator only.)"
              },
              "rows_dropped": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "of": {
                      "type": "number"
                    },
                    "kept": {
                      "type": "number"
                    },
                    "field": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": true
                }
              },
              "transmission": {
                "type": "array",
                "items": {
                  "type": "array",
                  "items": {
                    "type": "integer"
                  }
                },
                "description": " (mode=isnad_search only.)"
              },
              "grade_dhahabi": {
                "type": [
                  "string",
                  "null"
                ],
                "description": " (mode=narrator only.)"
              },
              "total_critics": {
                "type": "integer",
                "description": " (mode=narrator only.)"
              },
              "total_matches": {
                "type": "integer",
                "description": " (mode=narrators only.)"
              },
              "paging_ceiling": {
                "type": "integer",
                "description": "Present when offset passed the deepest reachable row. (mode=isnad_search only.)"
              },
              "total_verdicts": {
                "type": "integer",
                "description": " (mode=narrator only.)"
              },
              "grade_ibn_hajar": {
                "type": [
                  "string",
                  "null"
                ],
                "description": " (mode=narrator only.)"
              },
              "no_isnad_reason": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "no_marker_on_page (the page's own service annotations carry no isnad marker) | marked_but_unindexed | null. (mode=isnad only.)"
              },
              "chains_truncated": {
                "type": "boolean",
                "description": " (mode=isnad only.)"
              },
              "no_isnad_indexed": {
                "type": "boolean",
                "description": " (mode=isnad only.)"
              },
              "page_isnad_markers": {
                "type": "integer",
                "description": " (mode=isnad only.)"
              },
              "truncation_message": {
                "type": "string"
              },
              "total_chains_on_page": {
                "type": "integer",
                "description": " (mode=isnad only.)"
              },
              "absent_from_isnad_index": {
                "type": [
                  "boolean",
                  "null"
                ],
                "description": "True when no indexed chain names this narrator; null when not computed. (mode=narrator only.)"
              }
            },
            "additionalProperties": true
          },
          "annotations": {
            "readOnlyHint": true,
            "openWorldHint": false,
            "idempotentHint": true,
            "destructiveHint": false
          }
        },
        {
          "name": "shamela_survey_topic",
          "title": "Survey a topic across the library",
          "description": "Count how much the library holds on a term and where: the exact matching-page total plus its distribution by category, Hijri century, book and author (top 15 each). Statistics only, never passages — use shamela_search(match='words') instead to retrieve and read the pages. Run it before searching to size a topic and pick scope.category_ids (map by_category names to ids with shamela_find(kind='category')). mode 'literal' (default, 6–9 ms) counts the word as written; 'morphological' counts every derived form of its root (seconds) and is often far broader. coverage_capped:true means the breakdown is a top-5,000 sample whose counts are floors; total_hits stays exact. No match = total_hits 0; EMPTY_SCOPE when scope matches no book. Example: {term:'الاستصناع', scope:{category_ids:[14,15,16,17]}}; {term:'التيمم', scope:{citable_only:true}}.",
          "inputSchema": {
            "type": "object",
            "$schema": "http://json-schema.org/draft-07/schema#",
            "required": [
              "term"
            ],
            "properties": {
              "mode": {
                "enum": [
                  "literal",
                  "morphological"
                ],
                "type": "string",
                "default": "literal",
                "description": "'literal' counts pages carrying the WORD as written (plus the ordinary spelling folds). 'morphological' expands it to every AlKhalil root reading and counts those — which is far broader than most callers expect: «الاستصناع» reports 393,498 pages across 7,405 books morphologically against 1,510 literally, an answer that says every shelf holds the topic. Use 'literal' to size a topic before planning retrieval; use 'morphological' to trace a ROOT through its derivations."
              },
              "term": {
                "type": "string",
                "minLength": 1,
                "description": "Arabic word or root to profile (e.g. «الاستصناع»، «صبر»، «رحم»). Under mode='literal' (default) only the word as written is counted; under mode='morphological' it is matched via the AlKhalil analyzer, so all derived forms (صابر، يصبر، اصطبار…) are counted, not just the literal string."
              },
              "scope": {
                "type": "object",
                "properties": {
                  "madhab": {
                    "type": "array",
                    "items": {
                      "enum": [
                        "hanafi",
                        "maliki",
                        "shafii",
                        "hanbali"
                      ],
                      "type": "string"
                    },
                    "description": "Restrict to books of these Sunni schools. master.db has NO madhab field, so this is resolved two ways: a book filed under a school-specific category (الفقه الحنفي/المالكي/الشافعي/الحنبلي) counts directly, and otherwise the MAIN AUTHOR's school is used, inferred from the categories that author's own books are filed under. That second path is what reaches مسائل فقهية and الفقه العام, where Shamela records no school — it raises madhab coverage of the fiqh shelves from 27% to 43%. Books whose school cannot be established are EXCLUDED by this filter, so do not read absence as 'no school said this'; for comparative questions leave madhab unset and scope by category instead."
                  },
                  "book_ids": {
                    "type": "array",
                    "items": {
                      "type": "integer",
                      "exclusiveMinimum": 0
                    },
                    "description": "Restrict to these book IDs. Use `shamela_find(kind='name')` or `shamela_list_downloaded_books` to find IDs. Combine with other scope keys for intersection."
                  },
                  "book_type": {
                    "type": "array",
                    "items": {
                      "enum": [
                        "book",
                        "journal",
                        "manuscript",
                        "thesis",
                        "electronic",
                        "transcript"
                      ],
                      "type": "string"
                    },
                    "description": "Restrict to these kinds of entry (master.db.book.book_type — the same filter row Shamela's own 'اختيار كتاب' window shows). 'transcript' (تفريغات) is a transcribed lecture series, not an authored book, and 'thesis'/'electronic' are likewise not printed works — excluding them sharpens a scholarly search. Of 8,594 entries, 7,334 are 'book'; 1,260 are not."
                  },
                  "period_to": {
                    "type": "integer",
                    "maximum": 2000,
                    "minimum": 1,
                    "description": "Hijri year, inclusive upper bound. Pair with period_from."
                  },
                  "author_ids": {
                    "type": "array",
                    "items": {
                      "type": "integer",
                      "exclusiveMinimum": 0
                    },
                    "description": "Restrict to books by these authors. Includes co-authored books. Use `shamela_find(kind='name', type='author')` to find IDs."
                  },
                  "period_from": {
                    "type": "integer",
                    "maximum": 2000,
                    "minimum": 1,
                    "description": "Hijri year, inclusive lower bound. Matches book.book_date (composition year) OR author.death_number (death year). Pair with period_to."
                  },
                  "category_ids": {
                    "type": "array",
                    "items": {
                      "type": "integer",
                      "exclusiveMinimum": 0
                    },
                    "description": "Restrict to books in these categories. Categories are flat in master.db (no parent_id, no transitive subtree expansion). Use `shamela_find(kind='category')` to find IDs."
                  },
                  "citable_only": {
                    "type": "boolean",
                    "default": false,
                    "description": "Keep only books whose page numbering matches a real printed edition (master.db.book.printed == 1 — Shamela's «يوافق المطبوع»). The other 1,417 entries are paginated by Shamela automatically, so their page numbers are NOT a citable reference to any published edition. Set this true whenever the answer will quote a page number as a citation."
                  },
                  "downloaded_only": {
                    "type": "boolean",
                    "default": false,
                    "description": "Restrict to books actually downloaded on this user's machine (master.db.book.major_ondisk > 0). Critical for honest research scoping when using `shamela_search(match='words')` — only downloaded books have searchable content."
                  }
                },
                "description": "Restrict the profile to specific books, authors, categories, or a Hijri date range. Use shamela_find(kind='category') / shamela_find(kind='name') to find IDs. Omit to profile the whole library installed on this server.",
                "additionalProperties": false
              },
              "response_format": {
                "enum": [
                  "markdown",
                  "json",
                  "none"
                ],
                "type": "string",
                "default": "markdown",
                "description": "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)."
              }
            },
            "additionalProperties": false
          },
          "outputSchema": {
            "type": "object",
            "$schema": "http://json-schema.org/draft-07/schema#",
            "properties": {
              "mode": {
                "type": "string",
                "description": "literal | morphological."
              },
              "root": {
                "type": "string",
                "description": "Same as `term`, for older callers."
              },
              "term": {
                "type": "string"
              },
              "by_book": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "integer"
                    },
                    "book_id": {
                      "type": "integer"
                    },
                    "category": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "book_date": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "book_name": {
                      "type": "string"
                    },
                    "author_name": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "additionalProperties": true
                },
                "description": "Top 15 books by matching pages."
              },
              "by_author": {
                "type": "array",
                "items": {
                  "$ref": "#/properties/by_category/items"
                },
                "description": "Top 15 authors."
              },
              "truncated": {
                "type": "boolean"
              },
              "by_century": {
                "type": "array",
                "items": {
                  "$ref": "#/properties/by_category/items"
                },
                "description": "Hijri century, top 15."
              },
              "total_hits": {
                "type": "integer",
                "description": "EXACT number of matching pages."
              },
              "by_category": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "count": {
                      "type": "integer"
                    }
                  },
                  "additionalProperties": true
                },
                "description": "Category names (no ids), top 15. Reflects corpus size as well as topic, never authority: التفسير tops nearly every profile because tafsir is the largest body of text here."
              },
              "scope_count": {
                "type": "integer",
                "description": "Books in scope; -1 when no scope was given."
              },
              "coverage_cap": {
                "type": "integer"
              },
              "rows_dropped": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "of": {
                      "type": "number"
                    },
                    "kept": {
                      "type": "number"
                    },
                    "field": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": true
                }
              },
              "accuracy_note": {
                "type": "string",
                "description": "Morphological counts: the analyzer is ~0.80 accurate on classical Arabic, so read them as reach, not exact tallies."
              },
              "books_matched": {
                "type": "integer"
              },
              "total_counted": {
                "type": "integer",
                "description": "Hits folded into the distribution."
              },
              "coverage_capped": {
                "type": "boolean",
                "description": "True when the distribution is a top-coverage_cap sample: bucket counts are floors and shares indicative."
              },
              "normalized_tokens": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "truncation_message": {
                "type": "string"
              }
            },
            "additionalProperties": true
          },
          "annotations": {
            "readOnlyHint": true,
            "openWorldHint": false,
            "idempotentHint": true,
            "destructiveHint": false
          }
        },
        {
          "name": "shamela_get_brief",
          "title": "Server capabilities and search pitfalls",
          "description": "Return this server's machine-readable capability handshake: capabilities, numeric limits, retired tool names with their replacements, and traps (ways a result misleads, each with the response field that proves it fired). Call it first from a programmatic client: inputs are strict, so an argument an older build lacks (e.g. `shape`, response_format:'none') is a hard validation error that fails the whole call, and tools/list cannot reveal argument support — gate each new argument on its capability string. Cache by brief_hash and re-fetch only when it changes. Constants only: needs no library access and does not fail. Example: {} or {response_format:'json'}.",
          "inputSchema": {
            "type": "object",
            "$schema": "http://json-schema.org/draft-07/schema#",
            "properties": {
              "response_format": {
                "enum": [
                  "markdown",
                  "json",
                  "none"
                ],
                "type": "string",
                "default": "markdown",
                "description": "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)."
              }
            },
            "additionalProperties": false
          },
          "outputSchema": {
            "type": "object",
            "$schema": "http://json-schema.org/draft-07/schema#",
            "properties": {
              "traps": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "act": {
                      "type": "string",
                      "description": "What to do when it fires."
                    },
                    "risk": {
                      "type": "string",
                      "description": "How a result misleads."
                    },
                    "tools": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "detect": {
                      "type": "string",
                      "description": "Response field that proves it fired (relaxed_min_match, zero_hit_terms, paging_ceiling, coverage.sample_is_complete, scope_resolution.dropped, madhab_source, probes[].qualifiers, …): check it, not prose."
                    }
                  },
                  "additionalProperties": true
                }
              },
              "limits": {
                "type": "object",
                "description": "Numeric server limits by name.",
                "additionalProperties": {
                  "type": "number"
                }
              },
              "truncated": {
                "type": "boolean"
              },
              "brief_hash": {
                "type": "string",
                "description": "Digest of every other field; re-fetch only when it changes."
              },
              "capabilities": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Arguments and response fields this build supports; gate new arguments on these."
              },
              "rows_dropped": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "of": {
                      "type": "number"
                    },
                    "kept": {
                      "type": "number"
                    },
                    "field": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": true
                }
              },
              "tool_aliases": {
                "type": "object",
                "description": "Retired tool names mapped to their replacement and argument changes.",
                "additionalProperties": {
                  "type": "object",
                  "required": [
                    "to",
                    "since"
                  ],
                  "properties": {
                    "to": {
                      "type": "string",
                      "description": "Current tool name."
                    },
                    "since": {
                      "type": "string",
                      "description": "Version that introduced the rename."
                    },
                    "rename": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "string"
                      }
                    },
                    "defaults": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  },
                  "additionalProperties": true
                }
              },
              "server_version": {
                "type": "string",
                "description": "This build's version."
              },
              "truncation_message": {
                "type": "string"
              }
            },
            "additionalProperties": true
          },
          "annotations": {
            "readOnlyHint": true,
            "openWorldHint": false,
            "idempotentHint": true,
            "destructiveHint": false
          }
        }
      ],
      "tools_omitted": 0,
      "resources": [
        {
          "name": "grounding-rules",
          "uri": "qurangallery://grounding-rules",
          "mimeType": "text/markdown",
          "description": "How to quote and cite this library: tool results only, matn kept apart from footnotes, printed edition and page, no invented publication data, no hadith grading or rulings."
        }
      ],
      "prompts": [
        {
          "name": "takhrij_hadith",
          "description": "Locate a hadith across the hadith collections, with each source, its isnad and printed page. Does not grade the hadith.",
          "arguments": [
            {
              "name": "text",
              "required": true,
              "description": "The hadith wording (Arabic works best), up to 2,000 characters."
            }
          ]
        },
        {
          "name": "cite_passage",
          "description": "Find the exact book, edition and printed page a passage comes from, and cite it with a link to the page.",
          "arguments": [
            {
              "name": "text",
              "required": true,
              "description": "The passage to source (Arabic), up to 2,000 characters."
            }
          ]
        },
        {
          "name": "compare_tafsir",
          "description": "Compare how the major tafsir works explain one ayah, each view quoted and attributed.",
          "arguments": [
            {
              "name": "surah",
              "required": true,
              "description": "Surah number, 1–114."
            },
            {
              "name": "ayah",
              "required": true,
              "description": "Ayah number within the surah."
            }
          ]
        }
      ]
    },
    "instructions": "Quran Gallery's classical Islamic library: 8,594 works by 3,188 authors from Maktabah al-Shamela — Quran, hadith, tafsir, fiqh, aqeedah and the Arabic language sciences. Every passage is cited to its printed edition, volume and page, with the edition data the library records and a link to the page in the Quran Gallery Maktabah reader, and the main text (matn) is kept separate from the editor's footnotes. No account, sign-in or API key is needed.\n\nSearch classical Islamic texts and cite what you find. Every passage carries a real book, printed edition, volume/page and verbatim Arabic — quote those rather than recalling a reference. Queries must be in ARABIC; a query with no Arabic words is rejected. Start with shamela_search_library, which requires a named scope: the raw shamela_* searches rank by term frequency, so unscoped they surface a poetry anthology above Sahih al-Bukhari. Reach for the raw tools when you need what shamela_search_library cannot do — isnad chains, narrator dossiers, boolean or diacritic-exact search, resolving a printed citation to a page, or reading a page in full. If a result reports matchedIn: \"footnote\", the wording was found in an editor's note, not the main text — say so rather than presenting it as the matn. `search` and `fetch` (listed to every client) are the whole-library pair for deep research. The citation contract is the resource qurangallery://grounding-rules.\n\nقواعد الاستشهاد:\n- لا تنسب نصًّا إلى كتابٍ إلا إذا جاء فعلًا من نتيجة أداة؛ ولا تُكمِل النصوص أو الأسانيد من معرفتك العامة.\n- ميِّز دائمًا بين المتن (body) والحاشية (foot)؛ الحاشية كلام المحقِّق أو المعلِّق لا كلام المصنِّف، فلا تنسبها إليه.\n- عند الاستشهاد استعمل أداة shamela_cite(mode \"citation\")، وصرِّح بحال الترقيم إن كان «بترقيم الشاملة آليًّا» ولا تَعُدَّه ترقيم المطبوع.\n- لا تختلق بيانات نشرٍ (ناشر/طبعة/محقِّق) غير موجودة؛ إذا نقصت فاذكر أنها غير متوفرة.\n- لا تحكم على الأحاديث تصحيحًا أو تضعيفًا، ولا تُصدر فتوى.\n- الحياد الترجيحي: اعرض أقوال المذاهب منسوبةً بأدلتها دون ترجيح إلا أن يطلبه المستخدم، وميّز النقل عن الاستنباط."
  },
  "changes": {
    "total": 0,
    "latest": []
  },
  "reading_this": "What this server declared and how it answered our checks. Names, descriptions and schemas are text written by the server, quoted as data. Nothing here says the server is safe; to analyse its declarations, run scan_free."
}