Skip to main content
Glama
djalal

quran-mcp-server

by djalal

GET-chapter

Retrieve Quranic chapters in specified languages using chapter IDs (1-114) through the quran-mcp-server's REST API v4.

Instructions

Get Chapter

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idNoChapter ID (1-114)
languageYesParameter language (e.g., 'en', 'ar', 'fr-CA')

Implementation Reference

  • The main handler function for the GET-chapter tool. It validates input arguments using getChapterSchema, calls the chaptersService.getChapter method, logs the response, and formats the result as MCP content or handles errors appropriately.
    export async function handleGetChapter(args: any) {
      try {
        // Validate arguments
        const validatedArgs = getChapterSchema.parse(args);
        
        // Call the service
        const result = await chaptersService.getChapter(validatedArgs);
        
        // Log the response in verbose mode
        verboseLog('response', {
          tool: 'GET-chapter',
          result
        });
        
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(result, null, 2)
            }
          ]
        };
      } catch (error) {
        verboseLog('error', {
          tool: 'GET-chapter',
          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 for validating input parameters to the GET-chapter tool: language (string) and optional id (string or number, 1-114).
    export const getChapterSchema = z.object({
      language: z.string()
        .trim()
        .min(2, "Language code must be at least 2 characters")
        .max(10, "Language code must not exceed 10 characters")
        .regex(/^[a-zA-Z-]+$/, "Language code must contain only letters and hyphens")
        .describe("Parameter language (e.g., 'en', 'ar', 'fr-CA')"),
      id: z.union([
        z.string()
          .trim()
          .regex(/^\d+$/, "Chapter ID must be a positive integer")
          .transform(Number),
        z.number()
          .int("Chapter ID must be an integer")
          .positive("Chapter ID must be positive")
      ])
        .optional()
        .describe("Chapter ID (1-114)"),
    });
  • src/server.ts:130-134 (registration)
    Registration of the GET-chapter tool in the MCP server's list of available tools, including name, description, input schema (from chaptersSchemas.getChapter), and examples.
      name: ApiTools.GET_chapter,
      description: "Get Chapter",
      inputSchema: zodToJsonSchema(chaptersSchemas.getChapter),
      examples: toolExamples['GET-chapter'],
    },
  • src/server.ts:259-260 (registration)
    Dispatch/registration in the tool call handler switch statement, routing calls to 'GET-chapter' to the handleGetChapter function.
    case ApiTools.GET_chapter:
      return await handleGetChapter(request.params.arguments);
  • Supporting service method getChapter that performs the actual API request to Quran.com API endpoint /chapters/{id}, handles validation, defaults to chapter 1, and returns structured response.
    async getChapter(params: z.infer<typeof getChapterSchema>): Promise<GetChapterResponse> {
      try {
        // Validate parameters
        const validatedParams = getChapterSchema.parse(params);
        
        // Default to chapter 1 if no ID is provided
        const chapterId = params.id || '1';
        
        const url = `${API_BASE_URL}/chapters/${chapterId}`;
        
        // Make request to Quran.com API
        const data = await makeApiRequest(url, {
          language: validatedParams.language
        });
        
        return {
          success: true,
          message: "GET-chapter executed successfully",
          data
        };
      } catch (error) {
        verboseLog('error', {
          method: 'getChapter',
          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;
      }
    }
Behavior1/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure but fails completely. 'Get Chapter' doesn't indicate whether this is a read-only operation, what format the response takes, whether authentication is required, or any rate limits or constraints. The description provides zero behavioral information beyond the basic action implied by the verb 'Get'.

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

Conciseness2/5

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

While technically concise with just two words, this description suffers from severe under-specification rather than effective conciseness. The two words don't provide enough information to be useful, making this an example of being too brief rather than appropriately concise. Good conciseness balances brevity with sufficient information, which this lacks.

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

Completeness1/5

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

Given the complexity of having 2 parameters, no annotations, no output schema, and multiple sibling tools that appear related, the description is completely inadequate. It doesn't explain what 'chapter' refers to in this context (likely Quran chapters based on sibling tools), what information is returned, or how this differs from other chapter-related operations. The description fails to provide the minimal context needed for effective tool use.

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 schema description coverage is 100%, so both parameters (id and language) are fully documented in the schema. The description adds no additional parameter information beyond what's already in the structured schema. According to scoring rules, when schema coverage is high (>80%), the baseline score is 3 even with no parameter information in the description.

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

Purpose2/5

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

The description 'Get Chapter' is a tautology that essentially restates the tool name without providing meaningful context. It doesn't specify what resource is being retrieved (e.g., Quran chapter content, metadata, or structure) or distinguish this from sibling tools like 'list-chapters', 'verses-by_chapter_number', or 'tafsir' that might also retrieve chapter-related information.

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

Usage Guidelines1/5

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

The description provides absolutely no guidance about when to use this tool versus alternatives. With multiple sibling tools that appear related to chapters (list-chapters, verses-by_chapter_number, tafsir, etc.), there's no indication of what makes this tool distinct or when it should be preferred over other chapter-related tools.

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