Skip to main content
Glama
djalal

quran-mcp-server

by djalal

verses-by_hizb_number

Retrieve Quran verses by Hizb number, including translations, audio, tafsirs, and word details for in-depth study and analysis.

Instructions

Get verses by Hizb number

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
audioNoId of recitation
fieldsNoComma separated list of ayah fields
hizb_numberYesHizb number (1-60)
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 that validates input using the schema, calls the verses service, logs the operation, and returns the result as JSON or error response.
    /**
     * Handler for the verses-by_hizb_number tool
     */
    export async function handleVersesByHizbNumber(args: any) {
      try {
        // Validate arguments
        const validatedArgs = versesByHizbNumberSchema.parse(args);
        
        // Call the service
        const result = await versesService.versesByHizbNumber(validatedArgs);
        
        // Log the response in verbose mode
        verboseLog('response', {
          tool: 'verses-by_hizb_number',
          result
        });
        
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(result, null, 2)
            }
          ]
        };
      } catch (error) {
        verboseLog('error', {
          tool: 'verses-by_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 verses-by_hizb_number tool, including hizb_number and common verse/pagination options.
    /**
     * Schema for verses-by_hizb_number
     */
    export const versesByHizbNumberSchema = z.object({
      hizb_number: z.string().describe("Hizb number (1-60)"),
      ...commonVerseParams,
      ...paginationParams,
    });
  • src/server.ts:157-160 (registration)
    Tool metadata registration in the listTools handler: name, description, and input schema for discovery by MCP clients.
      name: ApiTools.verses_by_hizb_number,
      description: "Get verses by Hizb number",
      inputSchema: zodToJsonSchema(versesSchemas.versesByHizbNumber),
    },
  • src/server.ts:271-272 (registration)
    Tool execution registration in the callTool handler switch: maps tool name to handler invocation.
    case ApiTools.verses_by_hizb_number:
      return await handleVersesByHizbNumber(request.params.arguments);
  • Supporting service method that performs the actual API call to Quran.com for verses by hizb number, handles validation and error throwing.
     * Get verses by hizb number
     * Get all verses from a specific Hizb(1-60).
     * 
     * @param {Object} params - The parameters for this operation
     * @returns {Promise<VersesByHizbNumberResponse>} The operation result
     * @throws {ApiError} If the operation fails
     */
    async versesByHizbNumber(params: z.infer<typeof versesByHizbNumberSchema>): Promise<VersesByHizbNumberResponse> {
      try {
        // Validate parameters
        const validatedParams = versesByHizbNumberSchema.parse(params);
        
        const url = `${API_BASE_URL}/verses/by_hizb/${validatedParams.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,
          page: validatedParams.page,
          per_page: validatedParams.per_page
        });
        
        return {
          success: true,
          message: "verses-by_hizb_number executed successfully",
          data
        };
      } catch (error) {
        verboseLog('error', {
          method: 'versesByHizbNumber',
          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' but does not disclose behavioral traits such as whether this is a read-only operation, potential rate limits, authentication requirements, or what the output format looks like (since no output schema exists). The description is minimal and lacks essential context for safe and effective use.

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 is front-loaded and directly states the tool's purpose without unnecessary words. Every part of the description earns its place, making it highly concise and well-structured for quick understanding.

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, 1 required) and lack of annotations and output schema, the description is incomplete. It does not explain return values, error conditions, or behavioral constraints, leaving significant gaps for the agent. For a tool with many optional parameters and no output schema, more context is needed to ensure proper usage.

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 fully documents all 11 parameters. The description does not add any meaning beyond the schema, as it only mentions 'Hizb number' without detailing other parameters like 'audio', 'fields', or pagination options. With high schema coverage, the baseline score of 3 is appropriate, as the description relies on the schema for parameter semantics.

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 'Get verses by Hizb number' clearly states the action (get) and resource (verses), with the specific filter (by Hizb number). It distinguishes from siblings like 'verses-by_chapter_number' or 'verses-by_juz_number' by specifying the filtering criterion, though it doesn't explicitly contrast them. The purpose is unambiguous but lacks explicit sibling differentiation.

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?

No guidance is provided on when to use this tool versus alternatives. The description does not mention sibling tools (e.g., 'verses-by_juz_number' or 'verses-by_chapter_number') or specify contexts where Hizb-based retrieval is preferred. Usage is implied by the name but not explained, leaving the agent to infer based on parameter needs.

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