Skip to main content
Glama

Quran MCP Server

by Prince77-7
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*

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Prince77-7/quranMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server