Skip to main content
Glama

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
NameRequiredDescriptionDefault
include_translationNoWhether to include English translation (default: true)
translationNoTranslation to use (default: en.asad)en.asad

Implementation Reference

  • 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', }, }, }, },
  • 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;

Latest Blog Posts

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