Skip to main content
Glama
djalal

quran-mcp-server

by djalal

translations

Retrieve a list of available Quran translations filtered by language using the Quran MCP Server's REST API for accurate and specific content access.

Instructions

Get list of available translations

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
languageNoLanguage

Implementation Reference

  • Main handler for the 'translations' MCP tool: validates input with translationsSchema, invokes translationsService.listTranslations(validatedArgs), logs verbose response, returns formatted JSON content or standardized error.
    export async function handleTranslations(args: any) {
      try {
        // Validate arguments
        const validatedArgs = translationsSchema.parse(args);
        
        // Call the service
        const result = await translationsService.listTranslations(validatedArgs);
        
        // Log the response in verbose mode
        verboseLog('response', {
          tool: 'translations',
          result
        });
        
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(result, null, 2)
            }
          ]
        };
      } catch (error) {
        verboseLog('error', {
          tool: 'translations',
          error: error instanceof Error ? error.message : String(error)
        });
        
        // Use the standardized error response utility
        const { createErrorResponse } = require('../utils/error-handler');
        return createErrorResponse(error, 'translations');
      }
    }
  • Zod input validation schema for the 'translations' tool, defining optional 'language' parameter.
    export const translationsSchema = z.object({
      language: z.string().optional().describe("Language"),
    });
  • src/server.ts:191-196 (registration)
    MCP tool registration for 'translations' in server.setRequestHandler(ListToolsRequestSchema): specifies name, description, inputSchema from aggregated schemas, and examples.
    {
      name: ApiTools.translations,
      description: "Get list of available translations",
      inputSchema: zodToJsonSchema(translationsSchemas.translations),
      examples: toolExamples['translations'],
    },
  • Core business logic for listing translations: caches results, fetches from Quran.com API (/resources/translations), falls back to mock data on API errors or validation issues.
    async listTranslations(params: z.infer<typeof translationsSchema>): Promise<TranslationsResponse> {
      try {
        // Validate parameters
        const validatedParams = translationsSchema.parse(params);
        
        // Check cache first
        const now = Date.now();
        if (this.translationsCache && (now - this.cacheTimestamp < CACHE_DURATION_MS)) {
          verboseLog('response', {
            method: 'listTranslations',
            source: 'cache',
            age: `${(now - this.cacheTimestamp) / 1000} seconds`
          });
          
          return {
            success: true,
            message: "translations executed successfully (from cache)",
            data: this.translationsCache
          };
        }
        
        try {
          // Make request to Quran.com API
          const url = `${API_BASE_URL}/resources/translations`;
          const response = await makeApiRequest(url, {
            language: validatedParams.language
          });
          
          verboseLog('response', {
            method: 'listTranslations',
            source: 'api',
            dataSize: JSON.stringify(response).length
          });
          
          // Update cache
          this.translationsCache = response;
          this.cacheTimestamp = now;
          
          return {
            success: true,
            message: "translations executed successfully",
            data: response
          };
        } catch (axiosError) {
          verboseLog('error', {
            method: 'listTranslations',
            error: axiosError instanceof Error ? axiosError.message : String(axiosError)
          });
          
          // If the API call fails, return mock data
          verboseLog('response', {
            method: 'listTranslations',
            source: 'mock',
            reason: 'API unavailable'
          });
          
          const mockData = this.getTranslationsMockData();
          
          return {
            success: true,
            message: "translations executed with mock data (API unavailable)",
            data: mockData
          };
        }
      } catch (error) {
        verboseLog('error', {
          method: 'listTranslations',
          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);
        }
        
        // Return mock data as a fallback for any error
        verboseLog('response', {
          method: 'listTranslations',
          source: 'mock',
          reason: 'error occurred'
        });
        
        const mockData = this.getTranslationsMockData();
        
        return {
          success: true,
          message: "translations executed with mock data (error occurred)",
          data: mockData
        };
      }
    }
  • src/server.ts:288-291 (registration)
    Dispatch handler in server.setRequestHandler(CallToolRequestSchema): routes 'translations' tool calls to handleTranslations function.
    // Translation-related tools
    case ApiTools.translations:
      return await handleTranslations(request.params.arguments);
    case ApiTools.translation_info:
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 a read operation ('Get list') but doesn't disclose behavioral traits like whether it requires authentication, has rate limits, returns paginated results, or what format the list is in. This leaves significant gaps for a tool with no annotation coverage.

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 no wasted words. It's front-loaded and appropriately sized for a simple tool, making it easy to parse quickly.

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 no annotations and no output schema, the description is incomplete. It doesn't explain what 'translations' refers to (e.g., Quran translations), the return format, or any behavioral context. For a tool in a context with many siblings, more detail is needed to ensure proper 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?

Schema description coverage is 100%, with one parameter 'language' documented in the schema. The description doesn't add any meaning beyond the schema—it doesn't explain what the 'language' parameter does (e.g., filter by language) or provide examples. Baseline 3 is appropriate as the schema handles parameter documentation.

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

Purpose3/5

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

The description 'Get list of available translations' states a clear verb ('Get') and resource ('translations'), but it's vague about what 'available translations' means—translations of what? It doesn't distinguish from siblings like 'translation-info' or 'languages', leaving ambiguity about scope.

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. With siblings like 'translation-info' and 'languages', the description lacks any context about differences, prerequisites, or exclusions, offering no help in tool selection.

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