info
Retrieve detailed chapter information from the Quran, including metadata and content, by specifying chapter ID and language. Designed for integration with the Quran.com corpus API.
Instructions
Get Chapter Info
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chapter_id | No | Chapter ID (1-114) | |
| language | Yes | Parameter language (e.g., 'en', 'ar', 'fr-CA') |
Implementation Reference
- src/handlers/chapters.ts:119-165 (handler)Executes the logic for the 'info' tool: validates arguments with chapterInfoSchema, fetches chapter info via service, logs, and returns JSON-formatted text content or error.export async function handleChapterInfo(args: any) { try { // Validate arguments const validatedArgs = chapterInfoSchema.parse(args); // Call the service const result = await chaptersService.getChapterInfo(validatedArgs); // Log the response in verbose mode verboseLog('response', { tool: 'info', result }); return { content: [ { type: "text", text: JSON.stringify(result, null, 2) } ] }; } catch (error) { verboseLog('error', { tool: 'info', 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, }; } }
- src/schemas/chapters.ts:45-63 (schema)Input schema (Zod) for the 'info' tool, defining 'language' (required string) and 'chapter_id' (optional number 1-114).export const chapterInfoSchema = 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')"), chapter_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:136-139 (registration)Tool registration in the 'listTools' handler, defining name 'info', description, and input schema for the MCP protocol.name: ApiTools.info, description: "Get Chapter Info", inputSchema: zodToJsonSchema(chaptersSchemas.chapterInfo), },
- src/server.ts:261-262 (registration)Routing in the 'callTool' switch statement that maps 'info' tool calls to the handleChapterInfo handler.case ApiTools.info: return await handleChapterInfo(request.params.arguments);