Skip to main content

Official Python client SDK for Translation Helps MCP Server

Project description

translation-helps-mcp-client

Official Python client SDK for the Translation Helps MCP Server.

Installation

pip install translation-helps-mcp-client

Quick Start

Basic MCP Client Usage

import asyncio
from translation_helps import TranslationHelpsClient

async def main():
    # Create a client instance
    async with TranslationHelpsClient() as mcp_client:
        # Get available tools and prompts
        tools = await mcp_client.list_tools()
        prompts = await mcp_client.list_prompts()
        
        # Use tools/prompts directly with MCP-compatible interfaces
        # (e.g., Claude Desktop, Cursor, OpenAI Agents SDK)

asyncio.run(main())

Using with OpenAI Chat Completions API

import asyncio
from translation_helps import TranslationHelpsClient
from translation_helps.adapters import prepare_tools_for_provider
from openai import OpenAI

async def main():
    mcp_client = TranslationHelpsClient()
    await mcp_client.connect()
    
    # Get tools and prompts
    tools = await mcp_client.list_tools()
    prompts = await mcp_client.list_prompts()
    
    # Optional: Use adapter utility to prepare tools for OpenAI
    openai_client = OpenAI(api_key="your-api-key")
    openai_tools = prepare_tools_for_provider("openai", tools, prompts)
    
    # Use with OpenAI
    response = openai_client.chat.completions.create(
        model="gpt-4",
        messages=[{"role": "user", "content": "What does John 3:16 say?"}],
        tools=openai_tools
    )
    
    # When AI requests a tool call, execute it via SDK:
    # result = await mcp_client.call_tool(tool_name, tool_args)
    # Feed result back to AI for final response

asyncio.run(main())

Note: The adapter utilities are optional. You can also write your own conversion logic or use MCP tools/prompts directly if your provider supports MCP natively.

Usage with Context Manager

import asyncio
from translation_helps import TranslationHelpsClient

async def main():
    async with TranslationHelpsClient() as client:
        scripture = await client.fetch_scripture({
            "reference": "John 3:16"
        })
        print(scripture)

asyncio.run(main())

API Reference

TranslationHelpsClient

Main client class for interacting with the Translation Helps MCP server.

Constructor

TranslationHelpsClient(options: Optional[ClientOptions] = None)

Options:

  • serverUrl: Optional[str] - Server URL (default: production server)
  • timeout: Optional[int] - Request timeout in ms (default: 30000)
  • headers: Optional[Dict[str, str]] - Custom headers

Methods

async connect() -> None

Initialize connection to the MCP server. Automatically called by convenience methods.

async close() -> None

Close the HTTP client connection.

async fetch_scripture(options: FetchScriptureOptions) -> str

Fetch Bible scripture text.

text = await client.fetch_scripture({
    "reference": "John 3:16",
    "language": "en",
    "organization": "unfoldingWord",
    "format": "text",  # or "usfm"
    "includeVerseNumbers": True
})
async fetch_translation_notes(options: FetchTranslationNotesOptions) -> Dict

Fetch translation notes for a passage.

notes = await client.fetch_translation_notes({
    "reference": "John 3:16",
    "language": "en",
    "includeIntro": True,
    "includeContext": True
})
async fetch_translation_questions(options: FetchTranslationQuestionsOptions) -> Dict

Fetch translation questions for a passage.

questions = await client.fetch_translation_questions({
    "reference": "John 3:16",
    "language": "en"
})
async fetch_translation_word(options: FetchTranslationWordOptions) -> Dict

Fetch translation word article by term or reference.

# By term
word = await client.fetch_translation_word({
    "term": "love",
    "language": "en"
})

# By reference (gets words used in passage)
words = await client.fetch_translation_word({
    "reference": "John 3:16",
    "language": "en"
})
async fetch_translation_word_links(options: FetchTranslationWordLinksOptions) -> Dict

Fetch translation word links for a passage.

links = await client.fetch_translation_word_links({
    "reference": "John 3:16",
    "language": "en"
})
async fetch_translation_academy(options: FetchTranslationAcademyOptions) -> Any

Fetch translation academy articles.

articles = await client.fetch_translation_academy({
    "reference": "John 3:16",
    "language": "en",
    "format": "json"  # or "markdown"
})
async get_languages(options: Optional[GetLanguagesOptions] = None) -> Dict

Get available languages and organizations.

languages = await client.get_languages({
    "organization": "unfoldingWord"
})
async list_tools() -> List[MCPTool]

List all available MCP tools.

async list_prompts() -> List[MCPPrompt]

List all available MCP prompts.

async call_tool(name: str, arguments: Dict[str, Any]) -> Dict[str, Any]

Call any MCP tool directly.

async get_prompt(name: str, arguments: Optional[Dict[str, Any]] = None) -> Dict[str, Any]

Get a prompt template.

async check_prompts_support() -> bool

Dynamically check if the MCP server supports prompts.

async get_capabilities() -> Dict[str, Any]

Get the server's capabilities (tools and prompts support).

Optional Adapter Utilities

The SDK includes optional adapter utilities for converting MCP tools and prompts to different AI provider formats. These are convenience helpers - you can use them, write your own conversion logic, or use MCP tools/prompts directly if your provider supports MCP natively.

Using Adapters

from translation_helps import TranslationHelpsClient
from translation_helps.adapters import (
    prepare_tools_for_provider,
    convert_all_to_openai,
    provider_supports_prompts
)

# Declarative approach (recommended)
tools = await client.list_tools()
prompts = await client.list_prompts()
openai_tools = prepare_tools_for_provider("openai", tools, prompts)

# Low-level approach (more control)
openai_tools = convert_all_to_openai(tools, prompts)

# Check provider capabilities
if provider_supports_prompts("claude-desktop"):
    # Use prompts natively
    prompt = await client.get_prompt("translation-helps-for-passage", {...})
else:
    # Convert prompts to tools
    tools = prepare_tools_for_provider("openai", tools, prompts)

Available Adapter Functions

  • prepare_tools_for_provider(provider, tools, prompts) - Declarative helper that automatically handles conversion
  • convert_tools_to_openai(tools) - Convert MCP tools to OpenAI format
  • convert_prompts_to_openai(prompts) - Convert MCP prompts to OpenAI format (workaround)
  • convert_all_to_openai(tools, prompts) - Convert both tools and prompts
  • convert_tools_to_anthropic(tools) - Convert MCP tools to Anthropic format
  • provider_supports_prompts(provider) - Check if provider supports MCP prompts natively
  • get_prompt_strategy(provider, tools, prompts) - Get conversion strategy
  • detect_prompts_support_from_client(client) - Dynamically detect prompts support

See the adapters module documentation for more details.

Examples

Basic Usage

import asyncio
from translation_helps import TranslationHelpsClient

async def main():
    client = TranslationHelpsClient()
    await client.connect()

    # Fetch scripture
    scripture = await client.fetch_scripture({
        "reference": "John 3:16"
    })

    # Fetch comprehensive helps
    notes = await client.fetch_translation_notes({
        "reference": "John 3:16"
    })

    questions = await client.fetch_translation_questions({
        "reference": "John 3:16"
    })

    words = await client.fetch_translation_word({
        "reference": "John 3:16"
    })

    await client.close()

asyncio.run(main())

Error Handling

try:
    scripture = await client.fetch_scripture({
        "reference": "John 3:16"
    })
except Exception as e:
    print(f"Failed to fetch scripture: {e}")

Custom Server URL

client = TranslationHelpsClient({
    "serverUrl": "https://your-custom-server.com/api/mcp",
    "timeout": 60000  # 60 seconds
})

License

MIT

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

translation_helps_mcp_client-1.1.1.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

translation_helps_mcp_client-1.1.1-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file translation_helps_mcp_client-1.1.1.tar.gz.

File metadata

File hashes

Hashes for translation_helps_mcp_client-1.1.1.tar.gz
Algorithm Hash digest
SHA256 479990c41c73385baaf90d07ac4bb57bad93db63e8291563d42b5e37a9c4fb63
MD5 1bf0281b517dee3d6b6d7b2205fadec8
BLAKE2b-256 dc65c2f9514bb9e313c622d6d575b808ef2cc92588a1ab8ab4fdf17cebccc00b

See more details on using hashes here.

File details

Details for the file translation_helps_mcp_client-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for translation_helps_mcp_client-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9b0def91115ede46f1f0f73efb889496846f61a5197cbd39744c3dd59073fe33
MD5 2e17a36ab2696db5a4dc58630b483aca
BLAKE2b-256 98872ea262b540381082c5a0130c16b20e1e62ab409b27dbdd965a003befaad8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page