@pipeworx/mcp-ecb 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 +237 -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-ecb
|
|
2
|
+
|
|
3
|
+
ECB Data Portal MCP — European Central Bank statistical data
|
|
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
|
+
| `list_dataflows` | List ECB SDMX data flows. Optional substring filter on flow ref or name. |
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"mcpServers": {
|
|
20
|
+
"ecb": {
|
|
21
|
+
"url": "https://gateway.pipeworx.io/ecb/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 Ecb 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-ecb",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "ECB Data Portal MCP — European Central Bank statistical data",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"types": "src/index.ts",
|
|
8
|
+
"keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "ecb"],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/pipeworx-io/mcp-ecb"
|
|
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/ecb",
|
|
4
|
+
"title": "Ecb",
|
|
5
|
+
"description": "ECB Data Portal MCP — European Central Bank statistical data",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"websiteUrl": "https://pipeworx.io/packs/ecb",
|
|
8
|
+
"repository": {
|
|
9
|
+
"url": "https://github.com/pipeworx-io/mcp-ecb",
|
|
10
|
+
"source": "github"
|
|
11
|
+
},
|
|
12
|
+
"remotes": [
|
|
13
|
+
{
|
|
14
|
+
"type": "streamable-http",
|
|
15
|
+
"url": "https://gateway.pipeworx.io/ecb/mcp"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
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
|
+
* ECB Data Portal MCP — European Central Bank statistical data
|
|
21
|
+
*
|
|
22
|
+
* The ECB exposes SDMX 2.1 REST endpoints. Default format is XML; we ask for
|
|
23
|
+
* SDMX-JSON via `?format=jsondata`.
|
|
24
|
+
*
|
|
25
|
+
* Auth: none.
|
|
26
|
+
* API docs: https://data.ecb.europa.eu/help/api/
|
|
27
|
+
*
|
|
28
|
+
* Tools:
|
|
29
|
+
* - exchange_rate: EUR → currency rate (convenience over EXR flow)
|
|
30
|
+
* - hicp_inflation: Harmonised CPI YoY change (convenience over ICP flow)
|
|
31
|
+
* - get_data: generic SDMX query against any flow
|
|
32
|
+
* - list_dataflows: enumerate flow refs in the ECB catalogue
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
const BASE = 'https://data-api.ecb.europa.eu/service';
|
|
37
|
+
|
|
38
|
+
const tools: McpToolExport['tools'] = [
|
|
39
|
+
{
|
|
40
|
+
name: 'exchange_rate',
|
|
41
|
+
description:
|
|
42
|
+
'Daily EUR exchange rate against a currency. Returns time series of observations. Currency is the ISO 4217 code (e.g. "USD", "GBP", "JPY", "CHF").',
|
|
43
|
+
inputSchema: {
|
|
44
|
+
type: 'object',
|
|
45
|
+
properties: {
|
|
46
|
+
currency: { type: 'string', description: 'ISO 4217 currency code (USD, GBP, JPY, ...)' },
|
|
47
|
+
start_period: { type: 'string', description: 'Start date (YYYY-MM-DD)' },
|
|
48
|
+
end_period: { type: 'string', description: 'End date (YYYY-MM-DD)' },
|
|
49
|
+
frequency: {
|
|
50
|
+
type: 'string',
|
|
51
|
+
description: 'Observation frequency — D (daily), M (monthly), Q (quarterly), A (annual). Default D.',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
required: ['currency'],
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: 'hicp_inflation',
|
|
59
|
+
description:
|
|
60
|
+
'Harmonised Index of Consumer Prices (HICP) annual rate of change for a country / euro area. Monthly frequency. country defaults to U2 (euro area).',
|
|
61
|
+
inputSchema: {
|
|
62
|
+
type: 'object',
|
|
63
|
+
properties: {
|
|
64
|
+
country: {
|
|
65
|
+
type: 'string',
|
|
66
|
+
description: 'Reference area — U2 (euro area, default), DE, FR, IT, ES, NL, BE, etc.',
|
|
67
|
+
},
|
|
68
|
+
start_period: { type: 'string', description: 'Start date (YYYY or YYYY-MM)' },
|
|
69
|
+
end_period: { type: 'string', description: 'End date (YYYY or YYYY-MM)' },
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: 'get_data',
|
|
75
|
+
description:
|
|
76
|
+
'Generic SDMX data fetch from any ECB flow. Key is dot-separated dimension values; empty positions are wildcards. Example: flow_ref="EXR", key="D.USD.EUR.SP00.A" (daily USD/EUR spot).',
|
|
77
|
+
inputSchema: {
|
|
78
|
+
type: 'object',
|
|
79
|
+
properties: {
|
|
80
|
+
flow_ref: {
|
|
81
|
+
type: 'string',
|
|
82
|
+
description: 'Flow reference — EXR (exchange rates), ICP (HICP), BSI, IRS, STS, BLS, MIR, ...',
|
|
83
|
+
},
|
|
84
|
+
key: {
|
|
85
|
+
type: 'string',
|
|
86
|
+
description: 'Series key, dot-separated dimension values',
|
|
87
|
+
},
|
|
88
|
+
start_period: { type: 'string', description: 'Start date / period' },
|
|
89
|
+
end_period: { type: 'string', description: 'End date / period' },
|
|
90
|
+
last_n: { type: 'number', description: 'Return only the last N observations' },
|
|
91
|
+
},
|
|
92
|
+
required: ['flow_ref', 'key'],
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: 'list_dataflows',
|
|
97
|
+
description: 'List ECB SDMX data flows. Optional substring filter on flow ref or name.',
|
|
98
|
+
inputSchema: {
|
|
99
|
+
type: 'object',
|
|
100
|
+
properties: {
|
|
101
|
+
filter: { type: 'string', description: 'Case-insensitive substring filter' },
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
];
|
|
106
|
+
|
|
107
|
+
async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
|
|
108
|
+
switch (name) {
|
|
109
|
+
case 'exchange_rate':
|
|
110
|
+
return exchangeRate(args);
|
|
111
|
+
case 'hicp_inflation':
|
|
112
|
+
return hicpInflation(args);
|
|
113
|
+
case 'get_data':
|
|
114
|
+
return getData(args);
|
|
115
|
+
case 'list_dataflows':
|
|
116
|
+
return listDataflows(args);
|
|
117
|
+
default:
|
|
118
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
async function exchangeRate(args: Record<string, unknown>) {
|
|
123
|
+
const currency = reqStr(args, 'currency', '"USD"').toUpperCase();
|
|
124
|
+
const freq = ((args.frequency as string) ?? 'D').toUpperCase();
|
|
125
|
+
// EXR flow key: FREQ.CURRENCY.CURRENCY_DENOM.EXR_TYPE.EXR_SUFFIX
|
|
126
|
+
const key = `${freq}.${currency}.EUR.SP00.A`;
|
|
127
|
+
return fetchData('EXR', key, {
|
|
128
|
+
start_period: args.start_period as string | undefined,
|
|
129
|
+
end_period: args.end_period as string | undefined,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
async function hicpInflation(args: Record<string, unknown>) {
|
|
134
|
+
const country = ((args.country as string) ?? 'U2').toUpperCase();
|
|
135
|
+
// ICP flow key: FREQ.REF_AREA.ADJUSTMENT.ICP_ITEM.STS_INSTITUTION.ICP_SUFFIX
|
|
136
|
+
// M.U2.N.000000.4.ANR = monthly euro area annual rate of change, all items
|
|
137
|
+
const key = `M.${country}.N.000000.4.ANR`;
|
|
138
|
+
return fetchData('ICP', key, {
|
|
139
|
+
start_period: args.start_period as string | undefined,
|
|
140
|
+
end_period: args.end_period as string | undefined,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
async function getData(args: Record<string, unknown>) {
|
|
145
|
+
return fetchData(reqStr(args, 'flow_ref', '"EXR"'), reqStr(args, 'key', '"D.USD.EUR.SP00.A"'), {
|
|
146
|
+
start_period: args.start_period as string | undefined,
|
|
147
|
+
end_period: args.end_period as string | undefined,
|
|
148
|
+
last_n: args.last_n as number | undefined,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
async function fetchData(
|
|
153
|
+
flow: string,
|
|
154
|
+
key: string,
|
|
155
|
+
opts: { start_period?: string; end_period?: string; last_n?: number },
|
|
156
|
+
) {
|
|
157
|
+
const params = new URLSearchParams({ format: 'jsondata' });
|
|
158
|
+
if (opts.start_period) params.set('startPeriod', opts.start_period);
|
|
159
|
+
if (opts.end_period) params.set('endPeriod', opts.end_period);
|
|
160
|
+
if (opts.last_n) params.set('lastNObservations', String(opts.last_n));
|
|
161
|
+
const url = `${BASE}/data/${encodeURIComponent(flow)}/${encodeURIComponent(key)}?${params}`;
|
|
162
|
+
const res = await fetch(url, { headers: { Accept: 'application/json' } });
|
|
163
|
+
if (res.status === 404) throw new Error(`ECB: no data for flow=${flow} key=${key}`);
|
|
164
|
+
if (!res.ok) {
|
|
165
|
+
const body = await res.text();
|
|
166
|
+
throw new Error(`ECB error: ${res.status} ${body.slice(0, 200)}`);
|
|
167
|
+
}
|
|
168
|
+
const data = (await res.json()) as SdmxData;
|
|
169
|
+
return normalizeSdmx(flow, key, data);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
interface SdmxData {
|
|
173
|
+
dataSets?: {
|
|
174
|
+
series?: Record<string, { observations?: Record<string, [number | null, ...unknown[]]> }>;
|
|
175
|
+
}[];
|
|
176
|
+
structure?: {
|
|
177
|
+
dimensions?: {
|
|
178
|
+
series?: { id: string; name?: string; values?: { id: string; name?: string }[] }[];
|
|
179
|
+
observation?: { id: string; name?: string; values?: { id: string; name?: string }[] }[];
|
|
180
|
+
};
|
|
181
|
+
attributes?: {
|
|
182
|
+
series?: { id: string; values?: { id: string; name?: string }[] }[];
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function normalizeSdmx(flow: string, key: string, data: SdmxData) {
|
|
188
|
+
const seriesDims = data.structure?.dimensions?.series ?? [];
|
|
189
|
+
const obsDims = data.structure?.dimensions?.observation ?? [];
|
|
190
|
+
const series = data.dataSets?.[0]?.series ?? {};
|
|
191
|
+
const out: { series_key: string; dimensions: Record<string, string>; observations: { period: string; value: number | null }[] }[] = [];
|
|
192
|
+
for (const [skey, sval] of Object.entries(series)) {
|
|
193
|
+
const idx = skey.split(':').map(Number);
|
|
194
|
+
const dims: Record<string, string> = {};
|
|
195
|
+
seriesDims.forEach((d, i) => {
|
|
196
|
+
const v = d.values?.[idx[i]];
|
|
197
|
+
if (v) dims[d.id] = v.name ?? v.id;
|
|
198
|
+
});
|
|
199
|
+
const obs: { period: string; value: number | null }[] = [];
|
|
200
|
+
for (const [oidx, ovals] of Object.entries(sval.observations ?? {})) {
|
|
201
|
+
const period = obsDims[0]?.values?.[Number(oidx)]?.id ?? oidx;
|
|
202
|
+
obs.push({ period, value: ovals[0] ?? null });
|
|
203
|
+
}
|
|
204
|
+
obs.sort((a, b) => (a.period < b.period ? -1 : 1));
|
|
205
|
+
out.push({ series_key: skey, dimensions: dims, observations: obs });
|
|
206
|
+
}
|
|
207
|
+
return { flow, key, series_count: out.length, series: out };
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
async function listDataflows(args: Record<string, unknown>) {
|
|
211
|
+
const url = `${BASE}/dataflow/ECB?format=jsondata`;
|
|
212
|
+
const res = await fetch(url, { headers: { Accept: 'application/json' } });
|
|
213
|
+
if (!res.ok) {
|
|
214
|
+
const body = await res.text();
|
|
215
|
+
throw new Error(`ECB error: ${res.status} ${body.slice(0, 200)}`);
|
|
216
|
+
}
|
|
217
|
+
const data = (await res.json()) as { data?: { dataflows?: { id: string; name?: { en?: string } | string }[] } };
|
|
218
|
+
const flows = data.data?.dataflows ?? [];
|
|
219
|
+
const filter = ((args.filter as string) ?? '').toLowerCase();
|
|
220
|
+
const items = flows
|
|
221
|
+
.map((f) => ({
|
|
222
|
+
flow_ref: f.id,
|
|
223
|
+
name: typeof f.name === 'string' ? f.name : (f.name?.en ?? f.id),
|
|
224
|
+
}))
|
|
225
|
+
.filter((f) => !filter || f.flow_ref.toLowerCase().includes(filter) || f.name.toLowerCase().includes(filter));
|
|
226
|
+
return { count: items.length, dataflows: items };
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function reqStr(args: Record<string, unknown>, key: string, example: string): string {
|
|
230
|
+
const v = args[key];
|
|
231
|
+
if (typeof v !== 'string' || !v.trim()) {
|
|
232
|
+
throw new Error(`Required argument "${key}" is missing. Pass a string like ${example}.`);
|
|
233
|
+
}
|
|
234
|
+
return v;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
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
|
+
}
|