A Code Mode Model Context Protocol server for every public API listed by the UK Parliament developer hub. It runs on Cloudflare Workers and gives MCP clients a compact way to discover and query the Parliament APIs.
Note
This is an independent project and is not affiliated with or endorsed by the UK Parliament.
The public MCP endpoint is:
https://uk-parliament-mcp.ghostwriternr.workers.dev/mcp
For clients that support .mcp.json:
{
"mcpServers": {
"uk-parliament": {
"type": "http",
"url": "https://uk-parliament-mcp.ghostwriternr.workers.dev/mcp"
}
}
}The hosted endpoint is unauthenticated and intended for reasonable public use. For production or high-volume workloads, deploy your own instance and protect it with Cloudflare Access and rate limiting.
The Deploy to Cloudflare flow
creates a copy of this repository in your GitHub or GitLab account, provisions
the R2 bucket declared in wrangler.jsonc, deploys the Worker, seeds its API
catalog, and configures Workers Builds for subsequent pushes. No Parliament API
credentials are required.
After deployment, use https://<your-worker>.<your-subdomain>.workers.dev/mcp
as the URL in your MCP client. Consider adding Cloudflare Access and rate
limiting before sharing the endpoint.
The server exposes two tools:
searchruns JavaScript against a pre-resolved catalog of Parliament OpenAPI specifications. It has no network access. Use it to find operation paths, parameters, and response schemas.executeruns JavaScript with a constructiveparliament.request()capability. Use it to combine, filter, and transform responses from multiple Parliament APIs in one call.
Generated code runs in isolated Dynamic Workers. Ambient network access and importable environment bindings are disabled. Only the execute worker receives the narrowly scoped, GET-only Parliament gateway.
Results follow JSON serialization semantics: undefined object properties are
omitted and undefined array entries become null.
The catalog currently contains 160 operations across 12 API families:
| API | Version |
|---|---|
| Members | v1 |
| Register of Interests | v2 |
| Commons Votes | v1 |
| Lords Votes | v1 |
| Oral Questions and Motions | v1 |
| Statutory Instruments | v2 |
| Treaties | v1 |
| Erskine May | v1 |
| Parliament Now | v1 |
| Bills | v1 |
| Written Questions and Statements | v1 |
| Committees | v1 |
Only the latest version advertised by each service is included.
MCP client
|
v
Cloudflare Worker (/mcp)
|-- search -> isolated Dynamic Worker -> catalog from R2
`-- execute -> isolated Dynamic Worker -> ParliamentGateway RPC
|
v
fixed Parliament API origins
The host-side gateway owns URL validation, timeouts, response-size limits, decoding, and structured failures. Search and execute use separate Dynamic Worker loaders because they have different security policies and resource limits.
The normalized OpenAPI catalog is stored in R2 and refreshed daily at 03:00 UTC.
Requirements:
- Node.js 22 or newer
- A Cloudflare account with Workers, R2, and Dynamic Worker loaders available
- Wrangler authentication (
npx wrangler login)
Install dependencies and run all checks:
npm ci
npm run types
npm run checkFor local development, create the R2 bucket once and seed the catalog:
npx wrangler r2 bucket create uk-parliament-mcp-spec
npm run seedRun locally:
npm run devThe local MCP endpoint is http://localhost:8787/mcp.
Wrangler deploys to the account selected by your current authentication, then seeds the newly provisioned R2 bucket:
npm run deployThe repository does not include a Cloudflare account ID or credentials. If you
change the Worker or bucket names, update wrangler.jsonc before seeding and
deploying.
Generated workers have explicit CPU and subrequest limits, no ambient network access, and no access to the host Worker's bindings. The execute worker can only make validated GET requests to the configured Parliament API origins.
The server itself does not authenticate MCP clients because the upstream APIs
are public. A self-hosted production deployment should add Cloudflare Access or
another authentication and rate-limiting policy in front of /mcp.