@pipeworx/mcp-cbs-nl 0.1.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 +56 -0
- package/package.json +20 -0
- package/server.json +18 -0
- package/src/index.ts +151 -0
- package/tsconfig.json +14 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Pipeworx
|
|
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
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# mcp-cbs-nl
|
|
2
|
+
|
|
3
|
+
Statistics Netherlands (CBS / StatLine) OData MCP.
|
|
4
|
+
|
|
5
|
+
Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 250+ live data sources.
|
|
6
|
+
|
|
7
|
+
## Tools
|
|
8
|
+
|
|
9
|
+
| Tool | Description |
|
|
10
|
+
|------|-------------|
|
|
11
|
+
| `table_info` | Metadata for one table: title, summary, time period covered, frequency, update status and description. Pass a table id like "37296eng". |
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"mcpServers": {
|
|
20
|
+
"cbs-nl": {
|
|
21
|
+
"url": "https://gateway.pipeworx.io/cbs-nl/mcp"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Or connect to the full Pipeworx gateway for access to all 250+ data sources:
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"mcpServers": {
|
|
32
|
+
"pipeworx": {
|
|
33
|
+
"url": "https://gateway.pipeworx.io/mcp"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Using with ask_pipeworx
|
|
40
|
+
|
|
41
|
+
Instead of calling tools directly, you can ask questions in plain English:
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
ask_pipeworx({ question: "your question about Cbs Nl data" })
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
The gateway picks the right tool and fills the arguments automatically.
|
|
48
|
+
|
|
49
|
+
## More
|
|
50
|
+
|
|
51
|
+
- [All tools and guides](https://github.com/pipeworx-io/examples)
|
|
52
|
+
- [pipeworx.io](https://pipeworx.io)
|
|
53
|
+
|
|
54
|
+
## License
|
|
55
|
+
|
|
56
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pipeworx/mcp-cbs-nl",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Statistics Netherlands (CBS / StatLine) OData MCP.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"types": "src/index.ts",
|
|
8
|
+
"keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "cbs-nl"],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/pipeworx-io/mcp-cbs-nl"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"typecheck": "tsc --noEmit"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"typescript": "^5.7.0"
|
|
19
|
+
}
|
|
20
|
+
}
|
package/server.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
|
+
"name": "io.github.pipeworx-io/cbs-nl",
|
|
4
|
+
"title": "Cbs Nl",
|
|
5
|
+
"description": "Statistics Netherlands (CBS / StatLine) OData MCP.",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"websiteUrl": "https://pipeworx.io/packs/cbs-nl",
|
|
8
|
+
"repository": {
|
|
9
|
+
"url": "https://github.com/pipeworx-io/mcp-cbs-nl",
|
|
10
|
+
"source": "github"
|
|
11
|
+
},
|
|
12
|
+
"remotes": [
|
|
13
|
+
{
|
|
14
|
+
"type": "streamable-http",
|
|
15
|
+
"url": "https://gateway.pipeworx.io/cbs-nl/mcp"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
interface McpToolDefinition {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: 'object';
|
|
6
|
+
properties: Record<string, unknown>;
|
|
7
|
+
required?: string[];
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface McpToolExport {
|
|
12
|
+
tools: McpToolDefinition[];
|
|
13
|
+
callTool: (name: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
14
|
+
meter?: { credits: number };
|
|
15
|
+
cost?: Record<string, unknown>;
|
|
16
|
+
provider?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Statistics Netherlands (CBS / StatLine) OData MCP.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
const CATALOG = 'https://opendata.cbs.nl/ODataCatalog/Tables';
|
|
25
|
+
const TABLE = 'https://opendata.cbs.nl/ODataApi/odata';
|
|
26
|
+
const UA = 'pipeworx-mcp-cbs-nl/1.0 (+https://pipeworx.io)';
|
|
27
|
+
|
|
28
|
+
const tools: McpToolExport['tools'] = [
|
|
29
|
+
{
|
|
30
|
+
name: 'search_tables',
|
|
31
|
+
description:
|
|
32
|
+
'Find CBS StatLine datasets by keyword (matched against title). Returns table id, title, period and language. Table ids ending in "eng"/"ENG" have English labels; others are Dutch.',
|
|
33
|
+
inputSchema: {
|
|
34
|
+
type: 'object',
|
|
35
|
+
properties: {
|
|
36
|
+
keyword: { type: 'string', description: 'Search term matched in the table title, e.g. "population", "energy", "wages".' },
|
|
37
|
+
english_only: { type: 'boolean', description: 'If true, only return English-language tables (id ends in "eng"). Default false.' },
|
|
38
|
+
top: { type: 'number', description: 'Max results (default 25).' },
|
|
39
|
+
},
|
|
40
|
+
required: ['keyword'],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'table_info',
|
|
45
|
+
description: 'Metadata for one table: title, summary, time period covered, frequency, update status and description. Pass a table id like "37296eng".',
|
|
46
|
+
inputSchema: {
|
|
47
|
+
type: 'object',
|
|
48
|
+
properties: { table: { type: 'string', description: 'CBS table id, e.g. "37296eng".' } },
|
|
49
|
+
required: ['table'],
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: 'table_dimensions',
|
|
54
|
+
description:
|
|
55
|
+
'Column/dimension definitions for a table (DataProperties): what each field means, its key, type, unit and decimals. Use this before get_data to learn which $select keys and $filter dimensions exist.',
|
|
56
|
+
inputSchema: {
|
|
57
|
+
type: 'object',
|
|
58
|
+
properties: { table: { type: 'string', description: 'CBS table id, e.g. "37296eng".' } },
|
|
59
|
+
required: ['table'],
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: 'dimension_values',
|
|
64
|
+
description:
|
|
65
|
+
'List the valid codes/labels for one dimension of a table (a sub-endpoint such as "Periods" or a region/category dimension key, as named in the table root or table_dimensions).',
|
|
66
|
+
inputSchema: {
|
|
67
|
+
type: 'object',
|
|
68
|
+
properties: {
|
|
69
|
+
table: { type: 'string', description: 'CBS table id, e.g. "37296eng".' },
|
|
70
|
+
dimension: { type: 'string', description: 'Dimension endpoint name, e.g. "Periods", "CaribbeanNetherlands".' },
|
|
71
|
+
top: { type: 'number', description: 'Max rows (default 100).' },
|
|
72
|
+
},
|
|
73
|
+
required: ['table', 'dimension'],
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: 'get_data',
|
|
78
|
+
description:
|
|
79
|
+
'Fetch observations from a table (TypedDataSet). Supports OData v3 query params. Use $select to pick columns (from table_dimensions keys) and $filter to subset, e.g. filter="Periods eq \'2020JJ00\'". Always set a $top to avoid huge responses.',
|
|
80
|
+
inputSchema: {
|
|
81
|
+
type: 'object',
|
|
82
|
+
properties: {
|
|
83
|
+
table: { type: 'string', description: 'CBS table id, e.g. "37296eng".' },
|
|
84
|
+
select: { type: 'string', description: 'OData $select, comma-separated dimension/topic keys, e.g. "Periods,TotalPopulation_1".' },
|
|
85
|
+
filter: { type: 'string', description: "OData $filter, e.g. \"Periods eq '2020JJ00'\" or \"substringof('2020',Periods)\"." },
|
|
86
|
+
top: { type: 'number', description: 'OData $top, max rows to return (default 50).' },
|
|
87
|
+
skip: { type: 'number', description: 'OData $skip, rows to skip for paging.' },
|
|
88
|
+
},
|
|
89
|
+
required: ['table'],
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
];
|
|
93
|
+
|
|
94
|
+
async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
|
|
95
|
+
switch (name) {
|
|
96
|
+
case 'search_tables': {
|
|
97
|
+
const keyword = reqStr(args, 'keyword', '"population"');
|
|
98
|
+
const safe = keyword.toLowerCase().replace(/'/g, "''");
|
|
99
|
+
const filters = [`substringof('${safe}',tolower(Title))`];
|
|
100
|
+
if (args.english_only === true) filters.push("endswith(tolower(Identifier),'eng')");
|
|
101
|
+
const params = new URLSearchParams({
|
|
102
|
+
$format: 'json',
|
|
103
|
+
$select: 'Identifier,Title,ShortDescription,Period,Frequency,Language',
|
|
104
|
+
$filter: filters.join(' and '),
|
|
105
|
+
$top: String(numArg(args.top, 25)),
|
|
106
|
+
});
|
|
107
|
+
return cbsGet(`${CATALOG}?${params.toString()}`);
|
|
108
|
+
}
|
|
109
|
+
case 'table_info':
|
|
110
|
+
return cbsGet(`${TABLE}/${tableId(args)}/TableInfos?$format=json`);
|
|
111
|
+
case 'table_dimensions':
|
|
112
|
+
return cbsGet(`${TABLE}/${tableId(args)}/DataProperties?$format=json`);
|
|
113
|
+
case 'dimension_values': {
|
|
114
|
+
const dim = reqStr(args, 'dimension', '"Periods"').replace(/[^A-Za-z0-9_]/g, '');
|
|
115
|
+
const params = new URLSearchParams({ $format: 'json', $top: String(numArg(args.top, 100)) });
|
|
116
|
+
return cbsGet(`${TABLE}/${tableId(args)}/${dim}?${params.toString()}`);
|
|
117
|
+
}
|
|
118
|
+
case 'get_data': {
|
|
119
|
+
const params = new URLSearchParams({ $format: 'json', $top: String(numArg(args.top, 50)) });
|
|
120
|
+
if (typeof args.select === 'string' && args.select.trim()) params.set('$select', args.select);
|
|
121
|
+
if (typeof args.filter === 'string' && args.filter.trim()) params.set('$filter', args.filter);
|
|
122
|
+
if (args.skip !== undefined) params.set('$skip', String(numArg(args.skip, 0)));
|
|
123
|
+
return cbsGet(`${TABLE}/${tableId(args)}/TypedDataSet?${params.toString()}`);
|
|
124
|
+
}
|
|
125
|
+
default:
|
|
126
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async function cbsGet(url: string): Promise<unknown> {
|
|
131
|
+
const res = await fetch(url, { headers: { Accept: 'application/json', 'User-Agent': UA } });
|
|
132
|
+
if (!res.ok) throw new Error(`CBS: ${res.status} ${await res.text().then((t) => t.slice(0, 200))}`);
|
|
133
|
+
return res.json();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function tableId(args: Record<string, unknown>): string {
|
|
137
|
+
return reqStr(args, 'table', '"37296eng"').trim().replace(/[^A-Za-z0-9_]/g, '');
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function reqStr(args: Record<string, unknown>, key: string, example: string): string {
|
|
141
|
+
const v = args[key];
|
|
142
|
+
if (typeof v !== 'string' || !v.trim()) throw new Error(`Required argument "${key}" is missing. Pass a string like ${example}.`);
|
|
143
|
+
return v;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function numArg(v: unknown, fallback: number): number {
|
|
147
|
+
const n = typeof v === 'number' ? v : Number(v);
|
|
148
|
+
return Number.isFinite(n) && n >= 0 ? Math.floor(n) : fallback;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export default { tools, callTool, meter: { credits: 1 } } satisfies McpToolExport;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"strict": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"outDir": "dist",
|
|
10
|
+
"rootDir": "src",
|
|
11
|
+
"declaration": true
|
|
12
|
+
},
|
|
13
|
+
"include": ["src"]
|
|
14
|
+
}
|