Skip to content

Model Context Protocol

Give your AI the library.MCP server for classical Islamic texts

Let an AI assistant read classical Islamic texts and cite a real printed edition, volume and page with the verbatim Arabic, instead of a reference recalled from memory.

Endpoint

https://qurangallery.com/mcp/shamela

Streamable HTTPPOSTno authentication needed

Works with
  • ChatGPT
  • Claude
  • Copilot
  • and more Cursor VS Code Gemini CLI

8,594 works3,188 authorsno key neededfree

01 · Connect

One URL, in the client you already use.

Paste the endpoint into your assistant and ask a question. No account and no key are needed to start.

Claude claude.ai and Claude Desktop

  1. Open Settings → Connectors → Add custom connector.
  2. Name it Quran Gallery, paste the endpoint and leave the advanced settings empty.
  3. Switch it on for a chat from the tools menu.
endpoint
https://qurangallery.com/mcp/shamela

ChatGPT Developer mode

  1. Open Settings → Apps & Connectors → Advanced settings and turn on Developer mode.
  2. Create a connector with the endpoint and set Authentication to No authentication.
  3. Pick it from the composer's developer-mode menu in a new chat.
endpoint
https://qurangallery.com/mcp/shamela

Claude Code Terminal

  1. Run this once in your terminal.
bash
claude mcp add --transport http quran-gallery https://qurangallery.com/mcp/shamela

Cursor ~/.cursor/mcp.json

  1. Add the server to ~/.cursor/mcp.json.
  2. Restart the client if it asks you to.
~/.cursor/mcp.json
{
  "mcpServers": {
    "quran-gallery": {
      "url": "https://qurangallery.com/mcp/shamela"
    }
  }
}

VS Code .vscode/mcp.json

  1. Add the server to .vscode/mcp.json.
  2. Restart the client if it asks you to.
.vscode/mcp.json
{
  "servers": {
    "quran-gallery": {
      "type": "http",
      "url": "https://qurangallery.com/mcp/shamela"
    }
  }
}

Gemini CLI ~/.gemini/settings.json

  1. Add the server to ~/.gemini/settings.json.
  2. Restart the client if it asks you to.
~/.gemini/settings.json
{
  "mcpServers": {
    "quran-gallery": {
      "httpUrl": "https://qurangallery.com/mcp/shamela"
    }
  }
}

02 · What comes back

A passage, a book and a page you can check.

One real result from search_library for the most quoted hadith in Islam, unedited. This is what your assistant receives before it writes a word.

Request

search_library(query: "إنما الأعمال بالنيات", scope: "hadith-primary")

Passage 3 of 38 books searched

…عُمَرَ بْنَ الْخَطَّابِ ﵁ عَلَى الْمِنْبَرِ، قَالَ: سَمِعْتُ رَسُولَ اللهِ ﷺ، يَقُولُ: «إِنَّمَا الْأَعْمَالُ بِالنِّيَّاتِ، وَإِنَّمَا لِكُلِّ امْرِئٍ مَا نَوَى، فَمَنْ كَانَتْ هِجْرَتُهُ إِلَى دُنْيَا يُصِيبُهَا، أَوْ إِلَى امْرَأَ…
Book
صحيح البخاري - ط السلطانية
Author
البخاري d. 256 AH
Volume / page
1/ 6
Edition
ط السلطانية
Publisher
السلطانية
Source
shamela.ws
Matched in
Main text, not a footnote · Exact phrase
Raw result
{
  "book": "صحيح البخاري - ط السلطانية",
  "author": "البخاري",
  "authorDied": 256,
  "bookId": 1681,
  "printedPage": "1/ 6",
  "pageId": 10,
  "edition": "ط السلطانية",
  "publisher": "السلطانية",
  "sourceUrl": "https://shamela.ws/book/1681/10",
  "arabic": "…عُمَرَ بْنَ الْخَطَّابِ ﵁ عَلَى الْمِنْبَرِ، قَالَ: سَمِعْتُ رَسُولَ اللهِ ﷺ، يَقُولُ: «إِنَّمَا الْأَعْمَالُ بِالنِّيَّاتِ، وَإِنَّمَا لِكُلِّ امْرِئٍ مَا نَوَى، فَمَنْ كَانَتْ هِجْرَتُهُ إِلَى دُنْيَا يُصِيبُهَا، أَوْ إِلَى امْرَأَ…",
  "matchedIn": "body",
  "matchQuality": "exact_phrase"
}
  1. 01 Verbatim The Arabic is copied from the page, never paraphrased or completed from memory.
  2. 02 The printed page Volume and page in the named printing, so a reader can open the book and find it.
  3. 03 Body or footnote Every passage says whether the words are the author's or an editor's note.

03 · Tools

One tool to start with, 36 behind it.

Most questions need only search_library. The rest of the library server is there when a question needs more.

Start here

search_library(query, scope, limit?)

Runs an exact-phrase pass first and falls back to a token search, telling you which one answered. Returns book, author, death year, printed volume/page, and the verbatim Arabic, plus whether the words were found in the main text or in an editor's footnote.

Alongside it, 36 shamela_* tools from the library server itself: isnād chains and narrator dossiers, boolean and diacritic-exact search, resolving a printed citation to a page, tafsir by verse, and reading a page in full. Queries must be in Arabic.

In all, 39 tools: search_library, search, fetch and the 36 shamela_* tools.

The full tool reference

Search

9
  • shamela_search_pages
  • shamela_search_titles
  • shamela_search_phrase
  • shamela_search_exact
  • shamela_search_boolean
  • shamela_search_hadith
  • shamela_search_batch
  • shamela_recon
  • shamela_root_stats

Narrators and isnād

5
  • shamela_search_narrators
  • shamela_get_narrator
  • shamela_search_isnad
  • shamela_get_isnad
  • shamela_get_books_for_hadith
22 more tools Citation · Quran and tafsir · Reading · Catalogue

Citation

4
  • shamela_get_citation
  • shamela_resolve_work
  • shamela_resolve_printed_page
  • shamela_resolve

Quran and tafsir

5
  • shamela_search_quran
  • shamela_get_aya
  • shamela_get_tafseer_of_aya
  • shamela_list_tafsirs_for_aya
  • shamela_get_tafseer_texts

Reading

6
  • shamela_get_page
  • shamela_get_pages_range
  • shamela_get_book_section
  • shamela_get_toc
  • shamela_get_book_parts
  • shamela_get_page_services

Catalogue

7
  • shamela_search_books
  • shamela_search_authors
  • shamela_get_book
  • shamela_get_author
  • shamela_list_categories
  • shamela_books_by_period
  • shamela_brief

04 · Scopes

Search the right shelf first.

search_library requires one. This is not a convenience: unscoped, ranking in this corpus is by term frequency, which puts a 710 AH poetry anthology above every fiqh manual and never surfaces Sahih al-Bukhari for the most famous hadith in Islam. The raw shamela_* searches will let you run unscoped; the ranking is why you usually should not.

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

05 · Limits

Free to start. A key when you need more.

A refused call spends nothing, and the error names the limit you reached. A shorter page range is not a lost page: the response says where to continue.

Without a key

10 tool calls a minute

  • 200 a day, counted per IP address
  • Up to 5 pages per pages_range call and 10 per book_section call
  • Connecting and listing tools costs nothing

With a free key

60 requests a minute

  • No daily cap, counted per key
  • Up to 20 pages per pages_range call and 100 per book_section call
  • Sent as a header Authorization: Bearer qg_sk_…
Get a key

Create one under Developers in your Quran Gallery account.

What it does not do

  • Searches return page-scoped excerpts with citations; the reading tools return whole pages. No single call exports a book, and the rate limit is what separates reading from scraping.

  • It cannot stop your model from misattributing a passage. What it guarantees is that the passage, the book and the page are real, not that the sentence built around them is.

  • It does not need your identity to answer. Keyless calls are limited per IP; a key is only for higher limits.

Questions

Asked about the server

Is there an MCP server for hadith and tafsir?

Yes. The Quran Gallery MCP server at https://qurangallery.com/mcp/shamela searches 8,594 classical Islamic works by 3,188 authors, including the primary hadith collections, the major tafsirs, fiqh of the four schools, creed, sira and the Arabic language. Every passage comes back with its book, author, printed volume and page.

How do I add it to ChatGPT or Claude?

In Claude, open Settings → Connectors → Add custom connector and paste https://qurangallery.com/mcp/shamela. In ChatGPT, turn on Developer mode under Settings → Apps & Connectors → Advanced settings, then create a connector with the same URL and No authentication. Claude Code, Cursor, VS Code and Gemini CLI take the URL in their MCP configuration.

Is it free? Do I need a key?

It is free and needs no key. Without one you get 10 tool calls a minute and 200 a day per IP address. A free key from your Quran Gallery account raises that to 60 a minute with no daily cap.

Which books does it cover?

The Maktabah al-Shamela catalogue: 8,594 classical works by 3,188 authors across 41 categories. Searches run inside a scope, such as the eight primary hadith collections, canonical tafsir or one school's fiqh, so the right shelf answers first. Queries are in Arabic.

How is it different from asking an AI directly?

An assistant answering from memory can produce a plausible reference that does not exist. With this server it quotes a passage it retrieved, verbatim, with the printed edition, volume and page, so you can open the book and check. It cannot stop a model from misattributing a passage; it guarantees that the passage, the book and the page are real.

Does it work with ChatGPT deep research?

Yes. The server has search and fetch tools in the shape ChatGPT expects, so deep research can find a passage and then read it in full. In ChatGPT, turn on Developer mode and add https://qurangallery.com/mcp/shamela as a connector with No authentication.

Begin

Connect it, then ask for a page.

The documentation covers every tool, scope and error. Tell us what you build with it, or what goes wrong.