Sermons MCP Server
by mailmirza
README.md
# Sermons MCP Server
Lets an AI assistant browse, search and read **Friday khutbas** from the UAE General Authority of Islamic
Affairs and Endowments (Awqaf), 2015 - to date, through the open JSON API of
[Sermons by Islamic Network](https://sermons.islamic.network). It is a
[Model Context Protocol](https://modelcontextprotocol.io) (MCP) server built with
[FastMCP](https://gofastmcp.com).
Once connected you can ask things like:
- "What was the latest khutba about? Give me the main points."
- "Search the khutbas for anything about Dhul Hijjah, then tell me what the khutba says about the ten days."
- "List the khutbas from July 2021."
- "What advice did the khutba on Imam Malik give about seeking knowledge?"
The server has no AI of its own. It fetches the sermon text, and your AI assistant summarizes it and
answers your questions from that text.
> Answers are generated by an AI from the sermon text. Check the original khutba, and ask a qualified
> scholar for religious rulings.
## Tools
| Tool | What it does |
|---|---|
| `get_latest_khutba(language)` | Full text of the most recent Friday khutba |
| `list_khutbas(year, month?, khutba_type, source)` | Titles, dates and available languages for a year or month. `khutba_type` is `friday` or `other` (Eid, rain prayer and so on) |
| `get_khutba_text(year, month, title, language, khutba_type, source)` | Full text of one khutba. `title` can be a partial match |
| `search_khutbas(keyword, start_year?, end_year?, source)` | Searches khutba **titles** across all years by default |
`language` is `en`, `ar` or `ur`. PDFs are not available in every language for every khutba. When one is
missing, the tool says which languages are.
## How it works
1. The API is a set of static JSON files listing each khutba and its files (mp3, doc, pdf) on a CDN.
2. The server finds the khutba in that index, downloads the PDF, and extracts the text with `pypdf`.
3. The text goes back to your AI assistant.
Nothing is stored: no sermon text, PDFs or audio are kept in this repository or on the server.
## Quick start
```bash
git clone https://github.com/mailmirza/sermons-mcp-server.git
cd sermons-mcp-server
python -m venv venv
source venv/bin/activate # Windows PowerShell: .\venv\Scripts\Activate.ps1
pip install -r requirements.txt
python server.py # stdio mode: it waits for an MCP client
```
Test it with the [MCP Inspector](https://github.com/modelcontextprotocol/inspector). Let the Inspector
launch the server, and do not type into the server's own terminal:
```bash
npx @modelcontextprotocol/inspector python server.py
```
## Use it from an MCP client
**Local (stdio).** For Claude Desktop, add this to `claude_desktop_config.json` (use full paths; on Windows
use `venv\\Scripts\\python.exe` with double backslashes):
```json
{
"mcpServers": {
"sermons": {
"command": "/full/path/to/venv/bin/python",
"args": ["/full/path/to/sermons-mcp-server/server.py"]
}
}
}
```
**Over the network (HTTP).** Run with `MCP_TRANSPORT=http`. Claude's custom connector dialog expects an
`https://` URL, so put the server behind a reverse proxy with a certificate. See
[docs/deployment.md](docs/deployment.md). Please deploy your own copy rather than pointing many people at one.
## Configuration
| Variable | Meaning |
|---|---|
| `MCP_TRANSPORT` | `stdio` (default) or `http` |
| `MCP_HOST` | Bind address for HTTP, default `127.0.0.1` |
| `MCP_PORT` | HTTP port, default `8002` |
## Limits
- `search_khutbas` matches **titles only**. Searching inside sermon text would mean downloading every PDF.
- Each search makes one request per year, so a full-archive search is about a dozen requests.
- The only source today is UAE Awqaf. The API has no data for 2017.
- PDF text extraction is imperfect, especially for Arabic with diacritics and mixed Arabic and English text.
The English text read cleanly in testing.
## Lessons learned
1. **The same API returns different JSON shapes.** A month is `{"sermons": [...]}`, but a year is a *list of
per-month batches*: `[{"sermons": [...]}, {"sermons": [...]}, ...]`. Parsing it as one flat list silently
returned nothing. Look at real responses before writing parsing code.
2. **stdio and `print()` do not mix.** stdout carries the protocol; print to `sys.stderr` and never type
into the terminal of a running stdio server. Inspector shows stderr in its Console panel.
3. **Docstrings are instructions.** FastMCP turns them into the schema the model reads.
4. **Isolate bugs with a tiny script.** A 20-line standalone script that fetched one year and printed the
titles found the parsing bug faster than debugging through the MCP layer.
5. **Windows notes.** The command is `python`, not `python3`. If `Activate.ps1` is blocked, run
`Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned`.
## Data attribution
Sermon data comes from the open API of [Sermons by Islamic Network](https://sermons.islamic.network),
and the PDFs from its CDN. The khutbas are published by the General Authority of Islamic Affairs and
Endowments (UAE), and copyright remains with the source.
- This project is not affiliated with or endorsed by Islamic Network or the UAE Awqaf.
- Keep attribution if you build on it, check the API's terms, and be considerate with request volume.
## License
The code is [MIT](LICENSE). The sermons themselves are not covered by it.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues