Skip to main content
Glama
djalal

quran-mcp-server

by djalal

juzs

Retrieve a complete list of all juzs from the Quran using the Quran.com REST API v4 integration. Simplify access to Quranic divisions for study or reference purposes.

Instructions

Get list of all juzs

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Main handler function for the 'juzs' tool. Validates input using juzsSchema, calls juzsService.getJuzs, formats response as MCP content or error.
    export async function handleJuzs(args: any) { try { // Validate arguments const validatedArgs = juzsSchema.parse(args); // Call the service const result = await juzsService.getJuzs(validatedArgs); // Log the response in verbose mode verboseLog('response', { tool: 'juzs', result }); return { content: [ { type: "text", text: JSON.stringify(result, null, 2) } ] }; } catch (error) { verboseLog('error', { tool: 'juzs', 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 for the juzs tool, defined as an empty object indicating no required parameters.
    export const juzsSchema = z.object({});
  • src/server.ts:178-183 (registration)
    Tool registration in the listTools response, defining name, description, input schema, and examples for 'juzs'.
    { name: ApiTools.juzs, description: "Get list of all juzs", inputSchema: zodToJsonSchema(juzsSchemas.juzs), examples: toolExamples['juzs'], },
  • src/server.ts:280-282 (registration)
    Dispatch/handling of 'juzs' tool call in the CallToolRequestSchema switch statement, invoking handleJuzs.
    // Juzs-related tools case ApiTools.juzs: return await handleJuzs(request.params.arguments);
  • Service method that fetches juzs data from Quran.com API endpoint '/juzs', handles validation and errors, called by the handler.
    async getJuzs(params: z.infer<typeof juzsSchema>): Promise<JuzsResponse> { try { // Validate parameters const validatedParams = juzsSchema.parse(params); const url = `${API_BASE_URL}/juzs`; // Make request to Quran.com API const data = await makeApiRequest(url, {}); return { success: true, message: "juzs executed successfully", data }; } catch (error) { verboseLog('error', { method: 'getJuzs', 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; }

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