get_full_surah
Retrieve complete Quran chapters with all verses. Optionally include English translations to read full surah content for study or reference.
Instructions
Get all verses of a complete Surah (chapter). Can include translations.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| surah | Yes | Surah number (1-114) | |
| include_translation | No | Whether to include English translation (default: false) | |
| translation | No | Translation to use if include_translation is true (default: en.asad) | en.asad |
Implementation Reference
- src/tools/quran.ts:154-196 (handler)Core handler function that implements the get_full_surah tool. Validates surah number, fetches all verses (ayahs) using helper functions getQuranVerse or getQuranArabic, handles optional translation, uses caching internally, and returns array of QuranVerse objects.export async function getFullSurah( surah: number, includeTranslation: boolean = false, translationSlug: string = 'en.asad' ): Promise<QuranVerse[]> { if (!isValidSurah(surah)) { throw new QuranMCPError( `Invalid surah number: ${surah}. Must be between 1 and 114.`, 'INVALID_SURAH' ); } const surahInfo = getSurahInfo(surah); if (!surahInfo) { throw new QuranMCPError( `Could not find info for surah ${surah}`, 'SURAH_INFO_NOT_FOUND' ); } const verses: QuranVerse[] = []; for (let ayah = 1; ayah <= surahInfo.ayahs; ayah++) { try { if (includeTranslation) { const verse = await getQuranVerse(surah, ayah, translationSlug); verses.push({ surah, ayah, text: verse.arabic.text, translation: verse.translation.text, }); } else { const verse = await getQuranArabic(surah, ayah); verses.push(verse); } } catch (error) { console.error(`Failed to fetch verse ${surah}:${ayah}:`, error); } } return verses; }
- MCP tool schema definition including name, description, and inputSchema with properties for surah (required), include_translation, and translation.{ name: 'get_full_surah', description: 'Get all verses of a complete Surah (chapter). Can include translations.', inputSchema: { type: 'object', properties: { surah: { type: 'number', description: 'Surah number (1-114)', minimum: 1, maximum: 114, }, include_translation: { type: 'boolean', description: 'Whether to include English translation (default: false)', default: false, }, translation: { type: 'string', description: 'Translation to use if include_translation is true (default: en.asad)', default: 'en.asad', }, }, required: ['surah'], }, },
- src/shared/tool-executor.ts:69-72 (registration)Registration and dispatch logic in the central tool executor switch statement. Extracts arguments from input and calls the getFullSurah handler function.case 'get_full_surah': { const { surah, include_translation = false, translation = 'en.asad' } = args; result = await getFullSurah(surah, include_translation, translation); break;