Skip to main content
Glama
djalal

quran-mcp-server

by djalal

search

Find specific terms in the Quran by entering a search query, adjusting results per page, and selecting a language. Use pagination to navigate through results efficiently.

Instructions

Search the Quran for specific terms

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
languageNoISO code of language, use this query params if you want to boost translations for specific language.
pageNoPage number, well for pagination. You can use *p* as well
qYesSearch query, you can use *query* as well
sizeNoResults per page. *s* is also valid parameter.

Implementation Reference

  • Handler function for the 'search' tool. Validates input args using searchSchema, calls searchService.search(), logs verbose info, formats response as MCP content block, and handles Zod/validation errors.
    export async function handleSearch(args: any) {
      try {
        // Validate arguments
        const validatedArgs = searchSchema.parse(args);
        
        // Call the service
        const result = await searchService.search(validatedArgs);
        
        // Log the response in verbose mode
        verboseLog('response', {
          tool: 'search',
          result
        });
        
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(result, null, 2)
            }
          ]
        };
      } catch (error) {
        verboseLog('error', {
          tool: 'search',
          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 search tool defining parameters: q (string, required), size/page/language (optional strings).
    export const searchSchema = z.object({
      q: z.string().describe("Search query, you can use *query* as well"),
      size: z.string().optional().describe("Results per page. *s* is also valid parameter."),
      page: z.string().optional().describe("Page number, well for pagination. You can use *p* as well"),
      language: z.string().optional().describe("ISO code of language, use this query params if you want to boost translations for specific language."),
    });
  • src/server.ts:185-189 (registration)
    Tool registration in listTools handler: defines 'search' tool name (ApiTools.search), description, inputSchema from searchSchemas.search, and examples.
      name: ApiTools.search,
      description: "Search the Quran for specific terms",
      inputSchema: zodToJsonSchema(searchSchemas.search),
      examples: toolExamples['search'],
    },
  • src/server.ts:285-286 (registration)
    Tool dispatch registration in callTool handler: switch case for 'search' that invokes handleSearch with arguments.
    case ApiTools.search:
      return await handleSearch(request.params.arguments);
  • Core search logic in SearchService.search(): validates params, constructs API URL, calls makeApiRequest to Quran.com /search endpoint with query params, returns formatted SearchResponse. Handles errors.
    async search(params: z.infer<typeof searchSchema>): Promise<SearchResponse> {
      try {
        // Validate parameters
        const validatedParams = searchSchema.parse(params);
        
        const url = `${API_BASE_URL}/search`;
        
        // Make request to Quran.com API
        const data = await makeApiRequest(url, {
          q: validatedParams.q,
          size: validatedParams.size,
          page: validatedParams.page,
          language: validatedParams.language
        });
        
        return {
          success: true,
          message: "search executed successfully",
          data
        };
      } catch (error) {
        verboseLog('error', {
          method: 'search',
          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;
      }
    }
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 of behavioral disclosure. It states the tool searches for 'specific terms' but doesn't mention how results are returned (e.g., format, pagination details), whether it's case-sensitive, if it supports advanced operators, or any rate limits. This leaves significant gaps in understanding the tool's behavior.

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, clear sentence that directly states the tool's purpose without unnecessary words. It's front-loaded and efficiently communicates the core functionality, making it easy to understand at a glance.

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 the complexity of a search tool with 4 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what the search returns (e.g., verses, chapters, metadata), how results are structured, or any behavioral nuances. For a tool that likely returns complex results, more context is needed.

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 the schema already documents all parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema, such as explaining how the 'q' parameter interacts with Quranic text or typical search patterns. Baseline 3 is appropriate when the schema handles parameter documentation.

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

Purpose4/5

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

The description clearly states the action ('Search') and resource ('the Quran'), making the purpose immediately understandable. However, it doesn't differentiate this search tool from other Quran-related tools on the server, such as 'verses-by_chapter_number' or 'tafsir', which might also involve searching or retrieving content.

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?

The description provides no guidance on when to use this tool versus alternatives. With multiple sibling tools like 'verses-by_chapter_number' or 'tafsir' that might retrieve Quranic content, there's no indication of when a full-text search is preferable over structured verse retrieval.

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