Get Judgment Paragraph
judgment_get_paragraphRetrieve a single paragraph from a UK court judgment by its slug and paragraph eId. First discover eIds by using the index tool.
Instructions
Get a single paragraph from a UK court judgment by its LegalDocML eId.
Use judgment_get_index first to discover available eIds. Returns the paragraph XML content (400–1,700 tokens typical).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| slug | Yes | Judgment slug, e.g. 'uksc/2024/12' | |
| eId | Yes | Paragraph eId from judgment_get_index, e.g. 'para_12' |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/gateway.py:258-262 (registration)Tool registration for 'judgment_get_paragraph' on the gateway FastMCP instance via @gateway.tool decorator.
@gateway.tool( name="judgment_get_paragraph", annotations={"title": "Get Judgment Paragraph", "readOnlyHint": True, "idempotentHint": True}, ) async def judgment_get_paragraph( - src/gateway.py:262-277 (handler)Handler function: fetches judgment XML from TNA, calls extract_paragraph parser, returns dict with slug, eId, and content.
async def judgment_get_paragraph( slug: Annotated[str, Field(description="Judgment slug, e.g. 'uksc/2024/12'", min_length=3, max_length=200)], eId: Annotated[str, Field(description="Paragraph eId from judgment_get_index, e.g. 'para_12'", min_length=1, max_length=100)], ctx: Context, ) -> dict: """Get a single paragraph from a UK court judgment by its LegalDocML eId. Use judgment_get_index first to discover available eIds. Returns the paragraph XML content (400–1,700 tokens typical). """ import httpx client: httpx.AsyncClient = ctx.lifespan_context["xml_http"] resp = await client.get(f"{TNA_BASE}/{slug.lstrip('/')}/data.xml") resp.raise_for_status() content = case_law_parsers.extract_paragraph(resp.text, eId) return {"slug": slug, "eId": eId, "content": content} - src/gateway.py:263-265 (schema)Input schema (inline Pydantic Field annotations): slug (min_length=3, max_length=200) and eId (min_length=1, max_length=100).
slug: Annotated[str, Field(description="Judgment slug, e.g. 'uksc/2024/12'", min_length=3, max_length=200)], eId: Annotated[str, Field(description="Paragraph eId from judgment_get_index, e.g. 'para_12'", min_length=1, max_length=100)], ctx: Context, - Pure-function helper that parses LegalDocML XML and extracts a single paragraph by eId using lxml XPath.
def extract_paragraph(xml_text: str, eId: str) -> str: """Return a single `<paragraph eId="X">` serialised back to XML.""" root = _root(xml_text) el = root.find(f".//akn:paragraph[@eId='{eId}']", LEGALDOCML_NS) if el is None: raise KeyError(f"No paragraph with eId={eId!r}") return etree.tostring(el, pretty_print=False).decode()