From 1274a90ad0c223242fc574552d356278a375df1d Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 8 Oct 2026 18:57:19 +0000 Subject: [PATCH] Add getSeedBibleLink tool to the MCP server Returns a https://seedbible.org/{translationId}/{bookId}/{chapter} link for a reference such as "John 3:16" or "Ps 23 WEB", with the same optional translation parameter as fetchVerse. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01U3unrjDchfkq1Q1FMu8Q6r --- packages/seed-bible-mcp/README.md | 5 ++-- packages/seed-bible-mcp/src/bible.ts | 13 +++++++++ packages/seed-bible-mcp/src/mcp.ts | 43 ++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/packages/seed-bible-mcp/README.md b/packages/seed-bible-mcp/README.md index b351f0a..938e465 100644 --- a/packages/seed-bible-mcp/README.md +++ b/packages/seed-bible-mcp/README.md @@ -1,13 +1,14 @@ # Free Use Bible MCP Server -An [MCP](https://modelcontextprotocol.io) server that exposes the [Free Use Bible API](https://bible.helloao.org) (BSB, WEB, Hebrew WLC, SBL Greek NT) through four tools: +An [MCP](https://modelcontextprotocol.io) server that exposes the [Free Use Bible API](https://bible.helloao.org) (BSB, WEB, Hebrew WLC, SBL Greek NT) through five tools: - `getBibleReference` — turns a reference such as `John 3:16` or `Gen 1:1-3 WEB` into a passage result id. - `fetchChapter` — returns the passage text for a result id from `getBibleReference`. - `fetchVerse` — returns the text of a verse or verse range within one chapter, for a reference such as `John 3:16` or `Gen 1:1-3 WEB`. +- `getSeedBibleLink` — returns a link to the chapter on [Seed Bible](https://seedbible.org) (`https://seedbible.org/{translationId}/{bookId}/{chapter}`) for a reference such as `John 3:16` or `Ps 23 WEB`. - `listTranslations` — lists the available translations, optionally filtered by language (e.g. `spa` or `Spanish`) and by name. -`getBibleReference` and `fetchVerse` take an optional `translation` parameter that accepts any translation id from `listTranslations` (e.g. `spa_rv1909`). Without it, the translation is picked from the reference (BSB, WEB, WLC, or SBL), defaulting to BSB. +`getBibleReference`, `fetchVerse`, and `getSeedBibleLink` take an optional `translation` parameter that accepts any translation id from `listTranslations` (e.g. `spa_rv1909`). Without it, the translation is picked from the reference (BSB, WEB, WLC, or SBL), defaulting to BSB. The server speaks the Streamable HTTP transport at `/mcp` and runs statelessly, so the same code runs on Node.js and on Cloudflare Workers. diff --git a/packages/seed-bible-mcp/src/bible.ts b/packages/seed-bible-mcp/src/bible.ts index 3c085c9..87c6272 100644 --- a/packages/seed-bible-mcp/src/bible.ts +++ b/packages/seed-bible-mcp/src/bible.ts @@ -188,6 +188,19 @@ export function chapterUrl( return `${apiBase}/${translation}/${book}/${chapter}.json`; } +export const SEED_BIBLE_BASE = 'https://seedbible.org'; + +/** + * Builds a link to a chapter on Seed Bible, e.g. https://seedbible.org/BSB/JHN/3 + */ +export function seedBibleUrl( + translation: string, + book: string, + chapter: number +): string { + return `${SEED_BIBLE_BASE}/${encodeURIComponent(translation)}/${encodeURIComponent(book)}/${chapter}`; +} + export function passageTitle( translation: string, book: string, diff --git a/packages/seed-bible-mcp/src/mcp.ts b/packages/seed-bible-mcp/src/mcp.ts index d28b2d0..2daaf33 100644 --- a/packages/seed-bible-mcp/src/mcp.ts +++ b/packages/seed-bible-mcp/src/mcp.ts @@ -14,6 +14,7 @@ import { parseResultId, resolveTranslationId, passageTitle, + seedBibleUrl, } from './bible.js'; export interface BibleMcpOptions { @@ -69,6 +70,7 @@ export function createBibleMcpServer(options: BibleMcpOptions = {}): McpServer { 'Use getBibleReference() to interpret a user query into a Bible passage result. ' + 'Then use fetchChapter() to retrieve the full passage text. ' + 'To get the text of a verse or verse range directly, use fetchVerse(). ' + + 'To link a reader to a chapter on Seed Bible (seedbible.org), use getSeedBibleLink(). ' + 'Use listTranslations() to find available translations by language or name, then pass a translation id as the translation parameter. ' + 'References can name BSB, WEB (ENGWEBP), Hebrew WLC (heb_wlc), or SBL Greek NT (grc_sbl) directly; other translations need the translation parameter.', // The default Ajv validator compiles schemas with `new Function`, @@ -205,6 +207,47 @@ export function createBibleMcpServer(options: BibleMcpOptions = {}): McpServer { } ); + server.registerTool( + 'getSeedBibleLink', + { + description: + 'Get a link to a Bible chapter on Seed Bible (https://seedbible.org/{translationId}/{bookId}/{chapter}), from a reference such as "John 3" or "Gen 1:1-3 WEB".', + inputSchema: { + reference: z + .string() + .describe( + 'A chapter, verse, or verse range reference, optionally followed by a translation, e.g. "John 3", "John 3:16" or "Ps 23 WEB". Seed Bible links point to the whole chapter.' + ), + translation: translationParam, + }, + }, + async ({ reference, translation: requestedTranslation }) => { + const translationId = requestedTranslation + ? await resolveTranslationId(apiBase, requestedTranslation) + : undefined; + if (translationId === null) { + return unknownTranslation(requestedTranslation!); + } + const ref = await parseQueryToRef( + apiBase, + reference, + translationId + ); + if (!ref) { + return error( + `Could not interpret "${reference}" as a Bible reference.` + ); + } + + const [translation, book, chapter, verses] = ref; + return json({ + title: passageTitle(translation, book, chapter, verses), + url: seedBibleUrl(translation, book, chapter), + metadata: { translation, book, chapter, verses }, + }); + } + ); + server.registerTool( 'listTranslations', {