search-bible
Search Korean and English Bible verses by keyword. Finds matches in the first 10 chapters of each book across multiple Korean translations like GAE, NIR, KOR, CEV.
Instructions
Search for verses containing specific keywords. Searches the first 10 chapters of each book — not a full-Bible search.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query (Korean or English) | |
| version | No | Bible translation version (default: GAE) | GAE |
Implementation Reference
- src/index.ts:238-266 (handler)The call tool handler case for 'search-bible'. Validates input using searchBibleSchema, calls searchVerses() with query and version, formats the results with book/chapter/verse references, and returns a text response.
case "search-bible": { const validated = validateInput(searchBibleSchema, args, 'search-bible'); const { query, version = "GAE" } = validated; const results = await searchVerses(query, version); if (results.length === 0) { return { content: [ { type: "text", text: `No results found for "${query}".`, }, ], }; } let result = `# Search Results for "${query}"\n`; result += `Found ${results.length} verses:\n\n`; for (const verse of results) { result += `**${verse.book} ${verse.chapter}:${verse.verse}**\n`; result += `${verse.text}\n\n`; } return { content: [{ type: "text", text: result }], }; } - src/validation.ts:20-23 (schema)Zod schema for search-bible input validation. Defines 'query' (required string) and 'version' (optional enum of GAE/GAE1/NIR/KOR/CEV).
export const searchBibleSchema = z.object({ query: z.string().min(1), version: z.enum(['GAE', 'GAE1', 'NIR', 'KOR', 'CEV']).optional(), }); - src/index.ts:90-109 (registration)Tool registration entry for 'search-bible' in the tools array. Includes name, description ('Search for verses containing specific keywords. Searches the first 10 chapters of each book'), and inputSchema definition.
{ name: "search-bible", description: "Search for verses containing specific keywords. Searches the first 10 chapters of each book — not a full-Bible search.", inputSchema: { type: "object", properties: { query: { type: "string", description: "Search query (Korean or English)", }, version: { type: "string", description: "Bible translation version (default: GAE)", enum: ["GAE", "GAE1", "NIR", "KOR", "CEV"], default: "GAE", }, }, required: ["query"], }, }, - src/bible.ts:277-315 (helper)The searchVerses() function that performs the actual search. Iterates through all books (up to CONFIG.SEARCH.CHAPTERS_PER_BOOK=10 chapters each), fetches each chapter via fetchChapter(), and does a case-insensitive substring match on verse text. Returns matching verses with book, chapter, and verse references.
export async function searchVerses( query: string, version: string = "GAE", books?: string[] ): Promise<Array<{ book: string; chapter: number; verse: number; text: string }>> { const results: Array<{ book: string; chapter: number; verse: number; text: string }> = []; const searchLower = query.toLowerCase(); // Determine which books to search const booksToSearch = books || Object.keys(BIBLE_BOOKS); for (const bookName of booksToSearch) { const bookInfo = BIBLE_BOOKS[bookName]; if (!bookInfo) continue; // Search first few chapters (limit to avoid too many requests) for (let chapter = 1; chapter <= CONFIG.SEARCH.CHAPTERS_PER_BOOK; chapter++) { try { const chapterData = await fetchChapter(bookInfo.code, chapter, version); for (const verse of chapterData.verses) { if (verse.text.toLowerCase().includes(searchLower)) { results.push({ book: chapterData.book, chapter: chapterData.chapter, verse: verse.number, text: verse.text, }); } } } catch (error) { // Skip chapters that don't exist or fail to fetch break; } } } return results; } - src/config.ts:16-19 (helper)Search configuration constants. CHAPTERS_PER_BOOK: 10 (first 10 chapters only, not full-Bible search), MAX_BOOKS_TO_SEARCH: 66 (all books).
SEARCH: { MAX_BOOKS_TO_SEARCH: 66, // Search all books CHAPTERS_PER_BOOK: 10, // First 10 chapters for demo },