Skip to main content
Glama
Sivan22

Sefaria Jewish Library MCP Server

get_text

Retrieve Jewish texts from the Sefaria Library using specific references like 'Genesis 1:1' or 'שולחן ערוך אורח חיים סימן א' for accurate access to religious scripture and literature.

Instructions

get a jewish text from the jewish library

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
referenceYesThe reference of the jewish text, e.g. 'שולחן ערוך אורח חיים סימן א' or 'Genesis 1:1'

Implementation Reference

  • Core handler function implementing the logic for the 'get_text' tool by fetching Hebrew text via helper.
    async def get_text(reference: str) -> str:
        """
        Retrieves the text for a given reference.
        """
        return str(get_hebrew_text(reference))
  • Dispatch handler in call_tool that extracts arguments and invokes the get_text function.
    if name == "get_text":
        try:
            reference = arguments.get("reference")
            if not  reference:
                raise ValueError("Missing reference parameter")  
            
            logger.debug(f"handle_get_text: {reference}")
            text = await get_text(reference)
            
            
            return [types.TextContent(
                type="text",
                text= text
            )]
        except Exception as err:
            logger.error(f"retreive text error: {err}", exc_info=True)
            return [types.TextContent(
                type="text",
                text=f"Error: {str(err)}"
            )]
  • JSON schema defining the input parameters for the 'get_text' tool (requires 'reference' string).
        "type": "object",
        "properties": {
            "reference": {
                "type": "string",
                "description": "The reference of the jewish text, e.g. 'שולחן ערוך אורח חיים סימן א' or 'Genesis 1:1'",                               
            },
        },
        "required": ["reference"],
    },
  • Registration of the 'get_text' tool in the server's list_tools response.
        name="get_text",
        description="get a jewish text from the jewish library",
        inputSchema={
            "type": "object",
            "properties": {
                "reference": {
                    "type": "string",
                    "description": "The reference of the jewish text, e.g. 'שולחן ערוך אורח חיים סימן א' or 'Genesis 1:1'",                               
                },
            },
            "required": ["reference"],
        },
    ),
  • Supporting helper that performs the actual API request to retrieve Hebrew text from Sefaria.
    def get_hebrew_text(parasha_ref):
        """
        Retrieves the Hebrew text and version title for the given verse.
        """
        data = get_request_json_data("api/v3/texts/", parasha_ref)
    
        if data and "versions" in data and len(data['versions']) > 0:
            he_pasuk = data['versions'][0]['text']
            return  he_pasuk
        else:
            print(f"Could not retrieve Hebrew text for {parasha_ref}")
            return None
Install Server

Other Tools

Related 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/Sivan22/mcp-sefaria-server'

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