Skip to main content
Glama

Search UK Legislation

legislation_search
Read-onlyIdempotent

USE THIS TOOL WHEN searching UK Acts and Statutory Instruments by title, phrase, or full-text.

Returns ranked results: title, type, year, number, legislation.gov.uk URL, and next_steps hints (toc URI, section template). AFTER calling, chain to legislation_get_toc then legislation_get_section for structural drill-in.

Filter discipline: type and year are exact-match. Use only when you already know the value. For currency-driven searches, query by phrase and read the returned year; guessing an exact year can zero results. For broader concept queries across content, set fulltext=True. If the default title route receives a typed legislation.gov.uk WAF/non-XML failure, the tool automatically tries that documented full-text route once and marks search_mode="fulltext_fallback"; its broader relevance semantics must not be treated as a title-ranked result. Render-pending and ordinary HTTP failures do not trigger this fallback.

Source: legislation.gov.uk Atom search feed, with an explicit fallback marker when the alternative official full-text route supplied results.

Input Schema

NameRequiredDescriptionDefault
typeNoFilter by type: 'ukpga' (Acts), 'uksi' (SIs), 'asp' (Scottish Acts), 'nia' (NI Acts). Exact-match — omit if you don't already know whether you're looking for an Act vs an SI.
yearNoFilter by year of enactment (exact-match — a single integer, not a range). Omit unless you already know the Act's year. Speculating a year (e.g. 'this is recent so it must be 2026') and getting it wrong will zero out the result set. Better workflow: query without `year`, then read the year from the returned results.
limitNoMaximum results to return (1–50). Passed to the upstream results-count param.
queryYesSearch query, e.g. 'Housing Act 1988' or 'data protection personal data'
fulltextNoDefault false → searches Act/SI titles only (best for finding a named Act, e.g. 'Housing Act 1988' returns ukpga/1988/50 first). Set true to search the full text of every Act/SI for the query (returns SIs and regulations that cite the term — e.g. 'rental deposits' would return many implementing instruments).

Output Schema

NameRequiredDescriptionDefault
totalYesTotal number of matches
resultsYesMatching legislation items
search_modeNoRoute that produced these results. fulltext_fallback means the title route was unavailable because legislation.gov.uk returned a typed WAF/non-XML failure, so the server retried once using the documented full-text route; relevance may therefore be broader than title search.title
fallback_reasonNoTyped upstream reason that triggered the automatic full-text fallback, or null when the requested route completed normally.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changed
    • addedOutput schema / properties / fallback_reason
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "Typed upstream reason that triggered the automatic full-text fallback, or null when the requested route completed normally."
      +}
    • addedOutput schema / properties / search_mode
      Added value: +{
      +  "default": "title",
      +  "description": "Route that produced these results. fulltext_fallback means the title route was unavailable because legislation.gov.uk returned a typed WAF/non-XML failure, so the server retried once using the documented full-text route; relevance may therefore be broader than title search.",
      +  "enum": [
      +    "title",
      +    "fulltext",
      +    "fulltext_fallback"
      +  ],
      +  "type": "string"
      +}
  2. Changed7 schema fields changed
    • addedInput schema / properties / fulltext
      Added value: +{
      +  "default": false,
      +  "description": "Default false → searches Act/SI titles only (best for finding a named Act, e.g. 'Housing Act 1988' returns ukpga/1988/50 first). Set true to search the full text of every Act/SI for the query (returns SIs and regulations that cite the term — e.g. 'rental deposits' would return many implementing instruments).",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / limit
      Added value: +{
      +  "default": 20,
      +  "description": "Maximum results to return (1–50). Passed to the upstream results-count param.",
      +  "maximum": 50,
      +  "minimum": 1,
      +  "type": "integer"
      +}
    • removedInput schema / properties / params
      Removed value: -{
      -  "additionalProperties": false,
      -  "description": "LegislationSearchInput.",
      -  "properties": {
      -    "fulltext": {
      -      "default": false,
      -      "description": "Default false → searches Act/SI titles only (best for finding a named Act, e.g. 'Housing Act 1988' returns ukpga/1988/50 first). Set true to search the full text of every Act/SI for the query (returns SIs and regulations that cite the term — e.g. 'rental deposits' would return many implementing instruments).",
      -      "type": "boolean"
      -    },
      -    "limit": {
      -      "default": 20,
      -      "description": "Maximum results to return (1–50). Passed to the upstream results-count param.",
      -      "maximum": 50,
      -      "minimum": 1,
      -      "type": "integer"
      -    },
      -    "query": {
      -      "description": "Search query, e.g. 'Housing Act 1988' or 'data protection personal data'",
      -      "maxLength": 500,
      -      "minLength": 1,
      -      "type": "string"
      -    },
      -    "type": {
      -      "anyOf": [
      -        {
      -          "type": "string"
      -        },
      -        {
      -          "type": "null"
      -        }
      -      ],
      -      "default": null,
      -      "description": "Filter by type: 'ukpga' (Acts), 'uksi' (SIs), 'asp' (Scottish Acts), 'nia' (NI Acts). Exact-match — omit if you don't already know whether you're looking for an Act vs an SI."
      -    },
      -    "year": {
      -      "anyOf": [
      -        {
      -          "maximum": 2100,
      -          "minimum": 1800,
      -          "type": "integer"
      -        },
      -        {
      -          "type": "null"
      -        }
      -      ],
      -      "default": null,
      -      "description": "Filter by year of enactment (exact-match — a single integer, not a range). Omit unless you already know the Act's year. Speculating a year (e.g. 'this is recent so it must be 2026') and getting it wrong will zero out the result set. Better workflow: query without `year`, then read the year from the returned results."
      -    }
      -  },
      -  "required": [
      -    "query"
      -  ],
      -  "type": "object"
      -}
    • addedInput schema / properties / query
      Added value: +{
      +  "description": "Search query, e.g. 'Housing Act 1988' or 'data protection personal data'",
      +  "maxLength": 500,
      +  "minLength": 1,
      +  "type": "string"
      +}
    • addedInput schema / properties / type
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "Filter by type: 'ukpga' (Acts), 'uksi' (SIs), 'asp' (Scottish Acts), 'nia' (NI Acts). Exact-match — omit if you don't already know whether you're looking for an Act vs an SI."
      +}
    • addedInput schema / properties / year
      Added value: +{
      +  "anyOf": [
      +    {
      +      "maximum": 2100,
      +      "minimum": 1800,
      +      "type": "integer"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "Filter by year of enactment (exact-match — a single integer, not a range). Omit unless you already know the Act's year. Speculating a year (e.g. 'this is recent so it must be 2026') and getting it wrong will zero out the result set. Better workflow: query without `year`, then read the year from the returned results."
      +}
    • changedInput schema / required
      Previous value: -[
      -  "params"
      -]New value: +[
      +  "query"
      +]
  3. Changed1 schema field changed
    • addedInput schema / properties / params / properties / limit
      Added value: +{
      +  "default": 20,
      +  "description": "Maximum results to return (1–50). Passed to the upstream results-count param.",
      +  "maximum": 50,
      +  "minimum": 1,
      +  "type": "integer"
      +}
  4. Changed1 schema field changed
    • changedInput schema / properties / params / description
      Previous value: -"LegislationSearchInput with query, optional type filter, optional year."New value: +"LegislationSearchInput."
  5. Changed2 schema fields changed
    • changedInput schema / properties / params / properties / type / description
      Previous value: -"Filter by type: 'ukpga' (Acts), 'uksi' (SIs), 'asp' (Scottish Acts), 'nia' (NI Acts)"New value: +"Filter by type: 'ukpga' (Acts), 'uksi' (SIs), 'asp' (Scottish Acts), 'nia' (NI Acts). Exact-match — omit if you don't already know whether you're looking for an Act vs an SI."
    • changedInput schema / properties / params / properties / year / description
      Previous value: -"Filter by year of enactment"New value: +"Filter by year of enactment (exact-match — a single integer, not a range). Omit unless you already know the Act's year. Speculating a year (e.g. 'this is recent so it must be 2026') and getting it wrong will zero out the result set. Better workflow: query without `year`, then read the year from the returned results."
  6. Changed3 schema fields changed
    • changedOutput schema / properties / results / items / properties / number / description
      Previous value: -"Chapter or SI number"New value: +"Chapter (for Acts) or SI number. Part of the {type}/{year}/{number} triple that identifies an Act or SI."
    • changedOutput schema / properties / results / items / properties / type / description
      Previous value: -"Legislation type code, e.g. 'ukpga', 'uksi'"New value: +"Legislation type code, e.g. 'ukpga' (UK Public General Act), 'uksi' (Statutory Instrument), 'asp' (Scottish Parliament Act). Use with `year` and `number` as the triple {type}/{year}/{number} in the legislation_get_toc / legislation_get_section tools, or in legislation://{type}/{year}/{number}/section/{section}{?date} resource URIs."
    • changedOutput schema / properties / results / items / properties / year / description
      Previous value: -"Year of enactment or making"New value: +"Year of enactment or making. Part of the {type}/{year}/{number} triple that identifies an Act or SI."
  7. Changed1 schema field changed
    • addedInput schema / properties / params / description
      Added value: +"LegislationSearchInput with query, optional type filter, optional year."
  8. Changed1 schema field changed
    • addedOutput schema / properties / results / items / properties / next_steps
      Added value: +{
      +  "additionalProperties": {
      +    "type": "string"
      +  },
      +  "description": "Canonical resource URIs for reading this Act/SI. Read `toc` to discover sections, then `section_template` (substitute the section number) for the section text. Both URIs accept an optional ?date=YYYY-MM-DD query for point-in-time historical research.",
      +  "type": "object"
      +}
  9. Changed2 schema fields changed
    • addedInput schema / properties / params / properties / fulltext
      Added value: +{
      +  "default": false,
      +  "description": "Default false → searches Act/SI titles only (best for finding a named Act, e.g. 'Housing Act 1988' returns ukpga/1988/50 first). Set true to search the full text of every Act/SI for the query (returns SIs and regulations that cite the term — e.g. 'rental deposits' would return many implementing instruments).",
      +  "type": "boolean"
      +}
    • changedInput schema / properties / params / properties / query / description
      Previous value: -"Search query, e.g. 'data protection personal data'"New value: +"Search query, e.g. 'Housing Act 1988' or 'data protection personal data'"
  10. Changed6 schema fields changed
    • changedOutput schema / description
      Previous value: -"Generic wrapper for non-object return types."New value: +"Container for legislation search results."
    • removedOutput schema / properties / result
      Removed value: -{
      -  "type": "string"
      -}
    • addedOutput schema / properties / results
      Added value: +{
      +  "description": "Matching legislation items",
      +  "items": {
      +    "description": "Single legislation search result.",
      +    "properties": {
      +      "number": {
      +        "description": "Chapter or SI number",
      +        "type": "integer"
      +      },
      +      "score": {
      +        "anyOf": [
      +          {
      +            "type": "number"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "default": null,
      +        "description": "Relevance score from Lex API (higher = more relevant)"
      +      },
      +      "title": {
      +        "description": "Full title of the legislation",
      +        "type": "string"
      +      },
      +      "type": {
      +        "description": "Legislation type code, e.g. 'ukpga', 'uksi'",
      +        "type": "string"
      +      },
      +      "url": {
      +        "description": "Canonical legislation.gov.uk URL",
      +        "type": "string"
      +      },
      +      "year": {
      +        "description": "Year of enactment or making",
      +        "type": "integer"
      +      }
      +    },
      +    "required": [
      +      "title",
      +      "type",
      +      "year",
      +      "number",
      +      "url"
      +    ],
      +    "type": "object"
      +  },
      +  "type": "array"
      +}
    • addedOutput schema / properties / total
      Added value: +{
      +  "description": "Total number of matches",
      +  "type": "integer"
      +}
    • changedOutput schema / required
      Previous value: -[
      -  "result"
      -]New value: +[
      +  "results",
      +  "total"
      +]
    • removedOutput schema / x-fastmcp-wrap-result
      Removed value: -true
  11. First observed

TDQS

A4.8/5.0
Behavior5/5

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

Annotations already cover the safety profile (readOnly, idempotent, non-destructive), and the description goes well beyond them: the automatic full-text fallback on WAF/non-XML failures, the search_mode="fulltext_fallback" marker, the warning that fallback relevance is not title-ranked, and the explicit statement that render-pending/ordinary HTTP errors do not trigger it. That is precisely the kind of hidden behavior an agent would otherwise misread.

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 the trigger condition and the chaining instruction, which is the right order. It runs long and the 'Filter discipline' passage restates what the type/year schema descriptions already say, so a few sentences could be trimmed, but nothing is filler.

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?

Even though an output schema exists, the description names the returned fields and next_steps hints so the agent knows what it can chain on, and it fully documents the fallback mode. Nothing needed to call or interpret the result is missing.

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 the schema carries the parameter definitions; the description mostly reinforces them (exact-match type/year, fulltext semantics). It does add a workflow-level insight the schema lacks – that guessing a year can zero the result set and you should read the year off results instead – but much of the filter discussion duplicates schema text.

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 ('searching UK Acts and Statutory Instruments') plus the search modes (title, phrase, full-text), which clearly separates it from structural siblings like legislation_get_toc and legislation_get_section. An agent can tell exactly what to reach it for.

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?

Opens with an explicit 'USE THIS TOOL WHEN' condition and adds an 'AFTER calling, chain to legislation_get_toc then legislation_get_section' routing rule. It also gives negative guidance for the filters (only use type/year when you already know the value; omit year and read it from results), which is real when-not guidance.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.