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

legislation.gov.uk MCP Server

by legislation

search_legislation

Read-onlyIdempotent

Find UK legislation by keyword, title, type, year, extent, department, or subject. Filter, sort, and paginate results from legislation.gov.uk.

Instructions

Search for UK legislation by keyword, title, or other criteria on legislation.gov.uk. Returns JSON by default (set format="xml" for raw Atom feed).

Results include: id, type, year, number, title, and date. Use q for full-text keyword search, title for title search. Filter by type, year, startYear/endYear range, subject, department, extent, or language. Use sort to order results. Returns 20 results per page — use page to paginate; check meta.morePages in the response.

subject only applies to SI-family types (uksi, ssi, wsi, nisr, etc.); Acts don't carry subject metadata. If subject is set without a type, secondary is used by default.

See: types://guide, json://search-response, atom://feed-guide

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "search_legislation"
  }
}

Input Schema

NameRequiredDescriptionDefault
qNoFull-text keyword search across legislation content
pageNoPage number (default: 1, 20 results per page)
sortNoSort order for results. Options: - `relevance` — by match score; only meaningful with `q`, `title`, or `subject`. - `published` — publication date, newest first. - `title` — alphabetical. - `type` — grouped by legislation type. - `subject` — alphabetical by subject heading; only meaningful with `subject`. - `basic` — the site's fallback ordering. Category-grouped alphabetically, then year descending, then number descending. EU content (category `euretained`) sorts ahead of `primary` and `secondary`. Use with `q` to bypass relevance ranking. If omitted: `relevance` when `q` is set; `subject` when `subject` is set without `q`; otherwise `basic`.
typeNoFilter by legislation type. Each value is either a short type code (e.g. `ukpga`, `uksi`, `asp`; see `types://guide` for the full list) or an aggregation: `all`, `primary` (all Acts), `secondary` (all SIs), `eu-origin` (EU-retained), or `uk`/`wales`/`scotland`/`ni` (jurisdiction-level groupings). Pass multiple values to match any of them. `["primary", "secondary"]` is usually the most useful filter — it returns all Acts and SIs and excludes EU-retained legislation, which otherwise dominates results. Other examples: `["uksi", "ssi"]` for UK and Scottish SIs only.
yearNoFilter by specific year
titleNoSearch in legislation titles
extentNoFilter by geographic extent: E (England), W (Wales), S (Scotland), NI (Northern Ireland). Multiple values match legislation that extends to all of those jurisdictions (unless `exactExtent` is true).
formatNoResponse format (default: json for structured results, xml for raw Atom feed)
endYearNoEnd of year range (inclusive)
subjectNoFilter by subject heading (e.g. 'banking', 'housing', 'africa'). Only applies to SI-family types; sets `type` to `secondary` by default.
languageNoFilter by language: english (the default) or welsh
startYearNoStart of year range (inclusive)
departmentNoFilter by government department responsible for the legislation
exactExtentNoIf true, only return legislation whose extent is exactly the specified set and nothing else (default: false)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.1/5.0
Behavior4/5

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

Annotations already cover the read-only/idempotent/non-destructive profile, and the description adds real operational detail beyond that: JSON default with XML Atom alternative, 20 results per page, and pagination via `meta.morePages`. It stops short of discussing rate limits or failure behavior, but the pagination and format facts are the practically important ones.

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 core action and return format, then organized into a filter inventory and a caveat sentence. It is appropriately sized for a 14-parameter tool, though a few parameter restatements duplicate the schema text.

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

Completeness4/5

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

For a 14-parameter, zero-required search tool with no output schema, the description covers output fields, page size, pagination signal, and format choice, plus pointers to the types/response/feed guides. What remains uncovered is minor edge behavior (empty-result handling, error responses).

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

Parameters3/5

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

Schema coverage is 100%, so the schema already documents all 14 parameters in detail. The description restates several of those (q vs title, subject's SI-only restriction and secondary default, type aggregations) and adds only the result-field list and pagination pointer, so baseline 3 is appropriate.

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 ('Search for UK legislation ... on legislation.gov.uk') plus the searchable dimensions (keyword, title, criteria). The 'search' framing distinguishes it cleanly from the get_* siblings that retrieve a known item.

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

Usage Guidelines4/5

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

Explains which parameter selects which search mode ('Use `q` for full-text keyword search, `title` for title search') and when `subject` applies or is ignored. It does not explicitly contrast against the sibling get_legislation tools for known-item retrieval, so the when-not guidance is inferred rather than stated.

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