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,
      };
    });
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It adequately describes the search functionality and return format (book numbers and names), but doesn't mention potential limitations like case sensitivity, partial matching behavior, or error handling for invalid queries.

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 efficiently structured with three sentences: purpose statement, usage context, and concrete examples. Every sentence adds value, and the examples are directly relevant to understanding the tool's functionality.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a search tool with no annotations and no output schema, the description provides adequate context about what the tool does and its purpose. However, without an output schema, it could benefit from more detail about the exact structure of returned results beyond 'book numbers and names'.

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, providing complete documentation for both parameters. The description adds minimal value beyond the schema by mentioning examples of query formats, but doesn't provide additional semantic context about parameter interactions or constraints.

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

Purpose5/5

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

The description clearly states the specific action ('Search for Bible books'), resource ('by name or abbreviation'), and output ('Returns book numbers (1-66) and names'). It distinguishes this tool from siblings like get_bible_verse by focusing on book metadata rather than verse content.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool ('Useful for finding the correct book number for other scripture tools'), establishing its role as a helper for other Bible-related operations. However, it doesn't explicitly state when NOT to use it or name specific alternatives among siblings.

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

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