# Quran MCP Server - Project Summary
## ๐ฏ Project Overview
The **Quran MCP Server** is a comprehensive, production-ready Model Context Protocol (MCP) server that provides AI assistants with seamless access to Islamic resources. This server enables Claude and other MCP-compatible AI assistants to retrieve Quranic verses, scholarly commentary (Tafsir), authentic Hadith collections, and audio recitations.
## โจ Key Features
### 1. **Comprehensive Quran Access**
- โ
Complete Arabic text of all 114 Surahs
- โ
5 English translations from renowned scholars
- โ
Verse-by-verse and full Surah retrieval
- โ
Random verse feature for daily inspiration
- โ
Surah metadata (names, revelation type, verse counts)
### 2. **Scholarly Tafsir (Commentary)**
- โ
5 Tafsir sources (English and Arabic)
- โ
Ibn Kathir, Maarif-ul-Quran, Al-Tabari, Al-Qurtubi
- โ
Verse-by-verse explanations
- โ
Range queries for studying multiple verses
### 3. **Authentic Hadith Collections**
- โ
6 major Hadith collections (30,000+ hadiths)
- โ
Sahih Bukhari, Sahih Muslim, and 4 Sunan collections
- โ
Complete metadata (narrator, grade, book, chapter)
- โ
Random hadith feature
### 4. **Audio Recitations**
- โ
5 world-renowned reciters
- โ
Multiple bitrates (64kbps to 192kbps)
- โ
Direct MP3 URLs for streaming
- โ
Playlist generation support
### 5. **Enterprise-Grade Architecture**
- โ
TypeScript with strict mode for type safety
- โ
Intelligent LRU caching with TTL
- โ
Comprehensive error handling
- โ
Retry logic with exponential backoff
- โ
Input validation for all parameters
- โ
Modular, maintainable code structure
## ๐ Technical Specifications
### Technology Stack
- **Language**: TypeScript 5.x (strict mode)
- **Runtime**: Node.js 18+
- **Protocol**: Model Context Protocol (MCP) via stdio
- **SDK**: @modelcontextprotocol/sdk v1.0.4
- **Caching**: node-cache (in-memory LRU)
- **Validation**: Zod v3.23.8
### Architecture
```
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ MCP Client (Claude) โ
โโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ JSON-RPC 2.0 over stdio
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ MCP Server (index.ts) โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Tool Request Handler โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโผโโโโโโโโโโโโโ
โผ โผ โผ
โโโโโโโโโโ โโโโโโโโโโโ โโโโโโโโโโโโ
โ Quran โ โ Tafsir โ โ Hadith โ
โ Tools โ โ Tools โ โ Tools โ
โโโโโโฌโโโโ โโโโโโฌโโโโโ โโโโโโฌโโโโโโ
โ โ โ
โโโโโโโโโโโโโผโโโโโโโโโโโโโ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโ
โ Cache Service โ
โ (LRU with TTL) โ
โโโโโโโโโโโโโฌโโโโโโโโโโโโ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโ
โ Fetcher Service โ
โ (HTTP with retry) โ
โโโโโโโโโโโโโฌโโโโโโโโโโโโ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโ
โ External APIs โ
โ (CDN & REST APIs) โ
โโโโโโโโโโโโโโโโโโโโโโโโโ
```
### File Structure
```
quranMCP/
โโโ src/
โ โโโ index.ts # Main MCP server (14 tools)
โ โโโ types/
โ โ โโโ index.ts # TypeScript definitions
โ โโโ constants/
โ โ โโโ index.ts # Surah info, collections, validation
โ โโโ services/
โ โ โโโ cache.ts # LRU caching layer
โ โ โโโ fetcher.ts # HTTP client with retry
โ โโโ tools/
โ โโโ quran.ts # Quran text & translations
โ โโโ tafsir.ts # Tafsir commentary
โ โโโ hadith.ts # Hadith collections
โ โโโ recitation.ts # Audio recitations
โโโ dist/ # Compiled JavaScript
โโโ docs/
โ โโโ README.md # Main documentation
โ โโโ QUICKSTART.md # 5-minute setup guide
โ โโโ EXAMPLES.md # Usage examples
โ โโโ API.md # Complete API reference
โ โโโ PROJECT_SUMMARY.md # This file
โโโ package.json # Dependencies & scripts
โโโ tsconfig.json # TypeScript config
โโโ .gitignore # Git ignore rules
โโโ .env.example # Environment template
```
## ๐ ๏ธ Available Tools (14 Total)
### Quran Tools (3)
1. `get_quran_verse` - Get verse with Arabic + translation
2. `get_full_surah` - Get complete Surah
3. `get_random_verse` - Daily inspiration
### Tafsir Tools (2)
4. `get_tafsir` - Get commentary for a verse
5. `list_tafsir_sources` - List available Tafsir
### Hadith Tools (3)
6. `get_hadith` - Get specific hadith
7. `get_random_hadith` - Random hadith
8. `list_hadith_collections` - List collections
### Recitation Tools (2)
9. `get_recitation_url` - Get audio URL
10. `list_reciters` - List available reciters
### Information Tools (4)
11. `get_surah_info` - Surah metadata
12. `list_surahs` - All 114 Surahs
13. `list_translations` - Available translations
14. `get_cache_stats` - Performance monitoring
## ๐ Performance Characteristics
### Caching Strategy
- **Quran Text**: 24-hour TTL (rarely changes)
- **Translations**: 24-hour TTL
- **Tafsir**: 2-hour TTL
- **Hadith**: 2-hour TTL
- **Recitation URLs**: 24-hour TTL
- **Max Keys**: 10,000 (LRU eviction)
### Response Times
- **Cached**: < 1ms
- **First Fetch**: 100-500ms
- **With Retry**: Up to 3 seconds
### Error Handling
- Automatic retry with exponential backoff
- Timeout protection (10 seconds default)
- Comprehensive error codes
- Graceful degradation
## ๐ Data Sources
All data is sourced from trusted Islamic resources:
1. **Tafsir API** - [spa5k/tafsir_api](https://github.com/spa5k/tafsir_api)
2. **Hadith API** - [fawazahmed0/hadith-api](https://github.com/fawazahmed0/hadith-api)
3. **Quran API** - [fawazahmed0/quran-api](https://github.com/fawazahmed0/quran-api)
4. **AlQuran Cloud** - [alquran.cloud/api](https://alquran.cloud/api)
5. **EveryAyah** - [everyayah.com](https://everyayah.com)
## ๐ Quick Start
```bash
# 1. Install dependencies
npm install
# 2. Build the project
npm run build
# 3. Configure Claude Desktop
# Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"quran": {
"command": "node",
"args": ["/absolute/path/to/quranMCP/dist/index.js"]
}
}
}
# 4. Restart Claude Desktop
# 5. Test with Claude
# Ask: "Show me the first verse of the Quran"
```
## ๐ Documentation
- **README.md** - Complete feature overview and setup
- **QUICKSTART.md** - 5-minute installation guide
- **EXAMPLES.md** - Comprehensive usage examples
- **API.md** - Full API reference with all parameters
- **PROJECT_SUMMARY.md** - This document
## ๐ Example Queries
```
1. "Show me Ayat al-Kursi with translation and tafsir"
2. "Give me a random verse from the Quran"
3. "What does Surah Al-Fatiha say?"
4. "Show me hadith number 1 from Sahih Bukhari"
5. "Get the audio recitation of Surah Yasin"
6. "List all available Quran translations"
7. "What is the tafsir of verse 2:255?"
8. "Give me a random hadith about prayer"
```
## ๐ Security & Reliability
- โ
No authentication required (public APIs)
- โ
Read-only operations (no data modification)
- โ
Input validation on all parameters
- โ
Rate limiting via caching
- โ
Error boundaries and graceful failures
- โ
No sensitive data storage
## ๐ Statistics
- **Total Lines of Code**: ~2,500
- **Total Tools**: 14
- **Supported Surahs**: 114
- **Supported Translations**: 5
- **Tafsir Sources**: 5
- **Hadith Collections**: 6 (30,000+ hadiths)
- **Reciters**: 5
- **Total Verses**: 6,236
## ๐ฏ Use Cases
1. **Personal Study** - Daily Quran reading with translation and tafsir
2. **Research** - Cross-reference verses, hadiths, and commentary
3. **Teaching** - Prepare lessons with authentic sources
4. **Memorization** - Access audio recitations for memorization
5. **Daily Inspiration** - Random verse and hadith features
6. **Comparative Study** - Compare different translations and tafsir
## ๐ฎ Future Enhancements
Potential areas for expansion:
- [ ] Additional Tafsir sources
- [ ] More Hadith collections
- [ ] Additional language translations
- [ ] Full-text search functionality
- [ ] Thematic indexing
- [ ] Juz and Hizb navigation
- [ ] Bookmark and favorites system
- [ ] Offline mode with local database
## ๐ค Contributing
The codebase is designed for easy extension:
- Modular tool structure
- Clear separation of concerns
- Comprehensive type definitions
- Well-documented code
- Consistent error handling
## ๐ License
MIT License - Free for personal and commercial use
## ๐ Acknowledgments
- Anthropic for the Model Context Protocol
- All Islamic scholars and organizations who made these resources available
- The open-source community
---
**Built with โค๏ธ for the Muslim community and AI enthusiasts**
*"Read in the name of your Lord who created" - Quran 96:1*