Skip to main content
Glama
djalal

quran-mcp-server

by djalal

verses-by_chapter_number

Retrieve Quranic verses by specifying chapter numbers, with options for translations, audio, tafsirs, and word details. Simplify access to Quran text and interpretations in your preferred language.

Instructions

Get verses by Chapter / Surah number

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
audioNoId of recitation
chapter_numberYesChapter number (1-114)
fieldsNoComma separated list of ayah fields
languageNoLanguage to fetch word translation
pageNoFor paginating within the result
per_pageNoRecords per api call
tafsirsNoComma separated ids of tafsirs
translation_fieldsNoComma separated list of translation fields
translationsNoComma separated ids of translations
word_fieldsNoComma separated list of word fields
wordsNoInclude words of each ayah

Implementation Reference

  • The MCP tool handler function `handleVersesByChapterNumber` that validates input arguments using Zod schema, calls the versesService, logs the response or error, and returns MCP-compatible content blocks.
    export async function handleVersesByChapterNumber(args: any) {
      try {
        // Validate arguments
        const validatedArgs = versesByChapterNumberSchema.parse(args);
        
        // Call the service
        const result = await versesService.versesByChapterNumber(validatedArgs);
        
        // Log the response in verbose mode
        verboseLog('response', {
          tool: 'verses-by_chapter_number',
          result
        });
        
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(result, null, 2)
            }
          ]
        };
      } catch (error) {
        verboseLog('error', {
          tool: 'verses-by_chapter_number',
          error: error instanceof Error ? error.message : String(error)
        });
        
        if (error instanceof z.ZodError) {
          return {
            content: [{ 
              type: "text", 
              text: `Validation error: ${error.errors.map(e => `${e.path.join('.')}: ${e.message}`).join(', ')}`
            }],
            isError: true,
          };
        }
        
        return {
          content: [{ 
            type: "text", 
            text: `Error: ${error instanceof Error ? error.message : "Unknown error"}`
          }],
          isError: true,
        };
      }
    }
  • Zod schema defining the input parameters for the tool, including required 'chapter_number' and optional common verse parameters (language, words, translations, etc.) and pagination.
     * Schema for verses-by_chapter_number
     */
    export const versesByChapterNumberSchema = z.object({
      chapter_number: z.string().describe("Chapter number (1-114)"),
      ...commonVerseParams,
      ...paginationParams,
    });
  • src/server.ts:141-144 (registration)
    Registration of the tool in the server's listTools response, providing name, description, input schema, and usage examples.
    name: ApiTools.verses_by_chapter_number,
    description: "Get verses by Chapter / Surah number",
    inputSchema: zodToJsonSchema(versesSchemas.versesByChapterNumber),
    examples: toolExamples['verses-by_chapter_number'],
  • src/server.ts:265-266 (registration)
    Dispatch registration in the server's callTool handler switch statement, routing calls to the specific handler function.
    case ApiTools.verses_by_chapter_number:
      return await handleVersesByChapterNumber(request.params.arguments);
  • Core service logic that constructs the Quran.com API endpoint URL, passes parameters to makeApiRequest, and wraps the response in a structured format with success message.
    async versesByChapterNumber(params: z.infer<typeof versesByChapterNumberSchema>): Promise<VersesByChapterNumberResponse> {
      try {
        // Validate parameters
        const validatedParams = versesByChapterNumberSchema.parse(params);
        
        const url = `${API_BASE_URL}/verses/by_chapter/${validatedParams.chapter_number}`;
        
        // Make request to Quran.com API
        const data = await makeApiRequest(url, {
          language: validatedParams.language,
          words: validatedParams.words,
          translations: validatedParams.translations,
          audio: validatedParams.audio,
          tafsirs: validatedParams.tafsirs,
          word_fields: validatedParams.word_fields,
          translation_fields: validatedParams.translation_fields,
          fields: validatedParams.fields,
          page: validatedParams.page,
          per_page: validatedParams.per_page
        });
        
        return {
          success: true,
          message: "verses-by_chapter_number executed successfully",
          data
        };
      } catch (error) {
        verboseLog('error', {
          method: 'versesByChapterNumber',
          error: error instanceof Error ? error.message : String(error)
        });
        
        if (error instanceof z.ZodError) {
          throw new ApiError(`Validation error: ${error.errors.map(e => `${e.path.join('.')}: ${e.message}`).join(', ')}`, 400);
        }
        
        // Re-throw other errors
        throw error;
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states 'Get verses', implying a read-only operation, but doesn't clarify whether this is a safe read (e.g., no side effects), what the return format includes (e.g., verses with metadata), or any constraints like rate limits, authentication needs, or pagination behavior. The description lacks essential context for a tool with 11 parameters and no output schema.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence: 'Get verses by Chapter / Surah number'. It's front-loaded with the core action and resource, with zero wasted words. Every part of the sentence contributes directly to understanding the tool's purpose, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (11 parameters, no annotations, no output schema), the description is incomplete. It doesn't address behavioral traits, return values, or usage guidelines, leaving significant gaps. For a tool with rich parameterization and sibling alternatives, more context is needed to help the agent invoke it correctly and interpret results.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds no parameter-specific information beyond what the input schema provides. Since schema description coverage is 100%, the baseline score is 3. The description doesn't explain how parameters like 'audio', 'tafsirs', or 'fields' interact with the core functionality, nor does it provide examples or clarify semantics (e.g., what 'ayah fields' or 'word fields' entail).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Get verses by Chapter / Surah number'. It uses a specific verb ('Get') and identifies the resource ('verses'), and the scope ('by Chapter / Surah number') is clear. However, it doesn't explicitly differentiate from sibling tools like 'verses-by_juz_number' or 'verses-by_page_number', which have similar structures but different filtering criteria.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'verses-by_juz_number' or 'verses-by_verse_key', nor does it specify prerequisites, exclusions, or contextual cues for selection. The agent must infer usage based on the name alone, which is insufficient for optimal tool selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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/djalal/quran-mcp-server'

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