ONS + Nomis MCP server
Provides access to UK economic, social, and labour-market statistics via the ONS beta and Nomis APIs, enabling discovery and retrieval of time series, datasets, and census data.
README
ONS + Nomis MCP server
An MCP server over two UK statistics platforms, exposed from one server:
- ONS beta Customise My Data (
https://api.beta.ons.gov.uk/v1) — headline economic and social time series (CPIH, regional GDP, wellbeing). Open, no key, rate-limited to 120 req/10s and 200/min. - Nomis (
https://www.nomisweb.co.uk/api/v01) — census and labour-market statistics (Claimant Count, Annual Population Survey, Census 2011/2021 tables, workforce jobs). Open; an optionaluid(NOMIS_API_KEY) lifts limits for large queries.
The two APIs share no dimension model, so the Nomis tools are namespaced
nomis_*. Rule of thumb: ONS beta for headline economic indicators,
Nomis for granular local-area, census and labour-market tables.
Implementations
Two interchangeable implementations of the same 18-tool surface live here:
- Python (
ons_mcp/, FastMCP) — the reference implementation. - .NET / C# (
dotnet/, ASP.NET Core + the MCP C# SDK) — a like-for-like port, and what runs in production.
Both expose the identical tools and behaviour. The live service is
https://ons-mcp.library-apps.dev/mcp (the .NET container, behind Cloudflare
Access). See dotnet/README.md for the port and
docs/deploy.md for deployment.
Which route to use
For headline indicators — use get_timeseries. It serves the
published figure straight from the ONS website's series (the same number
ONS quotes), already chronologically ordered.
For multi-dimensional slicing — use the CMD dataset tools. They can filter by geography, age, category etc. in ways the published series can't.
CMD curation is uneven. Some datasets track publication closely (
weekly-deaths-region, updated within days); others lag badly (cpih01was five months behind the published CPIH series in July 2026;regional-gdp-by-yearwas three years behind).get_datasetandsearch_datasetsreturnlast_updatedand astaleness_warning— check them before quoting a CMD figure.
Option codes can also change between versions (cpih1dim1A0 in v1 became
CP00 in v67). A wrong code returns zero observations, not an error —
get_observations now diagnoses this and lists valid codes.
ONS beta API — data model
Datasets are held in tidy format. Every dataset has a time and a
geography dimension plus one or more topic dimensions. A dataset is
published as versions, grouped into editions. A single observation is
addressed by one option code per dimension; one dimension may be a *
wildcard to sweep a whole axis (e.g. a full time series) in one call.
Tools
The tools are designed to be called in sequence, discovery-first:
| Tool | Purpose |
|---|---|
get_timeseries |
Published headline series by URI — prefer for latest rates |
list_datasets |
Page through the catalogue |
search_datasets |
Client-side substring search over title/description/keywords |
get_dataset |
Resolve a dataset's latest edition + version |
get_dimensions |
List a version's variables |
get_options |
List valid option codes for one dimension |
get_observations |
Fetch observation(s); one dimension may be * |
get_metadata |
Provenance and bulk CSV/XLSX download links |
list_releases |
Live release calendar — upcoming/published/cancelled |
get_release |
One release: confirmed vs provisional date, related datasets |
list_topics |
Browse the ONS topic taxonomy (root, or a topic's subtopics) |
get_topic_content |
Publications under a topic; bridges series to get_timeseries |
Typical flow: search_datasets("inflation") → get_dataset("cpih01") →
get_dimensions(...) → get_options(..., "aggregate") →
get_observations(..., {"time": "*", "geography": "K02000001", "aggregate": "CP00"}).
Geography uses ONS codes, e.g. K02000001 = United Kingdom.
Discovery: releases and topics
Release calendar. list_releases(status="upcoming") is the
authoritative schedule of ONS publications — use it for "when is the next
X out", not the next_release field on get_timeseries/get_dataset,
which is a snapshot from the last publication and can be stale (it reported
15 July when the calendar said 22 July). get_release(uri) gives one
entry's confirmed-or-provisional date, any cancellation notice, and the
datasets it will contain.
Topics. list_topics() returns the top-level taxonomy; pass a topic id
(list_topics(parent_id="1245")) to drill into subtopics.
get_topic_content(topic_id) lists the bulletins, articles and key series
under a topic — and fills in timeseries_uri on series items so you can
hand them straight to get_timeseries.
Nomis tools
| Tool | Purpose |
|---|---|
nomis_search_datasets |
Keyword search over the Nomis catalogue |
nomis_get_dataset |
Dataset overview + dimensions (with conceptrefs) |
nomis_dimension_options |
Valid codes for a dimension (e.g. sex, age, measures) |
nomis_geography_search |
Resolve a place name to Nomis geography code(s) |
nomis_get_data |
Fetch observations (simple flat JSON) |
nomis_data_url |
Build a direct CSV/XLS/JSON bulk-download URL |
Nomis uses internal integer codes, not ONS mnemonics, and they differ
per dataset — always resolve via nomis_dimension_options /
nomis_geography_search first. Data retrieval uses Nomis' simple JSON
format (flat records with named dimensions), avoiding SDMX positional-key
decoding. measures=20100 (value) is usually required.
Typical flow: nomis_search_datasets("claimant") →
nomis_get_dataset("NM_1_1") → nomis_geography_search("NM_1_1", "Birmingham") and nomis_dimension_options("NM_1_1", "sex") →
nomis_get_data("NM_1_1", {"geography": "...", "sex": "5,6,7", "time": "latest", "measures": "20100"}).
Install
python -m venv .venv && . .venv/bin/activate
pip install -e .
Run
Stdio (default, for desktop clients):
ons-mcp
Streamable HTTP (for a self-hosted deployment behind a tunnel), served at
/mcp:
ONS_MCP_HTTP=1 ONS_MCP_PORT=8095 ons-mcp
Bound to 127.0.0.1 by design — front it with Cloudflare Tunnel rather
than exposing the port. In production it runs at
https://ons-mcp.library-apps.dev/mcp, fronted by Cloudflare Access
(Managed OAuth), with the origin re-verifying the Access JWT for defence in
depth. See docs/deploy.md for the systemd unit, tunnel
ingress and auth setup.
Verify
scripts/verify.py exercises both halves — the published-series route
(get_timeseries) and the CMD route (search → observations, with
staleness and the invalid-code diagnosis) — through the real in-memory MCP
dispatch path against the live ONS API, plus the Cloudflare Access guard
wiring:
python scripts/verify.py
Client config (stdio)
{
"mcpServers": {
"ons-beta": {
"command": "ons-mcp"
}
}
}
Environment
| Variable | Default | Meaning |
|---|---|---|
ONS_API_BASE |
https://api.beta.ons.gov.uk/v1 |
API root |
ONS_API_TIMEOUT |
30 |
Per-request timeout (s) |
ONS_MCP_HTTP |
unset | Set to 1 for HTTP transport (serves /mcp) |
ONS_MCP_PORT |
8095 |
HTTP port (bound to 127.0.0.1) |
ONS_MCP_ALLOWED_HOSTS |
ons-mcp.library-apps.dev,127.0.0.1,localhost |
DNS-rebinding Host allowlist |
CF_ACCESS_TEAM_DOMAIN |
unset | Cloudflare Access team domain; enables origin-side JWT checks (with CF_ACCESS_AUD) |
CF_ACCESS_AUD |
unset | Access application AUD; both must be set to enforce auth |
NOMIS_API_BASE |
https://www.nomisweb.co.uk/api/v01 |
Nomis API root |
NOMIS_API_KEY |
unset | Optional Nomis uid for larger queries |
NOMIS_API_TIMEOUT |
60 |
Nomis per-request timeout (s) |
Notes
The beta API has no server-side text search, so search_datasets pages
the catalogue and filters locally. It's fine for a few hundred datasets
but does one request per 100 items; cache the result if you call it often.
The ONS beta tools are verified end-to-end against the live API by
scripts/verify.py (see Verify above). The Nomis tools were built
against the documented SDMX-JSON structure and unit-tested for parsing, but
not smoke-tested against the live Nomis service — validate the first few
nomis_* calls in your environment.
Licence: the code is MIT — see LICENSE. The data it serves contains public sector information licensed under the Open Government Licence v3.0.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。