Skip to main content
Glama
djalal

quran-mcp-server

by djalal

verses-by_juz_number

Retrieve Quranic verses by Juz number, including translations, tafsirs, audio, and word details, using the Quran MCP server for precise and structured access to scripture content.

Instructions

Get verses by Juz number

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
audioNoId of recitation
fieldsNoComma separated list of ayah fields
juz_numberYesJuz number (1-30)
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

  • Main handler function that parses arguments with Zod schema, invokes the verses service, logs the operation, and returns formatted MCP content or error response.
    /**
     * Handler for the verses-by_juz_number tool
     */
    export async function handleVersesByJuzNumber(args: any) {
      try {
        // Validate arguments
        const validatedArgs = versesByJuzNumberSchema.parse(args);
        
        // Call the service
        const result = await versesService.versesByJuzNumber(validatedArgs);
        
        // Log the response in verbose mode
        verboseLog('response', {
          tool: 'verses-by_juz_number',
          result
        });
        
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(result, null, 2)
            }
          ]
        };
      } catch (error) {
        verboseLog('error', {
          tool: 'verses-by_juz_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 input schema defining parameters for the tool: juz_number (required), optional common verse params (language, words, etc.) and pagination.
    /**
     * Schema for verses-by_juz_number
     */
    export const versesByJuzNumberSchema = z.object({
      juz_number: z.string().describe("Juz number (1-30)"),
      ...commonVerseParams,
      ...paginationParams,
    });
  • src/server.ts:152-155 (registration)
    MCP tool registration in listTools handler: defines name, description, and converts Zod schema to JSON schema for input validation.
      name: ApiTools.verses_by_juz_number,
      description: "Get verses by Juz number",
      inputSchema: zodToJsonSchema(versesSchemas.versesByJuzNumber),
    },
  • src/server.ts:269-270 (registration)
    Dispatch registration in CallToolRequestSchema handler: maps tool name to the specific handler function call.
    case ApiTools.verses_by_juz_number:
      return await handleVersesByJuzNumber(request.params.arguments);
  • Core service logic: validates params, builds Quran.com API URL (/verses/by_juz/{juz_number}), makes request with optional params, wraps response in success object.
    async versesByJuzNumber(params: z.infer<typeof versesByJuzNumberSchema>): Promise<VersesByJuzNumberResponse> {
      try {
        // Validate parameters
        const validatedParams = versesByJuzNumberSchema.parse(params);
        
        const url = `${API_BASE_URL}/verses/by_juz/${validatedParams.juz_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_juz_number executed successfully",
          data
        };
      } catch (error) {
        verboseLog('error', {
          method: 'versesByJuzNumber',
          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?

With no annotations provided, the description carries full burden but only states the basic action without disclosing behavioral traits such as pagination behavior (implied by 'page' and 'per_page' parameters), rate limits, authentication needs, or what the output looks like. It mentions 'Get' which suggests a read operation, but lacks details on response format or error handling.

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—'Get verses by Juz number'—front-loading the core purpose without unnecessary elaboration. It appropriately sized for the tool's complexity.

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 (11 parameters, no output schema, no annotations), the description is insufficient. It lacks details on output format, error cases, or how parameters interact (e.g., combining 'audio' with 'translations'), leaving significant gaps for an AI agent to invoke it correctly without trial and error.

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 parameters like 'juz_number', 'audio', and 'fields' are documented in the schema. The description adds no additional semantic context beyond the tool's purpose, adhering to the baseline score when schema coverage is high.

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 Juz number' clearly states the action (get) and resource (verses), with the specific qualifier 'by Juz number' indicating the retrieval method. It distinguishes from siblings like 'verses-by_chapter_number' by specifying the Juz-based filtering, though it doesn't explicitly contrast them.

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 like 'verses-by_chapter_number' or 'verses-by_page_number'. The description implies usage for Juz-based retrieval but lacks explicit context, prerequisites, or exclusions, leaving the agent to infer based on parameter names alone.

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