Skip to main content
Glama

search_hadith_by_topic

Find Hadith teachings on Islamic topics like prayer, fasting, charity, and faith using predefined topic mappings across major collections.

Instructions

Search Hadith collections by common Islamic topics. Uses predefined topic mappings for better results. Topics include: prayer, fasting, charity, hajj, faith, prophet, companions, knowledge, manners, family, marriage, death, jihad, repentance. The AI can suggest these topics to users based on their questions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
topicYesTopic to search for. Common topics: prayer, fasting, charity, hajj, faith, prophet, companions, knowledge, manners, family, marriage, death, jihad, repentance
collectionsNoSpecific collections to search in (optional)
max_resultsNoMaximum number of results to return (default: 10)

Implementation Reference

  • The main handler function that implements the search_hadith_by_topic tool logic. It maps the input topic to relevant keywords and delegates the search to the underlying searchHadith function.
    export async function searchHadithByTopic(
      topic: string,
      collections?: string[],
      maxResults: number = 10
    ): Promise<HadithSearchResult[]> {
      // Map common topics to search terms
      const topicKeywords: Record<string, string> = {
        'prayer': 'prayer salah worship prostrate',
        'fasting': 'fast fasting ramadan',
        'charity': 'charity sadaqah alms',
        'hajj': 'hajj pilgrimage kaaba',
        'faith': 'faith belief iman',
        'prophet': 'prophet messenger',
        'companions': 'companion sahaba',
        'knowledge': 'knowledge learn scholar',
        'manners': 'manner behavior conduct',
        'family': 'family parents children',
        'marriage': 'marriage wife husband',
        'death': 'death grave hereafter',
        'jihad': 'jihad struggle strive',
        'repentance': 'repent forgive sin',
      };
    
      const searchQuery = topicKeywords[topic.toLowerCase()] || topic;
      return searchHadith(searchQuery, collections, maxResults);
    }
  • The schema definition for the search_hadith_by_topic tool, including input parameters validation, description, and supported collections.
    {
      name: 'search_hadith_by_topic',
      description: 'Search Hadith collections by common Islamic topics. Uses predefined topic mappings for better results. Topics include: prayer, fasting, charity, hajj, faith, prophet, companions, knowledge, manners, family, marriage, death, jihad, repentance. The AI can suggest these topics to users based on their questions.',
      inputSchema: {
        type: 'object',
        properties: {
          topic: {
            type: 'string',
            description: 'Topic to search for. Common topics: prayer, fasting, charity, hajj, faith, prophet, companions, knowledge, manners, family, marriage, death, jihad, repentance',
          },
          collections: {
            type: 'array',
            description: 'Specific collections to search in (optional)',
            items: {
              type: 'string',
              enum: ['bukhari', 'muslim', 'abudawud', 'tirmidhi', 'nasai', 'ibnmajah'],
            },
          },
          max_results: {
            type: 'number',
            description: 'Maximum number of results to return (default: 10)',
            default: 10,
          },
        },
        required: ['topic'],
      },
    },
  • The switch case registration in the tool executor that handles calls to search_hadith_by_topic by invoking the handler function.
    case 'search_hadith_by_topic': {
      const { topic, collections, max_results = 10 } = args;
      result = await searchHadithByTopic(topic, collections, max_results);
      break;
    }
Behavior2/5

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

With no annotations provided, the description carries full burden of behavioral disclosure. It mentions 'predefined topic mappings for better results' which adds some context about search methodology, but doesn't describe what the tool returns (Hadith texts? references? metadata?), error conditions, rate limits, or authentication needs. For a search tool with zero annotation coverage, this is inadequate.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences efficiently convey core functionality and usage suggestion. The topic list could be trimmed since it duplicates schema content, but overall structure is front-loaded with purpose and appropriately sized.

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?

For a search tool with 3 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain what results look like (format, structure), success/error behavior, or how topic mappings work operationally. The description adds value through topic examples and AI suggestion context but doesn't compensate for missing behavioral and output information.

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%, so the schema already documents all parameters thoroughly. The description lists topic examples that match the schema's 'topic' parameter description, adding no new semantic information beyond what's in the structured fields. Baseline 3 is appropriate when schema does the heavy lifting.

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 tool's purpose: 'Search Hadith collections by common Islamic topics' with specific verb+resource. It distinguishes from sibling 'search_hadith' by emphasizing topic-based search with predefined mappings, though it doesn't explicitly contrast with 'search_quran_by_topic' which shares similar topic-based approach.

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 context ('common Islamic topics') and suggests AI can recommend topics based on user questions, but lacks explicit when-to-use guidance versus alternatives like 'search_hadith' (general search) or 'search_quran_by_topic'. No exclusions or prerequisites are mentioned.

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