Skip to main content
Glama
djalal

quran-mcp-server

by djalal

languages

Retrieve all supported languages to access the Quran.com corpus. Ideal for users seeking multilingual Quranic resources via the quran-mcp-server's REST API.

Instructions

Get all languages

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
languageNoLanguage

Implementation Reference

  • The main handler function for the 'languages' MCP tool. Validates input using languagesSchema, calls languagesService.listLanguages(), logs response/error, and formats output as MCP content.
    /**
     * Handler for the languages tool
     */
    export async function handleLanguages(args: any) {
      try {
        // Validate arguments
        const validatedArgs = languagesSchema.parse(args);
        
        // Call the service
        const result = await languagesService.listLanguages(validatedArgs);
        
        // Log the response in verbose mode
        verboseLog('response', {
          tool: 'languages',
          result
        });
        
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(result, null, 2)
            }
          ]
        };
      } catch (error) {
        verboseLog('error', {
          tool: 'languages',
          error: error instanceof Error ? error.message : String(error)
        });
        
        // Use the standardized error response utility
        const { createErrorResponse } = require('../utils/error-handler');
        return createErrorResponse(error, 'languages');
      }
    }
  • Zod schema for validating input arguments to the 'languages' tool (optional 'language' parameter).
    export const languagesSchema = z.object({
      language: z.string().optional().describe("Language"),
    });
    
    // Export all language-related schemas
    export default {
      languages: languagesSchema,
    };
  • src/server.ts:232-236 (registration)
    Registration of the 'languages' tool in the MCP server's tools list, specifying name, description, input schema, and examples.
      name: ApiTools.languages,
      description: "Get all languages",
      inputSchema: zodToJsonSchema(languagesSchemas.languages),
      examples: toolExamples['languages'],
    },
  • src/server.ts:309-310 (registration)
    Dispatch/registration in the tool call switch statement: calls handleLanguages for ApiTools.languages.
    case ApiTools.languages:
      return await handleLanguages(request.params.arguments);
  • Core service logic for listing languages: checks cache, makes API request to Quran.com /resources/languages, falls back to mock data on error.
    async listLanguages(params: z.infer<typeof languagesSchema>): Promise<LanguagesResponse> {
      try {
        // Validate parameters
        const validatedParams = languagesSchema.parse(params);
        
        // Check cache first
        const now = Date.now();
        if (this.languagesCache && (now - this.cacheTimestamp < CACHE_DURATION_MS)) {
          verboseLog('response', {
            method: 'listLanguages',
            source: 'cache',
            age: `${(now - this.cacheTimestamp) / 1000} seconds`
          });
          
          return {
            success: true,
            message: "languages executed successfully (from cache)",
            data: this.languagesCache
          };
        }
        
        try {
          // Make request to Quran.com API
          const url = `${API_BASE_URL}/resources/languages`;
          const response = await makeApiRequest(url, {
            language: validatedParams.language
          });
          
          verboseLog('response', {
            method: 'listLanguages',
            source: 'api',
            dataSize: JSON.stringify(response).length
          });
          
          // Update cache
          this.languagesCache = response;
          this.cacheTimestamp = now;
          
          return {
            success: true,
            message: "languages executed successfully",
            data: response
          };
        } catch (axiosError) {
          verboseLog('error', {
            method: 'listLanguages',
            error: axiosError instanceof Error ? axiosError.message : String(axiosError)
          });
          
          // If the API call fails, return mock data
          verboseLog('response', {
            method: 'listLanguages',
            source: 'mock',
            reason: 'API unavailable'
          });
          
          const mockData = this.getLanguagesMockData();
          
          return {
            success: true,
            message: "languages executed with mock data (API unavailable)",
            data: mockData
          };
        }
      } catch (error) {
        verboseLog('error', {
          method: 'listLanguages',
          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: 'listLanguages',
          source: 'mock',
          reason: 'error occurred'
        });
        
        const mockData = this.getLanguagesMockData();
        
        return {
          success: true,
          message: "languages executed with mock data (error occurred)",
          data: mockData
        };
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden. 'Get all languages' implies a read-only operation, but it doesn't disclose behavioral traits such as whether it returns a list, supports filtering via the 'language' parameter, has rate limits, or requires authentication. This is a significant gap 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 extremely concise with just three words, front-loaded and zero waste. Every word earns its place by stating the core action and resource, making it efficient for quick understanding.

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, no output schema, and a vague purpose, the description is incomplete. It doesn't explain what 'languages' are in this context, how the parameter works, or what the return values look like. For a tool with 1 parameter and unclear scope, it should provide more context to be fully helpful.

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 input schema has 1 parameter with 100% description coverage ('language' described as 'Language'), so the schema does the heavy lifting. The description doesn't add any meaning beyond this, such as explaining how the parameter filters results or its expected format. Baseline 3 is appropriate when schema coverage is high.

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 all languages' clearly states the verb ('Get') and resource ('languages'), but it's vague about what 'languages' refers to (e.g., programming languages, natural languages, Quran translations) and doesn't distinguish from siblings like 'translations' or 'tafsirs'. It's functional but lacks specificity.

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. Given sibling tools like 'translations' and 'tafsirs' that might relate to languages, the description doesn't clarify its unique context or exclusions, leaving the agent to infer usage.

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