UK ONS MCP Server
This server provides access to UK Office for National Statistics (ONS) data, enabling you to discover, search, and retrieve official government statistics — no API key required.
List Datasets: Browse the full ONS dataset catalogue with pagination support.
Search Datasets: Find datasets by keyword, title, description, or ID (e.g. search "inflation" to find
cpih01).Get Dataset Metadata: Retrieve detailed metadata for a specific dataset by its ID.
Discover Dimensions: Learn about a dataset's required dimensions, including option counts and sample codes — essential before querying observations.
Get Dimension Options: Page through the complete list of valid option codes for any specific dimension.
Retrieve Observations: Fetch specific data points by supplying values for all dimensions, with exactly one wildcard (
*) allowed to vary a single dimension.Get Latest Data: Quickly obtain the most recent observations using auto-filled defaults (
time=*,geography=K02000001for UK-wide), with optional filters.Access Curated Resources: Use
ons://popular_datasetsfor a list of common dataset IDs, andons://api_infofor API details and recommended workflow.
All operations are read-only GET requests against the public ONS API, with input validation and bounded responses.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@UK ONS MCP Serverwhat's the latest UK inflation rate?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
UK ONS MCP Server
A Model Context Protocol (MCP) server for the UK Office for National Statistics (ONS) CMD API (https://api.beta.ons.gov.uk/v1).
Query official UK government statistics — inflation, GDP, wellbeing, trade, deaths and more — straight from your MCP-compatible assistant. No API key required.
Features
Direct ONS access — no authentication, no tokens
Browse & search the full published dataset catalogue
Dimension discovery — inspect a dataset's dimensions and valid option codes before querying
Real observations — pull data points filtered by geography, time and any other dimension
Latest-data shortcut that auto-fills sensible defaults
TypeScript, native
fetch, zero runtime deps beyond the MCP SDK and ZodInput validation and actionable, self-correcting error messages
Related MCP server: mcp-uk-ons
Requirements
Node.js >= 18.17 (uses the global
fetchandAbortSignal.timeout)
Recommended agent workflow
The ONS observations endpoint requires a value for every dimension of a dataset, and allows exactly one wildcard *. The intended flow is:
search_datasets— find a dataset id by keyword (e.g."inflation"->cpih01).get_dataset_dimensions— learn the required dimensions and see sample option codes.get_observation— request data, giving each dimension a value and using*for the one you want to vary.
get_latest_data is a convenience wrapper: it auto-fills time="*" and geography="K02000001" (UK) and any single-option dimension. If a dataset needs more choices, it returns the available options so you can switch to get_observation.
Available Tools
Tool | Purpose |
| Paginated list of all datasets ( |
| Keyword search over id/title/description/keywords. |
| Full metadata for one dataset by id. |
| Dimensions of a dataset's latest version, with option counts and samples. Call before |
| Page through the full list of valid option codes for one dimension. |
| Retrieve observations. Every dimension needs a value; exactly one may be |
| Latest observations with auto-filled |
Resources
URI | Description |
| Curated, live-verified list of common dataset ids. |
| API base URL, auth model and the recommended workflow. |
Example
Query CPIH (UK inflation) as a UK-wide time series:
// 1) discover dimensions
get_dataset_dimensions { "dataset_id": "cpih01" }
// -> dimensions: aggregate (122 options, e.g. CP00 "Overall Index"), geography, time
// 2) fetch the Overall Index across all time periods for the UK
get_observation {
"dataset_id": "cpih01",
"dimensions": { "time": "*", "geography": "K02000001", "aggregate": "CP00" }
}Omitting a required dimension returns a helpful error listing what is missing and sample codes to use, so an agent can retry without guessing.
Installation & configuration
Option A — npx (published package)
No install step; the client runs it on demand.
Claude Desktop (claude_desktop_config.json) or Claude Code (.mcp.json):
{
"mcpServers": {
"uk-ons": {
"command": "npx",
"args": ["-y", "uk_ons_mcp_server"]
}
}
}Option B — local build (from source)
git clone https://github.com/dwain-barnes/uk-ons-mcp-server.git
cd uk-ons-mcp-server
npm install
npm run buildThen point your client at the built entry point (use an absolute path):
{
"mcpServers": {
"uk-ons": {
"command": "node",
"args": ["/absolute/path/to/uk_ons_mcp_server/dist/index.js"]
}
}
}On Windows, use a full path such as C:\\Users\\you\\uk_ons_mcp_server\\dist\\index.js.
Claude Code can also add it from the CLI:
claude mcp add uk-ons -- node /absolute/path/to/uk_ons_mcp_server/dist/index.jsDevelopment
npm install
npm run build # compile TypeScript to dist/
npm start # run the built server on stdio
npm run dev # tsc --watch
npm run clean # remove dist/
npm test # build, then run the end-to-end smoke test against the live APIThe smoke test (test/smoke.mjs) spawns the built server over stdio with the MCP SDK client and checks all seven tools plus a resource end-to-end.
Security notes
Read-only. Every tool only performs
GETrequests against the public ONS API; nothing is written or mutated.No authentication or secrets. The ONS CMD API is open and keyless, so there are no tokens to store or leak.
Input validation. Dataset ids, editions, versions and dimension names are validated against a strict character set (
[A-Za-z0-9._-], max 100 chars) and every path/query value is URL-encoded before a request is made. Dimension values may additionally be the single wildcard*.Bounded responses. Observation results are capped (with a
truncatedflag and total count) to avoid overwhelming the model's context.
License
MIT — see LICENSE.
Disclaimer This project is unofficial and not endorsed by the UK Office for National Statistics. Data usage remains subject to ONS terms and the Open Government Licence.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/dwain-barnes/uk-ons-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server