@statsmcp/ons 0.0.0-stage → 0.6.0
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 +21 -0
- package/README.md +64 -2
- package/dist/bin.d.mts +1 -0
- package/dist/bin.mjs +6 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.mjs +1 -0
- package/dist/src-YJK0FD8B.mjs +54 -0
- package/package.json +54 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Tadej Polajnar
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,65 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @statsmcp/ons
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
An MCP server for the [time series](https://www.ons.gov.uk/timeseriestool) of the Office for National Statistics (ONS), the national statistics office of the United Kingdom. It gives AI assistants access to more than 13,000 time series in English.
|
|
4
|
+
|
|
5
|
+
> This project is not affiliated with or endorsed by the Office for National Statistics.
|
|
6
|
+
|
|
7
|
+
## Use the server
|
|
8
|
+
|
|
9
|
+
### Hosted
|
|
10
|
+
|
|
11
|
+
Add `https://statsmcp.dev/gb/mcp` as a remote MCP server. It uses Streamable HTTP and needs no authentication. For the steps for each client, refer to [statsmcp.dev/united-kingdom](https://statsmcp.dev/united-kingdom/).
|
|
12
|
+
|
|
13
|
+
### Local
|
|
14
|
+
|
|
15
|
+
You need Node.js 20 or later.
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"mcpServers": {
|
|
20
|
+
"ons": { "command": "npx", "args": ["-y", "@statsmcp/ons"] }
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
For Claude Code:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
claude mcp add ons -- npx -y @statsmcp/ons
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Tools
|
|
32
|
+
|
|
33
|
+
| Tool | What it does |
|
|
34
|
+
| -------------------- | -------------------------------------------------------------------------- |
|
|
35
|
+
| `search_tables` | Finds time series by keywords or by series code (CDID). |
|
|
36
|
+
| `get_table_metadata` | Lists the frequencies and periods of a series. |
|
|
37
|
+
| `query_table` | Returns data as CSV with readable labels. Use `latest` for recent periods. |
|
|
38
|
+
|
|
39
|
+
All tools are read-only.
|
|
40
|
+
|
|
41
|
+
## Use it in your own server
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
npm install @statsmcp/ons
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { StdioServerTransport } from '@modelcontextprotocol/server/stdio';
|
|
49
|
+
import { createOnsServer } from '@statsmcp/ons';
|
|
50
|
+
|
|
51
|
+
const server = createOnsServer({ userAgent: 'my-app/1.0' });
|
|
52
|
+
await server.connect(new StdioServerTransport());
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
`createOnsServer` returns an `McpServer`. It also accepts a `cache`.
|
|
56
|
+
|
|
57
|
+
## Data licence and attribution
|
|
58
|
+
|
|
59
|
+
The ONS publishes its statistics under the [Open Government Licence v3.0](https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/). You can reuse them freely, also commercially, with this source statement: `Source: Office for National Statistics licensed under the Open Government Licence v.3.0`.
|
|
60
|
+
|
|
61
|
+
Each result contains the source line and a link to the series page.
|
|
62
|
+
|
|
63
|
+
## Licence
|
|
64
|
+
|
|
65
|
+
The code is under the MIT licence. The data belongs to the Office for National Statistics.
|
package/dist/bin.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/dist/bin.mjs
ADDED
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { PresetServerOptions, PxwebPreset } from "@statsmcp/core";
|
|
2
|
+
import { McpServer } from "@modelcontextprotocol/server";
|
|
3
|
+
export declare const onsPreset: PxwebPreset;
|
|
4
|
+
export type OnsServerOptions = Pick<PresetServerOptions, 'cache' | 'userAgent'>;
|
|
5
|
+
export declare function createOnsServer(options?: OnsServerOptions): McpServer;
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as createOnsServer, n as onsPreset } from "./src-YJK0FD8B.mjs";
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { createPresetServer, onsTableUrl } from "@statsmcp/core";
|
|
2
|
+
// src/preset.ts
|
|
3
|
+
const OGL = "https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/";
|
|
4
|
+
const onsPreset = {
|
|
5
|
+
name: "ons",
|
|
6
|
+
title: "ONS time series of the Office for National Statistics (official statistics of the United Kingdom)",
|
|
7
|
+
version: "0.6.0",
|
|
8
|
+
apiBaseUrl: "https://api.beta.ons.gov.uk/v1",
|
|
9
|
+
api: "ons",
|
|
10
|
+
languages: ["en"],
|
|
11
|
+
attribution: () => `Source: Office for National Statistics licensed under the Open Government Licence v.3.0 (${OGL})`,
|
|
12
|
+
tableUrl: (_lang, tableId) => onsTableUrl(tableId),
|
|
13
|
+
instructions: `Official statistics for the United Kingdom from the time series of the Office for National Statistics (ONS). This server is not affiliated with or endorsed by the ONS.
|
|
14
|
+
|
|
15
|
+
To answer a question with data:
|
|
16
|
+
1. Call \`search_tables\` with short topic keywords in English ("en"). Each table is one time series; its id is the dataset and the series code (CDID), for example MM23/D7G7 for the CPI annual rate. A search for a CDID finds that series.
|
|
17
|
+
2. Call \`get_table_metadata\` on the best series to see its frequencies (A, Q, M) and periods. Monthly labour market figures are rolling three-month periods, for example "2026 JUL-SEP".
|
|
18
|
+
3. Call \`query_table\` with one \`frequency\` and \`latest\` on \`period\` for recent periods. Without a frequency, a long series can be too large.
|
|
19
|
+
|
|
20
|
+
The ONS allows about 200 requests per minute. Always cite the source line that each result ends with. If you change the data or calculate new figures, say so.`,
|
|
21
|
+
maxCells: 5e3,
|
|
22
|
+
searchLimit: 10,
|
|
23
|
+
searchAliases: { en: [
|
|
24
|
+
{
|
|
25
|
+
terms: [
|
|
26
|
+
"inflation",
|
|
27
|
+
"consumer prices",
|
|
28
|
+
"cpi"
|
|
29
|
+
],
|
|
30
|
+
query: "D7G7"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
terms: ["cpih"],
|
|
34
|
+
query: "L55O"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
terms: ["unemployment", "jobless"],
|
|
38
|
+
query: "MGSX"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
terms: ["gdp", "gross domestic product"],
|
|
42
|
+
query: "ABMI"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
terms: ["population"],
|
|
46
|
+
query: "UKPOP"
|
|
47
|
+
}
|
|
48
|
+
] }
|
|
49
|
+
};
|
|
50
|
+
// src/index.ts
|
|
51
|
+
function createOnsServer(options = {}) {
|
|
52
|
+
return createPresetServer(onsPreset, options);
|
|
53
|
+
}
|
|
54
|
+
export { onsPreset as n, createOnsServer as t };
|
package/package.json
CHANGED
|
@@ -1,6 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@statsmcp/ons",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"description": "MCP server for the time series of the Office for National Statistics (United Kingdom)",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Tadej Polajnar",
|
|
7
|
+
"homepage": "https://statsmcp.dev/united-kingdom/",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/Stats-MCP/statsmcp.git",
|
|
11
|
+
"directory": "packages/ons"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/Stats-MCP/statsmcp/issues"
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=20"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"mcp",
|
|
22
|
+
"ons",
|
|
23
|
+
"office-for-national-statistics",
|
|
24
|
+
"united-kingdom",
|
|
25
|
+
"statistics"
|
|
26
|
+
],
|
|
27
|
+
"bin": {
|
|
28
|
+
"ons-mcp": "./dist/bin.mjs"
|
|
29
|
+
},
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"types": "./dist/index.d.mts",
|
|
33
|
+
"default": "./dist/index.mjs"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist"
|
|
38
|
+
],
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@modelcontextprotocol/server": "^2.4.0",
|
|
44
|
+
"@statsmcp/core": "0.6.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/node": "26.6.6",
|
|
48
|
+
"tsdown": "0.23.4",
|
|
49
|
+
"typescript": "7.0.2",
|
|
50
|
+
"vitest": "5.0.5"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "tsdown",
|
|
54
|
+
"typecheck": "tsc --noEmit",
|
|
55
|
+
"test": "vitest run"
|
|
56
|
+
}
|
|
6
57
|
}
|