@statsmcp/ssb 0.0.0-stage → 0.3.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 +66 -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-uKKCgtKQ.mjs +60 -0
- package/package.json +55 -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,67 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @statsmcp/ssb
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
An MCP server for [Statbank Norway](https://www.ssb.no/en/statbank), the database of Statistics Norway (SSB). It gives AI assistants access to Statbank tables in Norwegian and English.
|
|
4
|
+
|
|
5
|
+
> This project is not affiliated with or endorsed by Statistics Norway.
|
|
6
|
+
|
|
7
|
+
## Use the server
|
|
8
|
+
|
|
9
|
+
### Hosted
|
|
10
|
+
|
|
11
|
+
Add `https://statsmcp.dev/no/mcp` as a remote MCP server. It uses Streamable HTTP and needs no authentication. For the steps for each client, refer to [statsmcp.dev/norway](https://statsmcp.dev/norway/).
|
|
12
|
+
|
|
13
|
+
### Local
|
|
14
|
+
|
|
15
|
+
You need Node.js 20 or later.
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"mcpServers": {
|
|
20
|
+
"ssb": { "command": "npx", "args": ["-y", "@statsmcp/ssb"] }
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
For Claude Code:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
claude mcp add ssb -- npx -y @statsmcp/ssb
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Tools
|
|
32
|
+
|
|
33
|
+
| Tool | What it does |
|
|
34
|
+
| -------------------- | ------------------------------------------------------------------------------------------------ |
|
|
35
|
+
| `search_tables` | Finds tables by keywords in their titles. Returns table numbers, titles and publication dates. |
|
|
36
|
+
| `get_table_metadata` | Lists the variables of a table and their value codes. Use `valueFilter` to find a value by name. |
|
|
37
|
+
| `query_table` | Returns data as CSV with readable labels. Use `latest` for recent periods. |
|
|
38
|
+
|
|
39
|
+
All tools are read-only. Each tool accepts `lang` (`no` or `en`).
|
|
40
|
+
|
|
41
|
+
SSB allows about 40 API calls per minute. The server keeps results in a cache to use fewer calls.
|
|
42
|
+
|
|
43
|
+
## Use it in your own server
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
npm install @statsmcp/ssb
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import { StdioServerTransport } from '@modelcontextprotocol/server/stdio';
|
|
51
|
+
import { createSsbServer } from '@statsmcp/ssb';
|
|
52
|
+
|
|
53
|
+
const server = createSsbServer({ userAgent: 'my-app/1.0' });
|
|
54
|
+
await server.connect(new StdioServerTransport());
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
`createSsbServer` returns an `McpServer`. It also accepts a `cache`. To make one, install `@statsmcp/core` and use `createMemoryCache`, or implement the `Cache` interface.
|
|
58
|
+
|
|
59
|
+
## Data licence and attribution
|
|
60
|
+
|
|
61
|
+
SSB data is under the [Creative Commons Attribution 4.0 licence (CC BY 4.0)](https://www.ssb.no/en/diverse/lisens). You can use it for any purpose, including commercial use, if you name Statistics Norway (SSB) as the source.
|
|
62
|
+
|
|
63
|
+
Each result contains the source line with the licence link, and a link to the table on ssb.no. If you change the data or calculate new figures, you must say so, for example: `Source: Statistics Norway (SSB) / Calculated by <you>`.
|
|
64
|
+
|
|
65
|
+
## Licence
|
|
66
|
+
|
|
67
|
+
The code is under the MIT licence. The data belongs to Statistics Norway.
|
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 ssbPreset: PxwebPreset;
|
|
4
|
+
export type SsbServerOptions = Pick<PresetServerOptions, 'cache' | 'userAgent'>;
|
|
5
|
+
export declare function createSsbServer(options?: SsbServerOptions): McpServer;
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as createSsbServer, n as ssbPreset } from "./src-uKKCgtKQ.mjs";
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { createPresetServer } from "@statsmcp/core";
|
|
2
|
+
// src/preset.ts
|
|
3
|
+
const TABLE_NUMBER = /^(\d{5}):/;
|
|
4
|
+
const ATTRIBUTION = {
|
|
5
|
+
no: "Kilde: Statistisk sentralbyrå (SSB), CC BY 4.0 (https://www.ssb.no/diverse/lisens)",
|
|
6
|
+
en: "Source: Statistics Norway (SSB), CC BY 4.0 (https://www.ssb.no/en/diverse/lisens)"
|
|
7
|
+
};
|
|
8
|
+
const ssbPreset = {
|
|
9
|
+
name: "ssb",
|
|
10
|
+
title: "Statbank Norway (Statistics Norway official statistics)",
|
|
11
|
+
version: "0.3.0",
|
|
12
|
+
apiBaseUrl: "https://data.ssb.no/api/v0",
|
|
13
|
+
database: "table",
|
|
14
|
+
languages: ["no", "en"],
|
|
15
|
+
attribution: (lang) => lang === "no" ? ATTRIBUTION.no : ATTRIBUTION.en,
|
|
16
|
+
tableUrl: (lang, tableId) => {
|
|
17
|
+
const prefix = lang === "no" ? "" : "en/";
|
|
18
|
+
const number = tableId.split("/").at(-1) ?? "";
|
|
19
|
+
if (!/^\d{5}$/.test(number)) return `https://www.ssb.no/${prefix}statbank`;
|
|
20
|
+
return `https://www.ssb.no/${prefix}statbank/table/${number}`;
|
|
21
|
+
},
|
|
22
|
+
tableIdFromHit: (hit) => TABLE_NUMBER.exec(hit.title)?.[1] ?? "",
|
|
23
|
+
instructions: `Official statistics for Norway from Statbank, the database of Statistics Norway (SSB). This server is not affiliated with or endorsed by SSB.
|
|
24
|
+
|
|
25
|
+
To answer a question with data:
|
|
26
|
+
1. Call \`search_tables\` with short topic keywords. Norwegian titles ("no") are the most complete; try "en" if the user writes in English, and try the other language when results are poor. Table ids are five-digit table numbers.
|
|
27
|
+
2. Call \`get_table_metadata\` on the best table to see its variables and value codes. Use \`valueFilter\` to find a municipality, county or industry by name.
|
|
28
|
+
3. Call \`query_table\` with only the values you need. Use \`latest\` for recent periods.
|
|
29
|
+
|
|
30
|
+
SSB allows about 40 API calls per minute, so avoid unnecessary calls. Always cite the source line that each result ends with. If you calculate new figures from the data, say they are your own calculation based on SSB data.`,
|
|
31
|
+
maxCells: 5e3,
|
|
32
|
+
searchLimit: 10,
|
|
33
|
+
searchAliases: {
|
|
34
|
+
en: [{
|
|
35
|
+
terms: [
|
|
36
|
+
"salary",
|
|
37
|
+
"salaries",
|
|
38
|
+
"wage"
|
|
39
|
+
],
|
|
40
|
+
query: "earnings"
|
|
41
|
+
}, {
|
|
42
|
+
terms: [
|
|
43
|
+
"housing price",
|
|
44
|
+
"house price",
|
|
45
|
+
"home price",
|
|
46
|
+
"property price"
|
|
47
|
+
],
|
|
48
|
+
query: "price for existing dwellings"
|
|
49
|
+
}],
|
|
50
|
+
no: [{
|
|
51
|
+
terms: ["boligpris", "huspris"],
|
|
52
|
+
query: "prisindeks for brukte boliger"
|
|
53
|
+
}]
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
// src/index.ts
|
|
57
|
+
function createSsbServer(options = {}) {
|
|
58
|
+
return createPresetServer(ssbPreset, options);
|
|
59
|
+
}
|
|
60
|
+
export { ssbPreset as n, createSsbServer as t };
|
package/package.json
CHANGED
|
@@ -1,6 +1,58 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@statsmcp/ssb",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "MCP server for Statbank Norway, the database of Statistics Norway (SSB)",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Tadej Polajnar",
|
|
7
|
+
"homepage": "https://statsmcp.dev/norway/",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/Stats-MCP/statsmcp.git",
|
|
11
|
+
"directory": "packages/ssb"
|
|
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
|
+
"ssb",
|
|
23
|
+
"statbank",
|
|
24
|
+
"norway",
|
|
25
|
+
"statistics",
|
|
26
|
+
"pxweb"
|
|
27
|
+
],
|
|
28
|
+
"bin": {
|
|
29
|
+
"ssb-mcp": "./dist/bin.mjs"
|
|
30
|
+
},
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/index.d.mts",
|
|
34
|
+
"default": "./dist/index.mjs"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"dist"
|
|
39
|
+
],
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@modelcontextprotocol/server": "^2.4.0",
|
|
45
|
+
"@statsmcp/core": "0.3.0"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@types/node": "26.6.5",
|
|
49
|
+
"tsdown": "0.23.2",
|
|
50
|
+
"typescript": "7.0.2",
|
|
51
|
+
"vitest": "5.0.5"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "tsdown",
|
|
55
|
+
"typecheck": "tsc --noEmit",
|
|
56
|
+
"test": "vitest run"
|
|
57
|
+
}
|
|
6
58
|
}
|