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; }

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