@pipeworx/mcp-cbs-il 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 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,55 @@
1
+ # mcp-cbs-il
2
+
3
+ Israel Central Bureau of Statistics (CBS / הלשכה המרכזית לסטטיסטיקה) MCP.
4
+
5
+ Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 697+ live data sources.
6
+
7
+ ## Tools
8
+
9
+ | Tool | Description |
10
+ |------|-------------|
11
+
12
+ ## Quick Start
13
+
14
+ Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):
15
+
16
+ ```json
17
+ {
18
+ "mcpServers": {
19
+ "cbs-il": {
20
+ "url": "https://gateway.pipeworx.io/cbs-il/mcp"
21
+ }
22
+ }
23
+ }
24
+ ```
25
+
26
+ Or connect to the full Pipeworx gateway for access to all 697+ data sources:
27
+
28
+ ```json
29
+ {
30
+ "mcpServers": {
31
+ "pipeworx": {
32
+ "url": "https://gateway.pipeworx.io/mcp"
33
+ }
34
+ }
35
+ }
36
+ ```
37
+
38
+ ## Using with ask_pipeworx
39
+
40
+ Instead of calling tools directly, you can ask questions in plain English:
41
+
42
+ ```
43
+ ask_pipeworx({ question: "your question about Cbs Il data" })
44
+ ```
45
+
46
+ The gateway picks the right tool and fills the arguments automatically.
47
+
48
+ ## More
49
+
50
+ - [All tools and guides](https://github.com/pipeworx-io/examples)
51
+ - [pipeworx.io](https://pipeworx.io)
52
+
53
+ ## License
54
+
55
+ MIT
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@pipeworx/mcp-cbs-il",
3
+ "version": "0.1.0",
4
+ "description": "Israel Central Bureau of Statistics (CBS / הלשכה המרכזית לסטטיסטיקה) MCP.",
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+ "types": "src/index.ts",
8
+ "keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "cbs-il"],
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/pipeworx-io/mcp-cbs-il"
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-il",
4
+ "title": "Cbs Il",
5
+ "description": "Israel Central Bureau of Statistics (CBS / הלשכה המרכזית לסטטיסטיקה) MCP.",
6
+ "version": "0.1.0",
7
+ "websiteUrl": "https://pipeworx.io/packs/cbs-il",
8
+ "repository": {
9
+ "url": "https://github.com/pipeworx-io/mcp-cbs-il",
10
+ "source": "github"
11
+ },
12
+ "remotes": [
13
+ {
14
+ "type": "streamable-http",
15
+ "url": "https://gateway.pipeworx.io/cbs-il/mcp"
16
+ }
17
+ ]
18
+ }
package/src/index.ts ADDED
@@ -0,0 +1,166 @@
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
+ * Israel Central Bureau of Statistics (CBS / הלשכה המרכזית לסטטיסטיקה) MCP.
21
+ *
22
+ * Keyless public API at https://apis.cbs.gov.il covering Israeli economic,
23
+ * demographic and price statistics. Two data families:
24
+ *
25
+ * /series — a hierarchical catalog of numbered time-series. Navigate the
26
+ * tree by subject id, then fetch a leaf series' actual observations by
27
+ * its numeric series id.
28
+ * /index — the official price indices (CPI, etc.), with their own
29
+ * catalog tree and a dedicated monthly price-data endpoint.
30
+ *
31
+ * The catalog is hierarchical: top-level subjects come from
32
+ * `catalog_browse` (no id), and `catalog_search` returns the deep leaf
33
+ * "paths" (breadcrumb arrays) under a subject. Series content is bilingual:
34
+ * pass lang="en" (default here) for English, "he" for Hebrew.
35
+ */
36
+
37
+
38
+ const BASE = 'https://apis.cbs.gov.il';
39
+ const UA = 'pipeworx-mcp-cbs-il/1.0 (+https://pipeworx.io)';
40
+
41
+ const tools: McpToolExport['tools'] = [
42
+ {
43
+ name: 'catalog_browse',
44
+ description:
45
+ "Browse the CBS time-series catalog. With no subject_id, returns the top-level subjects (Foreign Trade, Population, Balance of Payments, Consumer Price Index, etc.) — each with a numeric path id. Pass that id back as subject_id to drill into a subject's full set of leaf series paths. The catalog is hierarchical; each catalog entry has a 'path' breadcrumb array and a 'name'. Use this to discover what's available before calling get_series_data.",
46
+ inputSchema: {
47
+ type: 'object',
48
+ properties: {
49
+ subject_id: {
50
+ type: 'integer',
51
+ description:
52
+ 'Top-level subject id (from a no-arg call, e.g. 8 = Foreign Trade, 2 = Population). Omit to list the top-level subjects.',
53
+ },
54
+ page: { type: 'integer', description: 'Page number for paginated leaf lists (default 1, page size 100).' },
55
+ lang: { type: 'string', enum: ['en', 'he'], description: 'Content language. Default "en".' },
56
+ },
57
+ },
58
+ },
59
+ {
60
+ name: 'get_series_data',
61
+ description:
62
+ 'Fetch the actual time-series observations for a CBS series by its numeric series id (the leaf id found via catalog_browse). Returns metadata (subject path, unit, prices, last update) plus an array of observations with TimePeriod (e.g. "2026-04") and Value. Covers Israeli economic and demographic statistics. Optionally filter by start_period / end_period (YYYY-MM or YYYY).',
63
+ inputSchema: {
64
+ type: 'object',
65
+ properties: {
66
+ series_id: { type: 'integer', description: 'Numeric series id, e.g. 1 (foreign-trade deficit).' },
67
+ start_period: { type: 'string', description: 'Earliest period, e.g. "2025-01" or "2024".' },
68
+ end_period: { type: 'string', description: 'Latest period, e.g. "2026-06".' },
69
+ lang: { type: 'string', enum: ['en', 'he'], description: 'Content language. Default "en".' },
70
+ },
71
+ required: ['series_id'],
72
+ },
73
+ },
74
+ {
75
+ name: 'index_catalog',
76
+ description:
77
+ 'List the official CBS price-index catalog tree: chapters (Consumer Price Index, Wholesale Price Index, Housing Price Index, etc.) and their codes. Each code has a numeric codeId used by get_index_data. Use this to find the index code you want (e.g. 120010 = Consumer Price Index - General).',
78
+ inputSchema: {
79
+ type: 'object',
80
+ properties: {
81
+ lang: { type: 'string', enum: ['en', 'he'], description: 'Content language. Default "en".' },
82
+ },
83
+ },
84
+ },
85
+ {
86
+ name: 'get_index_data',
87
+ description:
88
+ 'Fetch monthly values for a CBS price index by its numeric code (from index_catalog, e.g. 120010 = CPI General). Returns per-month entries with the index value, the monthly percent change (percent) and the year-over-year change (percentYear) — i.e. Israeli inflation. Optionally filter by start_period / end_period (YYYY-MM or YYYY).',
89
+ inputSchema: {
90
+ type: 'object',
91
+ properties: {
92
+ code: { type: 'integer', description: 'Index code, e.g. 120010 (Consumer Price Index - General).' },
93
+ start_period: { type: 'string', description: 'Earliest period, e.g. "2025-01".' },
94
+ end_period: { type: 'string', description: 'Latest period, e.g. "2026-06".' },
95
+ lang: { type: 'string', enum: ['en', 'he'], description: 'Content language. Default "en".' },
96
+ },
97
+ required: ['code'],
98
+ },
99
+ },
100
+ ];
101
+
102
+ async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
103
+ const lang = (args.lang as string | undefined) === 'he' ? 'he' : 'en';
104
+
105
+ switch (name) {
106
+ case 'catalog_browse': {
107
+ const params = new URLSearchParams({ format: 'json', download: 'false', lang });
108
+ const subjectId = args.subject_id;
109
+ if (subjectId === undefined || subjectId === null) {
110
+ // Top-level subjects. id=1 is the special root that lists every subject.
111
+ params.set('id', '1');
112
+ return cbsGet(`/series/catalog/level?${params.toString()}`);
113
+ }
114
+ if (typeof subjectId !== 'number' || !Number.isInteger(subjectId)) {
115
+ throw new Error('Argument "subject_id" must be an integer subject id (from a no-arg catalog_browse call).');
116
+ }
117
+ params.set('id', String(subjectId));
118
+ if (args.page !== undefined) params.set('Page', String(args.page));
119
+ // Leaf paths under a subject live under /catalog/path (paginated, 100/page).
120
+ return cbsGet(`/series/catalog/path?${params.toString()}`);
121
+ }
122
+
123
+ case 'get_series_data': {
124
+ const seriesId = args.series_id;
125
+ if (typeof seriesId !== 'number' || !Number.isInteger(seriesId)) {
126
+ throw new Error('Required argument "series_id" must be an integer, e.g. 1. Find ids via catalog_browse.');
127
+ }
128
+ const params = new URLSearchParams({ id: String(seriesId), format: 'json', download: 'false', lang });
129
+ if (typeof args.start_period === 'string' && args.start_period.trim()) params.set('startPeriod', args.start_period.trim());
130
+ if (typeof args.end_period === 'string' && args.end_period.trim()) params.set('endPeriod', args.end_period.trim());
131
+ return cbsGet(`/series/data/list?${params.toString()}`);
132
+ }
133
+
134
+ case 'index_catalog': {
135
+ const params = new URLSearchParams({ format: 'json', download: 'false', lang });
136
+ return cbsGet(`/index/catalog/tree?${params.toString()}`);
137
+ }
138
+
139
+ case 'get_index_data': {
140
+ const code = args.code;
141
+ if (typeof code !== 'number' || !Number.isInteger(code)) {
142
+ throw new Error('Required argument "code" must be an integer index code, e.g. 120010. Find codes via index_catalog.');
143
+ }
144
+ const params = new URLSearchParams({ id: String(code), format: 'json', download: 'false', lang });
145
+ if (typeof args.start_period === 'string' && args.start_period.trim()) params.set('startPeriod', args.start_period.trim());
146
+ if (typeof args.end_period === 'string' && args.end_period.trim()) params.set('endPeriod', args.end_period.trim());
147
+ return cbsGet(`/index/data/price?${params.toString()}`);
148
+ }
149
+
150
+ default:
151
+ throw new Error(`Unknown tool: ${name}`);
152
+ }
153
+ }
154
+
155
+ async function cbsGet(path: string): Promise<unknown> {
156
+ const res = await fetch(`${BASE}${path}`, {
157
+ headers: { Accept: 'application/json', 'User-Agent': UA },
158
+ });
159
+ if (!res.ok) {
160
+ const body = await res.text().catch(() => '');
161
+ throw new Error(`CBS Israel: ${res.status} ${body.slice(0, 200)}`);
162
+ }
163
+ return res.json();
164
+ }
165
+
166
+ 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
+ }