Skip to main content
Glama

get_random_hadith

Retrieve a random Hadith from Islamic collections for daily inspiration or study, with optional filtering by specific collections like Bukhari or Muslim.

Instructions

Get a random Hadith from a collection. Great for daily inspiration!

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionNoHadith collection (optional). If not specified, picks from any collection.

Implementation Reference

  • Core handler function that implements get_random_hadith logic: selects random collection if unspecified, picks random hadith number, and fetches using getHadith.
    export async function getRandomHadith(collection?: string): Promise<HadithResponse> {
      // If no collection specified, pick a random one
      const selectedCollection = collection ||
        HADITH_COLLECTIONS[Math.floor(Math.random() * HADITH_COLLECTIONS.length)].slug;
    
      const collectionInfo = HADITH_COLLECTIONS.find(c => c.slug === selectedCollection);
      if (!collectionInfo) {
        throw new QuranMCPError(
          `Unknown hadith collection: ${selectedCollection}`,
          'INVALID_COLLECTION'
        );
      }
    
      // Get random hadith number
      const randomNumber = Math.floor(Math.random() * collectionInfo.totalHadiths) + 1;
    
      return getHadith(selectedCollection, randomNumber);
    }
  • Tool schema definition including name, description, and input validation schema.
    {
      name: 'get_random_hadith',
      description: 'Get a random Hadith from a collection. Great for daily inspiration!',
      inputSchema: {
        type: 'object',
        properties: {
          collection: {
            type: 'string',
            description: 'Hadith collection (optional). If not specified, picks from any collection.',
            enum: ['bukhari', 'muslim', 'abudawud', 'tirmidhi', 'nasai', 'ibnmajah'],
          },
        },
      },
    },
  • Tool registration in the central switch dispatcher that maps tool name to handler execution.
    case 'get_random_hadith': {
      const { collection } = args;
      result = await getRandomHadith(collection);
      break;
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. It mentions 'random' retrieval and 'daily inspiration', but fails to disclose critical behavioral traits such as whether the tool requires authentication, has rate limits, returns structured data (e.g., text, source, narrator), or handles errors. This leaves significant gaps for an agent to use it effectively.

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 two sentences, front-loaded with the core functionality ('Get a random Hadith from a collection') and followed by a brief use case ('Great for daily inspiration!'). Every word adds value without redundancy, making it efficient and easy to parse.

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 lack of annotations and output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., Hadith text, metadata), error conditions, or operational constraints like rate limits. For a tool with no structured behavioral data, this leaves the agent under-informed about how to handle the response or potential issues.

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 100% description coverage, with the parameter 'collection' well-documented (optional, enum values, default behavior). The description adds no additional parameter semantics beyond what the schema provides, such as explaining the significance of collection choices or how randomness is weighted. Thus, it meets the baseline for high schema coverage.

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 verb ('Get') and resource ('a random Hadith from a collection'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_hadith' or 'search_hadith_by_topic', which likely serve different purposes (e.g., specific vs. random retrieval).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for 'daily inspiration', suggesting a context of random retrieval for motivational purposes. However, it lacks explicit guidance on when to use this tool versus alternatives like 'get_hadith' (which might fetch a specific Hadith) or 'search_hadith_by_topic' (which might filter by topic), leaving the agent to infer based on the 'random' keyword.

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

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/Prince77-7/quranMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server