Skip to main content
Glama

search_bible_books

Find Bible book numbers and names by searching with book titles or abbreviations. Use this tool to identify correct book references for scripture lookup.

Instructions

Search for Bible books by name or abbreviation. Returns book numbers (1-66) and names. Useful for finding the correct book number for other scripture tools. Examples: "matt" -> Matthew (40), "1 john" -> 1 John (62), "gen" -> Genesis (1).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query - can be book name, abbreviation, or number. Examples: "matthew", "matt", "mt", "40", "1 john"
limitNoMaximum number of results to return (default: 10)

Implementation Reference

  • Defines the tool schema including name, description, and input validation schema for the search_bible_books tool.
    export const searchBibleBooksTool = { name: 'search_bible_books', description: 'Search for Bible books by name or abbreviation. Returns book numbers (1-66) and names. Useful for finding the correct book number for other scripture tools. Examples: "matt" -> Matthew (40), "1 john" -> 1 John (62), "gen" -> Genesis (1).', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query - can be book name, abbreviation, or number. Examples: "matthew", "matt", "mt", "40", "1 john"' }, limit: { type: 'number', description: 'Maximum number of results to return (default: 10)', default: 10 } }, required: ['query'] } };
  • The primary handler function that implements the search_bible_books tool. Validates input, calls searchBooks helper, formats results with testament info, and returns JSON or error messages.
    export async function searchBibleBooksImplementation(query, limit = 10) { try { if (!query || typeof query !== 'string') { return { content: [{ type: 'text', text: 'Error: Query must be a non-empty string' }], isError: true }; } const results = searchBooks(query, limit); if (results.length === 0) { return { content: [{ type: 'text', text: `No Bible books found matching "${query}". Try using a book name, abbreviation, or number (1-66).` }] }; } // Format results const formattedResults = results.map(r => ({ number: r.number, name: r.name, testament: r.number <= 39 ? 'Old Testament' : 'New Testament', relevance_score: r.score })); return { content: [{ type: 'text', text: JSON.stringify({ query: query, results_count: formattedResults.length, books: formattedResults }, null, 2) }] }; } catch (error) { return { content: [{ type: 'text', text: `Error searching Bible books: ${error.message}` }], isError: true }; } }
  • Supporting utility function that performs fuzzy search on Bible book names and abbreviations, calculates relevance scores, sorts results, and limits output. Called by the main handler.
    export function searchBooks(query, limit = 10) { if (!query || typeof query !== 'string') { return []; } const normalizedQuery = query.toLowerCase().trim(); // If query is a number, return exact match const asNumber = parseInt(normalizedQuery); if (!isNaN(asNumber) && asNumber >= 1 && asNumber <= 66) { return [{ number: asNumber, name: BIBLE_BOOKS[asNumber], score: 100 }]; } const results = []; // Search through all books for (const [num, name] of Object.entries(BIBLE_BOOKS)) { const bookNum = parseInt(num); const nameLower = name.toLowerCase(); let score = 0; // Exact match if (nameLower === normalizedQuery) { score = 100; } // Starts with query else if (nameLower.startsWith(normalizedQuery)) { score = 80; } // Contains query else if (nameLower.includes(normalizedQuery)) { score = 60; } // Check if any word starts with query else if (nameLower.split(' ').some(word => word.startsWith(normalizedQuery))) { score = 70; } // Also check abbreviations for (const [abbr, abbNum] of Object.entries(BOOK_ABBREVIATIONS)) { if (abbNum === bookNum && abbr.startsWith(normalizedQuery)) { score = Math.max(score, 75); } } if (score > 0) { results.push({ number: bookNum, name: name, score: score }); } } // Sort by score (highest first), then by book number results.sort((a, b) => { if (b.score !== a.score) { return b.score - a.score; } return a.number - b.number; }); return results.slice(0, limit); }
  • src/index.js:52-56 (registration)
    Registers the search_bible_books tool (included in allTools) for the stdio MCP server by handling ListToolsRequestSchema.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: allTools, }; });
  • Registers the search_bible_books tool (included in allTools) for the HTTP MCP server by handling ListToolsRequestSchema.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: allTools, }; });

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/advenimus/jw-mcp'

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