@pipeworx/mcp-legislation-uk 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +99 -8
- package/bin/cli.js +17 -0
- package/package.json +15 -3
- package/server.json +1 -1
- package/src/index.ts +1433 -8
- package/src/server.ts +45 -0
- package/tsconfig.json +5 -1
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,13 +1,45 @@
|
|
|
1
|
-
#
|
|
1
|
+
# legislation-uk
|
|
2
2
|
|
|
3
|
-
legislation.gov.uk
|
|
3
|
+
UK legislation from [legislation.gov.uk](https://www.legislation.gov.uk) — the official database of UK Acts and statutory instruments. Search for legislation, read its metadata, read the actual text of an Act or of one section in the version you choose (as amended, as enacted, or as it stood on a date), see what has amended it (or what it amends), and read the plain-language Explanatory Notes.
|
|
4
4
|
|
|
5
|
-
Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to
|
|
5
|
+
Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 1683+ live data sources.
|
|
6
|
+
|
|
7
|
+
Covers England, Wales, Scotland and Northern Ireland: `ukpga` (UK Public General Acts), `uksi` (UK Statutory Instruments), `asp` (Acts of the Scottish Parliament), `anaw`/`asc` (Wales), `nia` (Northern Ireland Acts), `ukla` (UK Local Acts).
|
|
6
8
|
|
|
7
9
|
## Tools
|
|
8
10
|
|
|
9
|
-
| Tool |
|
|
10
|
-
|
|
11
|
+
| Tool | What it returns |
|
|
12
|
+
|------|-----------------|
|
|
13
|
+
| `search_uk_legislation` | Search by title words (and optional year) → matching Acts/instruments with full-text URLs. `type` is optional — an exact code, a plain category (`"act"`, `"si"`, `"ssi"`), or omit it to default to `ukpga`. (Renamed from `search_legislation` — the old name still resolves.) |
|
|
14
|
+
| `get_legislation` | Metadata for one Act/instrument by type + year + number: title, status, extent, enactment date, full-text URL |
|
|
15
|
+
| `get_legislation_section` | The actual text of ONE section — e.g. section 5 of the Data Protection Act 2018 (`ukpga/2018/12`) — without paying for the whole statute. Takes `as_at` (or `version`) for a point-in-time date. |
|
|
16
|
+
| `get_legislation_text` | The text of a whole Act/instrument, byte-bounded: large Acts are truncated with an explicit note pointing at the section-level tool. Takes `as_at` (or `version`). |
|
|
17
|
+
| `legislation_amendments` | What has amended this legislation (`direction: "affected"`, default) or what it amends (`direction: "affecting"`) — amending/amended instrument, affected/affecting provisions, change type, whether applied, commencement date. **Paged at 50** — always states `total_results`/`total_pages`. |
|
|
18
|
+
| `get_explanatory_notes` | Plain-language commentary written by the responsible government department, explaining what a section is meant to do. NOT part of the law. Pass `section` for one section's commentary, or omit for an overview + table of contents. |
|
|
19
|
+
|
|
20
|
+
### Versions (the trap)
|
|
21
|
+
|
|
22
|
+
UK legislation exists in point-in-time versions that differ in substance, not cosmetics: the text **as enacted** and the text **as amended** at a date. Section 5 of the Data Protection Act 2018 refers to "the GDPR" as enacted and "the UK GDPR" as it stands today. The text tools take a `version` argument — `"current"` (default), `"enacted"`, or a `YYYY-MM-DD` date — or the equivalent `as_at: "YYYY-MM-DD"` alias, and **every response states which version it served** (`version_valid_from`) and the date that version took effect. Repealed/omitted words appear as runs of dots, exactly as legislation.gov.uk renders them.
|
|
23
|
+
|
|
24
|
+
Section numbering also differs between versions: a section inserted by amendment does not exist in the enacted text, so a `section_not_found` for one version may still exist in another.
|
|
25
|
+
|
|
26
|
+
**legislation.gov.uk serves the nearest EARLIER version silently** when nothing changed on the exact date you asked for — the URL and `Content-Location` header both echo the date you requested even though the served text is older. The only place the real served date shows up is the document's own version metadata, which is why `version_valid_from` is on every response and a `version_note` explains the gap whenever `as_at` and `version_valid_from` differ.
|
|
27
|
+
|
|
28
|
+
### Amendments are paged at 50, never the total
|
|
29
|
+
|
|
30
|
+
`legislation_amendments` hits `/changes/{affected|affecting}/{type}/{year}/{number}/data.feed`, an Atom feed capped at 50 entries per page. The Data Protection Act 2018 alone has 2,271+ recorded effects across 46 pages — every response carries `total_results`, `total_pages`, `page`, and `next_page` so a caller never mistakes one page for the whole change history.
|
|
31
|
+
|
|
32
|
+
### Explanatory Notes have no XML — and no single page shape
|
|
33
|
+
|
|
34
|
+
`data.xml` 404s for `/notes`; only HTML exists, and legislation.gov.uk uses two different templates depending on the Act's age. Older Acts (e.g. Equality Act 2010) put the entire commentary — every section's notes — on one HTML page. Newer Acts (e.g. Data Protection Act 2018) serve only a "view PDF" stub at `/notes`; the real content sits under `/notes/contents`, split into numbered "divisions" (chapters), with per-section commentary living in whichever division is titled "Commentary on provisions of Act". `get_explanatory_notes` tries the flat page first and falls back to locating that division. Not every Act has notes at all (Appropriation, Consolidated Fund, Finance and Consolidation Acts never get them), and not every section gets its own paragraph — some are grouped or unremarked.
|
|
35
|
+
|
|
36
|
+
## Auth
|
|
37
|
+
|
|
38
|
+
None. legislation.gov.uk is keyless and free.
|
|
39
|
+
|
|
40
|
+
## Data sources
|
|
41
|
+
|
|
42
|
+
- [legislation.gov.uk](https://www.legislation.gov.uk) — full text as CLML XML at `/{type}/{year}/{number}/data.xml`, section-level at `/{type}/{year}/{number}/section/{n}/data.xml`, versioned via `/enacted` or `/{date}` path segments; search via the Atom feed at `/{type}/data.feed`; amendments via the Atom feed at `/changes/{affected|affecting}/{type}/{year}/{number}/data.feed`; Explanatory Notes as HTML at `/{type}/{year}/{number}/notes` (and `/notes/contents` for larger, division-split Acts).
|
|
11
43
|
|
|
12
44
|
## Quick Start
|
|
13
45
|
|
|
@@ -23,7 +55,25 @@ Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):
|
|
|
23
55
|
}
|
|
24
56
|
```
|
|
25
57
|
|
|
26
|
-
|
|
58
|
+
### What this endpoint actually serves
|
|
59
|
+
|
|
60
|
+
`tools/list` at `https://gateway.pipeworx.io/legislation-uk/mcp` returns the tools in the table
|
|
61
|
+
above **plus the shared Pipeworx meta-tools** — `ask_pipeworx`,
|
|
62
|
+
`discover_tools`, `search_within`, `remember`/`recall` and the rest of the
|
|
63
|
+
gateway-wide set. So the tool count you see is larger than this table: a
|
|
64
|
+
single-pack endpoint currently lists roughly 30 shared tools alongside the
|
|
65
|
+
pack's own. The connection's `initialize` response states its exact scope, and
|
|
66
|
+
is the authoritative answer for a given day.
|
|
67
|
+
|
|
68
|
+
This is deliberate, not multiplexing by accident. The meta-tools are what let a
|
|
69
|
+
scoped connection answer a question this pack does not cover — via
|
|
70
|
+
`ask_pipeworx`, which routes across the whole catalog — without you adding a
|
|
71
|
+
second MCP server. There is currently no way to mount a pack endpoint without
|
|
72
|
+
them; if the extra schemas cost you more context than the routing is worth,
|
|
73
|
+
connect to the full gateway once rather than to several pack endpoints.
|
|
74
|
+
|
|
75
|
+
Or connect to the full Pipeworx gateway to get every pack's tools listed
|
|
76
|
+
directly, instead of just this one's:
|
|
27
77
|
|
|
28
78
|
```json
|
|
29
79
|
{
|
|
@@ -35,9 +85,50 @@ Or connect to the full Pipeworx gateway for access to all 965+ data sources:
|
|
|
35
85
|
}
|
|
36
86
|
```
|
|
37
87
|
|
|
88
|
+
Both URLs reach the same gateway and the same 1683+ data sources. The
|
|
89
|
+
only difference is which pack's tools are listed **directly**; `ask_pipeworx`
|
|
90
|
+
reaches all of them from either one.
|
|
91
|
+
|
|
92
|
+
## No MCP client? Call it over HTTP
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
curl -X POST https://gateway.pipeworx.io/v1/tools/search_uk_legislation \
|
|
96
|
+
-H 'Content-Type: application/json' \
|
|
97
|
+
-d '{"type":"ukpga","title":"equality"}'
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
No account needed for the first calls. Inspect any tool: `GET https://gateway.pipeworx.io/v1/tools/search_uk_legislation`. Find one: `POST https://gateway.pipeworx.io/v1/tools/search_packs` with `{"query":"..."}`.
|
|
101
|
+
|
|
102
|
+
## Standalone (no gateway account)
|
|
103
|
+
|
|
104
|
+
This package also runs as a local stdio MCP server — no Pipeworx account, no
|
|
105
|
+
gateway round-trip:
|
|
106
|
+
|
|
107
|
+
```json
|
|
108
|
+
{
|
|
109
|
+
"mcpServers": {
|
|
110
|
+
"legislation-uk": {
|
|
111
|
+
"command": "npx",
|
|
112
|
+
"args": ["-y", "@pipeworx/mcp-legislation-uk"]
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Or run it directly to confirm it starts:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
npx -y @pipeworx/mcp-legislation-uk
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
It speaks MCP over stdin/stdout and answers `initialize`/`tools/list`/`tools/call`
|
|
125
|
+
for **only** this pack's tools — none of the shared meta-tools the gateway
|
|
126
|
+
connection above adds. Same source, same tools, no ask_pipeworx routing.
|
|
127
|
+
|
|
38
128
|
## Using with ask_pipeworx
|
|
39
129
|
|
|
40
|
-
Instead of calling tools directly, you can ask questions in plain English
|
|
130
|
+
Instead of calling tools directly, you can ask questions in plain English —
|
|
131
|
+
this works on the pack endpoint above as well as on the full gateway:
|
|
41
132
|
|
|
42
133
|
```
|
|
43
134
|
ask_pipeworx({ question: "your question about Legislation Uk data" })
|
|
@@ -47,7 +138,7 @@ The gateway picks the right tool and fills the arguments automatically.
|
|
|
47
138
|
|
|
48
139
|
## More
|
|
49
140
|
|
|
50
|
-
- [
|
|
141
|
+
- [Docs and guides](https://pipeworx.io/docs)
|
|
51
142
|
- [pipeworx.io](https://pipeworx.io)
|
|
52
143
|
|
|
53
144
|
## License
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
//
|
|
3
|
+
// Entry point for `npx @pipeworx/mcp-<slug>`.
|
|
4
|
+
//
|
|
5
|
+
// Packs ship as raw TypeScript (no build step — see publish-pack.sh for why:
|
|
6
|
+
// tsx sidesteps every extensionless-import / bare-JSON-import edge case a
|
|
7
|
+
// per-pack tsc build would have to solve one pack at a time). This file
|
|
8
|
+
// registers tsx's ESM loader programmatically, then hands off to src/server.ts,
|
|
9
|
+
// which wraps the pack's {tools, callTool} export in a stdio MCP server.
|
|
10
|
+
//
|
|
11
|
+
// Copied verbatim into every published pack repo by scripts/publish-pack.sh —
|
|
12
|
+
// edit this file, not a per-pack copy.
|
|
13
|
+
import { register } from 'tsx/esm/api';
|
|
14
|
+
|
|
15
|
+
register();
|
|
16
|
+
|
|
17
|
+
await import('../src/server.ts');
|
package/package.json
CHANGED
|
@@ -1,20 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipeworx/mcp-legislation-uk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "legislation.gov.uk MCP — the UK's official legislation database.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"types": "src/index.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"mcp-legislation-uk": "bin/cli.js"
|
|
10
|
+
},
|
|
8
11
|
"keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "legislation-uk"],
|
|
9
12
|
"license": "MIT",
|
|
10
13
|
"repository": {
|
|
11
14
|
"type": "git",
|
|
12
|
-
"url": "https://github.com/pipeworx-io/mcp-legislation-uk"
|
|
15
|
+
"url": "git+https://github.com/pipeworx-io/mcp-legislation-uk.git"
|
|
13
16
|
},
|
|
14
17
|
"scripts": {
|
|
15
18
|
"typecheck": "tsc --noEmit"
|
|
16
19
|
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
22
|
+
"tsx": "^4.19.0"
|
|
23
|
+
},
|
|
17
24
|
"devDependencies": {
|
|
18
|
-
"typescript": "^5.
|
|
25
|
+
"typescript": "^5.9.3",
|
|
26
|
+
"@cloudflare/workers-types": "^4.20260405.1"
|
|
27
|
+
},
|
|
28
|
+
"pipeworx": {
|
|
29
|
+
"sourceHash": "v1-5d6ee5fcac1c88ad132a6a3afbcaeb4b2a4e5381e585bbd71632536b68eb7bad",
|
|
30
|
+
"sourceCommit": "1064560fd9dcd0d6fc2606298c2ba244b3a1fbeb"
|
|
19
31
|
}
|
|
20
32
|
}
|
package/server.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "io.github.pipeworx-io/legislation-uk",
|
|
4
4
|
"title": "Legislation Uk",
|
|
5
5
|
"description": "legislation.gov.uk MCP — the UK's official legislation database.",
|
|
6
|
-
"version": "0.1.
|
|
6
|
+
"version": "0.1.2",
|
|
7
7
|
"websiteUrl": "https://pipeworx.io/packs/legislation-uk",
|
|
8
8
|
"repository": {
|
|
9
9
|
"url": "https://github.com/pipeworx-io/mcp-legislation-uk",
|