Skip to main content
Glama
djalal

quran-mcp-server

by djalal

verses-by_rub_el_hizb_number

Retrieve Quranic verses by specifying the Rub el Hizb number (1-240). Customize output with translations, audio, tafsirs, and word details for in-depth study via the Quran MCP server.

Instructions

Get verses by Rub el Hizb number

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
audioNoId of recitation
fieldsNoComma separated list of ayah fields
languageNoLanguage to fetch word translation
rub_el_hizb_numberYesRub el Hizb number (1-240)
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 that validates the input arguments using Zod, invokes the verses service method, logs the execution, and formats the response as a JSON text block or error message.
    /**
     * Handler for the verses-by_rub_el_hizb_number tool
     */
    export async function handleVersesByRubElHizbNumber(args: any) {
      try {
        // Validate arguments
        const validatedArgs = versesByRubElHizbNumberSchema.parse(args);
        
        // Call the service
        const result = await versesService.versesByRubElHizbNumber(validatedArgs);
        
        // Log the response in verbose mode
        verboseLog('response', {
          tool: 'verses-by_rub_el_hizb_number',
          result
        });
        
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(result, null, 2)
            }
          ]
        };
      } catch (error) {
        verboseLog('error', {
          tool: 'verses-by_rub_el_hizb_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: required 'rub_el_hizb_number' string (1-240) and optional common verse parameters like language, words, translations, etc.
    /**
     * Schema for verses-by_rub_el_hizb_number
     */
    export const versesByRubElHizbNumberSchema = z.object({
      rub_el_hizb_number: z.string().describe("Rub el Hizb number (1-240)"),
      ...commonVerseParams,
    });
  • src/server.ts:162-165 (registration)
    MCP tool registration in the listTools response: defines the tool name, description, and converts the Zod input schema to JSON schema.
      name: ApiTools.verses_by_rub_el_hizb_number,
      description: "Get verses by Rub el Hizb number",
      inputSchema: zodToJsonSchema(versesSchemas.versesByRubElHizbNumber),
    },
  • src/server.ts:273-274 (registration)
    Dispatch registration in the callTool request handler switch statement: maps the tool name to the execution of the handler function.
    case ApiTools.verses_by_rub_el_hizb_number:
      return await handleVersesByRubElHizbNumber(request.params.arguments);
  • Supporting service method that constructs the Quran.com API URL (/verses/by_rub/{rub_el_hizb_number}), appends query parameters, makes the HTTP request via makeApiRequest, and returns structured success response or throws errors.
     * Get verses by rub el hizb number
     * Get all verses of a specific Rub el Hizb number(1-240).
     * 
     * @param {Object} params - The parameters for this operation
     * @returns {Promise<VersesByRubElHizbNumberResponse>} The operation result
     * @throws {ApiError} If the operation fails
     */
    async versesByRubElHizbNumber(params: z.infer<typeof versesByRubElHizbNumberSchema>): Promise<VersesByRubElHizbNumberResponse> {
      try {
        // Validate parameters
        const validatedParams = versesByRubElHizbNumberSchema.parse(params);
        
        const url = `${API_BASE_URL}/verses/by_rub/${validatedParams.rub_el_hizb_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
        });
        
        return {
          success: true,
          message: "verses-by_rub_el_hizb_number executed successfully",
          data
        };
      } catch (error) {
        verboseLog('error', {
          method: 'versesByRubElHizbNumber',
          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 full burden. It states 'Get verses', implying a read-only operation, but doesn't disclose behavioral traits such as whether it's safe, if it requires authentication, rate limits, pagination, or what the output format looks like. The description is minimal and lacks essential context for a tool with 9 parameters.

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 with zero waste. It's front-loaded with the core purpose and appropriately sized for the tool's complexity, making it easy to scan and understand quickly.

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 tool's complexity (9 parameters, no annotations, no output schema), the description is incomplete. It doesn't explain what a Rub el Hizb is, how the output is structured, or provide any context on the optional parameters' effects. For a data retrieval tool with many options, more guidance is needed to be fully helpful.

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?

Schema description coverage is 100%, so the schema already documents all 9 parameters thoroughly. The description adds no additional meaning beyond the schema, such as explaining parameter interactions or usage examples. Baseline 3 is appropriate since the schema does the heavy lifting, but the description doesn't compensate or enhance understanding.

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 verb 'Get' and resource 'verses', specifying they are retrieved 'by Rub el Hizb number'. It distinguishes from siblings like 'verses-by_chapter_number' or 'verses-by_juz_number' by indicating the specific numbering system used. However, it doesn't explicitly mention what a 'Rub el Hizb' is or that it's a Quranic division, which could help further differentiate.

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

Usage Guidelines3/5

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

The description implies usage when you have a Rub el Hizb number (1-240) to fetch verses, as seen in the schema. It doesn't provide explicit guidance on when to use this versus alternatives like 'verses-by_juz_number' or 'verses-by_page_number', nor does it mention prerequisites or exclusions. Usage is contextually inferred but not clearly stated.

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