Skip to main content
Glama
legislation.gov.uk MCP Server

legislation.gov.uk MCP Server

by legislation

get_legislation_fragment

Read-onlyIdempotent

Retrieve a specific section, part, or chapter of UK legislation in plain text or structured formats, with optional point-in-time versions for focused reading, summarisation, or amendment checks.

Instructions

Retrieve a fragment (section, part, chapter, etc.) of a UK legislation document. Returns readable plain text by default (text). Also available: xml (CLML with full metadata), akn (Akoma Ntoso), html.

Text is best for reading and summarisation. It discards semantic markup, amendment commentaries, and structural metadata — use xml to track amendments, follow cross-references, or check in-force status.

type, year, and number must be exact — use search_legislation to confirm if unsure. Use get_legislation_table_of_contents to discover fragment IDs. Common fragmentId patterns: section/1, part/2, part/1/chapter/3, regulation/5, crossheading/name. The API does not support fragment IDs deeper than the section or regulation level (e.g. section/1/a is not a valid ID).

Version: use a date (YYYY-MM-DD) for a point-in-time snapshot, or enacted/made/created/adopted for the original version. Do not pass version="prospective"; when metadata lists "prospective", that is the latest fragment version and should be fetched by omitting the version parameter.

See: types://guide, cookbook://point-in-time-version

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "type": "<type>",
      "year": "<year>",
      "number": "<number>",
      "fragmentId": "<fragmentId>"
    },
    "name": "get_legislation_fragment"
  }
}

Input Schema

NameRequiredDescriptionDefault
typeYesType of legislation (e.g., ukpga, uksi, asp, ukla)
yearYesYear of enactment. A 4-digit calendar year (e.g., 2020) works for all legislation. For pre-1963 Acts, the canonical identifier uses a regnal year in Reign/Number format (e.g., Vict/63, Geo5/26) — but a calendar year will usually work too, as the API redirects. Use regnal years when you need to disambiguate (a calendar year can span two regnal years). See the years://regnal resource for valid identifiers.
formatNoResponse format (default: text for readable plain text, xml for CLML, akn for Akoma Ntoso, html for rendered version)
numberYesLegislation number (e.g., 18, 1234)
versionNoOptional: Version to retrieve. Use enacted/made/created/adopted for original version, or YYYY-MM-DD for legislation as it stood on that date. Do not use prospective here; when versions ends with prospective, omit version to fetch that version. Dates before first version return an error.
languageNoOptional: Set to "welsh" to retrieve the Welsh-language text for bilingual legislation (e.g. asc, anaw types). Defaults to "english". Non-bilingual legislation ignores this parameter.
fragmentIdYesFragment identifier path (e.g., section/5, part/1/chapter/2, regulation/10)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.8/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already cover safety (readOnly, idempotent, non-destructive), and the description adds substantive behavior on top: text output discards markup, amendment commentaries and structural metadata; the API rejects fragment IDs deeper than section/regulation; pre-first-version dates error; non-bilingual legislation silently ignores `language`. These are real failure modes an agent could not infer from the schema or annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with purpose, then format selection, then ID rules, then version semantics — a logical order with no filler sentences. Minor redundancy: the prospective-version rule and much of the version explanation appear nearly verbatim in the schema's `version` description, costing some density.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With 7 parameters, two enums, and no output schema, the description carries the right load: it defines what each format returns, how IDs are shaped and bounded, and how versioning resolves. Nothing needed to call the tool correctly appears missing, and it points to resources (`types://guide`, `cookbook://point-in-time-version`) for the deep edge cases.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so 3 is the floor, but the description genuinely adds meaning: concrete fragmentId patterns (`section/1`, `part/1/chapter/3`, `regulation/5`, `crossheading/name`) and the depth restriction, plus the requirement that type/year/number be exact. The `version` explanation largely restates the schema field description, so it falls short of a full 5.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource with scope: 'Retrieve a fragment (section, part, chapter, etc.) of a UK legislation document.' The fragment-vs-whole-document scope and the sibling pointers (search_legislation, get_legislation_table_of_contents) let an agent distinguish it from get_legislation without opening a schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit routing guidance: use search_legislation to confirm type/year/number, use get_legislation_table_of_contents to discover fragment IDs, and use xml instead of text when amendment tracking, cross-references, or in-force status matter. It also states a negative rule (do not pass version="prospective"; omit version instead), which is exactly the kind of when-not guidance that prevents bad calls.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.