get_random_verse
Retrieve a random Quran verse with optional English translation for daily spiritual inspiration and reflection.
Instructions
Get a random verse from the Quran. Great for daily inspiration!
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| include_translation | No | Whether to include English translation (default: true) | |
| translation | No | Translation to use (default: en.asad) | en.asad |
Implementation Reference
- src/tools/quran.ts:212-235 (handler)The core handler function that implements the logic for retrieving a random Quran verse, including random surah/ayah selection, Arabic text fetching, and optional translation.export async function getRandomVerse( includeTranslation: boolean = true, translationSlug: string = 'en.asad' ): Promise<{ arabic: QuranVerse; translation?: QuranVerse; surahInfo: any }> { // Pick random surah const randomSurah = Math.floor(Math.random() * 114) + 1; const surahInfo = getSurahInfo(randomSurah); if (!surahInfo) { throw new QuranMCPError('Failed to get random verse', 'RANDOM_VERSE_ERROR'); } // Pick random ayah from that surah const randomAyah = Math.floor(Math.random() * surahInfo.ayahs) + 1; const arabic = await getQuranArabic(randomSurah, randomAyah); if (includeTranslation) { const translation = await getQuranTranslation(randomSurah, randomAyah, translationSlug); return { arabic, translation, surahInfo }; } return { arabic, surahInfo }; }
- The MCP tool schema definition including name, description, and input validation schema for get_random_verse.{ name: 'get_random_verse', description: 'Get a random verse from the Quran. Great for daily inspiration!', inputSchema: { type: 'object', properties: { include_translation: { type: 'boolean', description: 'Whether to include English translation (default: true)', default: true, }, translation: { type: 'string', description: 'Translation to use (default: en.asad)', default: 'en.asad', }, }, }, },
- src/shared/tool-executor.ts:75-78 (registration)The switch case registration in the tool executor that maps the tool name to the handler function call.case 'get_random_verse': { const { include_translation = true, translation = 'en.asad' } = args; result = await getRandomVerse(include_translation, translation); break;