get_text
Retrieve Jewish texts and commentaries from the Sefaria library by providing a specific reference, enabling access to traditional and scholarly resources.
Instructions
get a jewish text from the jewish library
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| reference | Yes | The reference of the jewish text, e.g. 'שולחן ערוך אורח חיים סימן א' or 'Genesis 1:1' |
Implementation Reference
- The primary handler function for the 'get_text' tool. It retrieves Hebrew text from the Sefaria API for the provided reference by calling get_hebrew_text and converting it to string.async def get_text(reference: str) -> str: """ Retrieves the text for a given reference. """ return str(get_hebrew_text(reference))
- JSON Schema defining the input for the 'get_text' tool, specifying a required 'reference' parameter of type string.inputSchema={ "type": "object", "properties": { "reference": { "type": "string", "description": "The reference of the jewish text, e.g. 'שולחן ערוך אורח חיים סימן א' or 'Genesis 1:1'", }, }, "required": ["reference"], },
- src/sefaria_jewish_library/server.py:36-49 (registration)Registers the 'get_text' tool with the MCP server in the list_tools handler, including name, description, and schema.types.Tool( 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"], }, ),
- Helper function called by get_text to fetch the Hebrew text from Sefaria API using get_request_json_data.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