Get Judgment Header
judgment_get_headerRetrieve metadata for a UK court judgment including parties, judges, neutral citation, court, and dates using a judgment slug. Get a quick orientation before reading specific paragraphs.
Instructions
Get metadata for a UK court judgment: parties, judges, neutral citation, court, dates.
Use case_law_search to find the slug, then call this for orientation before reading specific paragraphs via judgment_get_paragraph.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| slug | Yes | Judgment slug, e.g. 'uksc/2024/12' or 'ewca/civ/2023/450' |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/gateway.py:216-229 (handler)The async handler function that executes the 'judgment_get_header' tool logic: fetches judgment XML from TNA and extracts the header element.
async def judgment_get_header( slug: Annotated[str, Field(description="Judgment slug, e.g. 'uksc/2024/12' or 'ewca/civ/2023/450'", min_length=3, max_length=200)], ctx: Context, ) -> dict: """Get metadata for a UK court judgment: parties, judges, neutral citation, court, dates. Use case_law_search to find the slug, then call this for orientation before reading specific paragraphs via judgment_get_paragraph. """ 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() return {"slug": slug, "header": case_law_parsers.extract_header(resp.text)} - src/gateway.py:212-214 (registration)Registers the 'judgment_get_header' tool with FastMCP gateway, including metadata annotations.
@gateway.tool( name="judgment_get_header", annotations={"title": "Get Judgment Header", "readOnlyHint": True, "idempotentHint": True}, - src/gateway.py:217-218 (schema)Input schema: a 'slug' string parameter with Pydantic Field validation (min_length=3, max_length=200). Returns a dict with slug and header.
slug: Annotated[str, Field(description="Judgment slug, e.g. 'uksc/2024/12' or 'ewca/civ/2023/450'", min_length=3, max_length=200)], ctx: Context, - Helper function that parses the Akoma Ntoso XML to extract the <header> element using lxml.
def extract_header(xml_text: str) -> str: """Return `<header>...</header>` serialised back to XML.""" root = _root(xml_text) header = root.find(".//akn:header", LEGALDOCML_NS) if header is None: raise KeyError("No <header> element in this judgment") return etree.tostring(header, pretty_print=False).decode()