PROJECT_SUMMARY.mdā¢10.8 kB
# 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*