@cyanheads/eurostat-mcp-server 0.3.0 → 0.4.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/CLAUDE.md +1 -1
- package/Dockerfile +16 -3
- package/README.md +27 -6
- package/dist/index.js +23 -2
- package/dist/index.js.map +1 -1
- package/dist/mcp-server/tools/definitions/eurostat-dataframe-describe.tool.d.ts +40 -0
- package/dist/mcp-server/tools/definitions/eurostat-dataframe-describe.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/eurostat-dataframe-describe.tool.js +113 -0
- package/dist/mcp-server/tools/definitions/eurostat-dataframe-describe.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/eurostat-dataframe-query.tool.d.ts +34 -0
- package/dist/mcp-server/tools/definitions/eurostat-dataframe-query.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/eurostat-dataframe-query.tool.js +98 -0
- package/dist/mcp-server/tools/definitions/eurostat-dataframe-query.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/eurostat-query-dataset.tool.d.ts +9 -0
- package/dist/mcp-server/tools/definitions/eurostat-query-dataset.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/eurostat-query-dataset.tool.js +72 -10
- package/dist/mcp-server/tools/definitions/eurostat-query-dataset.tool.js.map +1 -1
- package/dist/services/canvas-accessor.d.ts +26 -0
- package/dist/services/canvas-accessor.d.ts.map +1 -0
- package/dist/services/canvas-accessor.js +57 -0
- package/dist/services/canvas-accessor.js.map +1 -0
- package/dist/services/eurostat-data/eurostat-data-service.d.ts +53 -8
- package/dist/services/eurostat-data/eurostat-data-service.d.ts.map +1 -1
- package/dist/services/eurostat-data/eurostat-data-service.js +90 -13
- package/dist/services/eurostat-data/eurostat-data-service.js.map +1 -1
- package/dist/services/eurostat-data/types.d.ts +30 -0
- package/dist/services/eurostat-data/types.d.ts.map +1 -1
- package/dist/services/eurostat-data/types.js +4 -0
- package/dist/services/eurostat-data/types.js.map +1 -1
- package/package.json +2 -1
- package/server.json +58 -4
|
@@ -4,11 +4,16 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { tool, z } from '@cyanheads/mcp-ts-core';
|
|
6
6
|
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
7
|
-
import {
|
|
7
|
+
import { acquireCanvas, getCanvas } from '../../../services/canvas-accessor.js';
|
|
8
|
+
import { getEurostatDataService, observationRowSchema, } from '../../../services/eurostat-data/eurostat-data-service.js';
|
|
8
9
|
import { GEO_LEVEL_VALUES, OBS_CAP } from '../../../services/eurostat-data/types.js';
|
|
10
|
+
/** Fresh handle for one staged result set. Distinct per call — each is its own match. */
|
|
11
|
+
function newTableName() {
|
|
12
|
+
return `df_${globalThis.crypto.randomUUID().slice(0, 8)}`;
|
|
13
|
+
}
|
|
9
14
|
export const eurostatQueryDataset = tool('eurostat_query_dataset', {
|
|
10
15
|
title: 'Query Eurostat Dataset',
|
|
11
|
-
description: 'Fetch statistical data from a Eurostat dataset with dimension filters. Returns decoded observations with dimension codes and labels, numeric values, and status flags (e.g., "p" = provisional, "e" = estimated). Call eurostat_get_dataset_info first to discover valid dimension codes and values. Apply filters to keep the result set manageable — large unfiltered queries may trigger an async response error. Use filters.geo for specific country/region codes, or geo_level for NUTS hierarchy filtering (mutually exclusive). Use last_n_periods for the N most recent periods without knowing the end date.',
|
|
16
|
+
description: 'Fetch statistical data from a Eurostat dataset with dimension filters. Returns decoded observations with dimension codes and labels, numeric values, and status flags (e.g., "p" = provisional, "e" = estimated), capped at 5,000 inline rows. Call eurostat_get_dataset_info first to discover valid dimension codes and values. Apply filters to keep the result set manageable — large unfiltered queries may trigger an async response error. Use filters.geo for specific country/region codes, or geo_level for NUTS hierarchy filtering (mutually exclusive). Use last_n_periods for the N most recent periods without knowing the end date. When the match exceeds the inline cap on a deployment that runs a dataframe canvas, the whole match is also staged as a SQL table and the response names it in tableName — read the rest with eurostat_dataframe_query rather than re-querying Eurostat.',
|
|
12
17
|
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: true },
|
|
13
18
|
input: z.object({
|
|
14
19
|
dataset_code: z.string().min(1).describe('Dataset code (e.g., "nama_10_gdp"). Required.'),
|
|
@@ -38,6 +43,10 @@ export const eurostatQueryDataset = tool('eurostat_query_dataset', {
|
|
|
38
43
|
.enum(['EN', 'FR', 'DE'])
|
|
39
44
|
.default('EN')
|
|
40
45
|
.describe('Language for labels in the response. Default is "EN". Options: "EN", "FR", "DE".'),
|
|
46
|
+
canvas_id: z
|
|
47
|
+
.string()
|
|
48
|
+
.optional()
|
|
49
|
+
.describe('Reuse an existing dataframe canvas, so a result staged by this call lands beside earlier ones and can be joined against them. Pass a canvasId from a previous response; omit to start a fresh canvas. Ignored on deployments without a dataframe canvas, and when the result fits inline and nothing is staged.'),
|
|
41
50
|
}),
|
|
42
51
|
output: z.object({
|
|
43
52
|
datasetCode: z.string().describe('Dataset code as provided.'),
|
|
@@ -70,11 +79,23 @@ export const eurostatQueryDataset = tool('eurostat_query_dataset', {
|
|
|
70
79
|
.describe('Status flag for this observation. Omitted for normal observations.'),
|
|
71
80
|
})
|
|
72
81
|
.describe('A single decoded observation with dimension values, numeric value, and optional status.'))
|
|
73
|
-
.describe('Decoded observations, capped at 5,000 rows. Past the cap these are the first 5,000 the response enumerates — the leading combinations of the dataset dimensions, neither a sample nor the most recent periods
|
|
82
|
+
.describe('Decoded observations, capped at 5,000 rows. Past the cap these are the first 5,000 the response enumerates — the leading combinations of the dataset dimensions, neither a sample nor the most recent periods. When tableName is set, these same rows and every row past the cap are staged on the dataframe canvas; when it is absent, narrow the query with dimension filters or a period range to choose which observations you get.'),
|
|
74
83
|
obsCount: z.number().describe('Total number of observations matched (before any cap).'),
|
|
75
84
|
truncated: z
|
|
76
85
|
.boolean()
|
|
77
|
-
.describe('True when the result exceeded 5,000 observations
|
|
86
|
+
.describe('True when the result exceeded 5,000 observations, so the returned rows are a prefix of the match rather than all of it. When tableName is set, the whole match is on the canvas and reachable with eurostat_dataframe_query; when it is absent, narrowing the query with dimension filters is what brings the rest into reach.'),
|
|
87
|
+
canvasId: z
|
|
88
|
+
.string()
|
|
89
|
+
.optional()
|
|
90
|
+
.describe('Dataframe canvas holding the staged result. Pass to eurostat_dataframe_describe, eurostat_dataframe_query, or a later eurostat_query_dataset call. Omitted when nothing was staged.'),
|
|
91
|
+
tableName: z
|
|
92
|
+
.string()
|
|
93
|
+
.optional()
|
|
94
|
+
.describe('Canvas table holding every matched observation in flat form — one code column per dimension plus a "_label" companion, then obs_value, obs_flag, obs_flag_label. Omitted when nothing was staged: either the result fit under the cap, or this deployment runs without a dataframe canvas.'),
|
|
95
|
+
stagedRowCount: z
|
|
96
|
+
.number()
|
|
97
|
+
.optional()
|
|
98
|
+
.describe('Rows written to the canvas table. Matches obsCount. Omitted alongside tableName when nothing was staged.'),
|
|
78
99
|
timeRange: z
|
|
79
100
|
.object({
|
|
80
101
|
start: z
|
|
@@ -106,7 +127,7 @@ export const eurostatQueryDataset = tool('eurostat_query_dataset', {
|
|
|
106
127
|
notice: z
|
|
107
128
|
.string()
|
|
108
129
|
.optional()
|
|
109
|
-
.describe('Guidance when the result was
|
|
130
|
+
.describe('Guidance when the result was capped at 5,000 rows — where the rest of the match is, or how to narrow the query. Omitted for uncapped results.'),
|
|
110
131
|
},
|
|
111
132
|
enrichmentTrailer: {
|
|
112
133
|
appliedFilters: {
|
|
@@ -161,6 +182,12 @@ export const eurostatQueryDataset = tool('eurostat_query_dataset', {
|
|
|
161
182
|
when: 'Mutually exclusive parameters were combined: "geo" filter + geo_level, or since_period/until_period + last_n_periods.',
|
|
162
183
|
recovery: 'Use "geo" or geo_level (not both); use since_period/until_period or last_n_periods (not both).',
|
|
163
184
|
},
|
|
185
|
+
{
|
|
186
|
+
reason: 'canvas_not_found',
|
|
187
|
+
code: JsonRpcErrorCode.NotFound,
|
|
188
|
+
when: 'A canvas_id was supplied for staging but is unknown or its lifetime has elapsed.',
|
|
189
|
+
recovery: 'Omit canvas_id so the response starts a fresh canvas and returns its canvasId.',
|
|
190
|
+
},
|
|
164
191
|
],
|
|
165
192
|
async handler(input, ctx) {
|
|
166
193
|
const svc = getEurostatDataService();
|
|
@@ -204,13 +231,37 @@ export const eurostatQueryDataset = tool('eurostat_query_dataset', {
|
|
|
204
231
|
}
|
|
205
232
|
// The service caps `observations` while decoding, so its length says nothing about how
|
|
206
233
|
// large the match was. `obsCount` is the full total and is what truncation turns on.
|
|
207
|
-
const { appliedFilters, ...queryResult } = result;
|
|
234
|
+
const { appliedFilters, rows, ...queryResult } = result;
|
|
208
235
|
const truncated = result.obsCount > OBS_CAP;
|
|
236
|
+
/**
|
|
237
|
+
* Stage the whole match only when the cap actually bit. Under the cap the
|
|
238
|
+
* caller already holds every row, so a canvas table would duplicate the
|
|
239
|
+
* response and burn a per-tenant canvas slot for nothing.
|
|
240
|
+
*
|
|
241
|
+
* `rows()` is a generator over the response body already in memory, so this
|
|
242
|
+
* costs no extra upstream request and never builds the full row set as an
|
|
243
|
+
* array — the canvas appender pulls one row at a time.
|
|
244
|
+
*/
|
|
245
|
+
const canvas = truncated ? getCanvas() : undefined;
|
|
246
|
+
let staged;
|
|
247
|
+
if (canvas) {
|
|
248
|
+
const instance = await acquireCanvas(canvas, input.canvas_id, ctx);
|
|
249
|
+
const handle = await instance.registerTable(newTableName(), rows(), {
|
|
250
|
+
schema: observationRowSchema(result.dimensionsUsed),
|
|
251
|
+
signal: ctx.signal,
|
|
252
|
+
});
|
|
253
|
+
staged = {
|
|
254
|
+
canvasId: instance.canvasId,
|
|
255
|
+
tableName: handle.tableName,
|
|
256
|
+
stagedRowCount: handle.rowCount,
|
|
257
|
+
};
|
|
258
|
+
}
|
|
209
259
|
ctx.log.info('Dataset query complete', {
|
|
210
260
|
datasetCode: input.dataset_code,
|
|
211
261
|
obsCount: result.obsCount,
|
|
212
262
|
truncated,
|
|
213
263
|
missingObsCount: result.missingObsCount,
|
|
264
|
+
...(staged && { canvasId: staged.canvasId, tableName: staged.tableName }),
|
|
214
265
|
});
|
|
215
266
|
// Sourced from the service's applied set, not raw input: a zero-length filter array is
|
|
216
267
|
// dropped from the upstream request, so echoing it back would claim a restriction that
|
|
@@ -225,9 +276,11 @@ export const eurostatQueryDataset = tool('eurostat_query_dataset', {
|
|
|
225
276
|
},
|
|
226
277
|
});
|
|
227
278
|
if (truncated) {
|
|
228
|
-
ctx.enrich.notice(
|
|
279
|
+
ctx.enrich.notice(staged
|
|
280
|
+
? `Inline rows capped at ${OBS_CAP.toLocaleString()} of ${result.obsCount.toLocaleString()} matched. All ${staged.stagedRowCount.toLocaleString()} are staged as table "${staged.tableName}" on canvas "${staged.canvasId}" — reach them with eurostat_dataframe_query, or narrow the query with dimension filters (geo, unit, na_item) to shrink what Eurostat sends.`
|
|
281
|
+
: `Result capped at ${OBS_CAP.toLocaleString()} of ${result.obsCount.toLocaleString()} matched rows. Add dimension filters (geo, unit, na_item) or a period range to bring the rest into reach.`);
|
|
229
282
|
}
|
|
230
|
-
return { ...queryResult, truncated };
|
|
283
|
+
return { ...queryResult, truncated, ...staged };
|
|
231
284
|
},
|
|
232
285
|
format: (result) => {
|
|
233
286
|
// An absent period bound is named as unreported rather than rendered as a blank, so
|
|
@@ -235,12 +288,21 @@ export const eurostatQueryDataset = tool('eurostat_query_dataset', {
|
|
|
235
288
|
const UNREPORTED = 'not reported by Eurostat';
|
|
236
289
|
const { start, end } = result.timeRange;
|
|
237
290
|
const period = start || end ? `${start ?? UNREPORTED} – ${end ?? UNREPORTED}` : UNREPORTED;
|
|
291
|
+
const truncationNote = !result.truncated
|
|
292
|
+
? ''
|
|
293
|
+
: result.tableName
|
|
294
|
+
? ' — inline rows capped at 5,000; the whole match is staged on the canvas below'
|
|
295
|
+
: ' — result capped at 5,000 rows. Add dimension filters to bring the rest into reach.';
|
|
238
296
|
const lines = [
|
|
239
297
|
`# ${result.datasetLabel} (\`${result.datasetCode}\`)`,
|
|
240
298
|
`**Observations:** ${result.obsCount} (${result.missingObsCount} missing) | **Period:** ${period}`,
|
|
241
|
-
`**Truncated:** ${result.truncated}${
|
|
242
|
-
`**Dimensions:** ${result.dimensionsUsed.join(', ')}
|
|
299
|
+
`**Truncated:** ${result.truncated}${truncationNote}`,
|
|
300
|
+
`**Dimensions:** ${result.dimensionsUsed.join(', ')}`,
|
|
243
301
|
];
|
|
302
|
+
if (result.tableName) {
|
|
303
|
+
lines.push(`**Staged:** table \`${result.tableName}\` on canvas \`${result.canvasId}\` (stagedRowCount ${result.stagedRowCount}) — query it with eurostat_dataframe_query`);
|
|
304
|
+
}
|
|
305
|
+
lines.push('');
|
|
244
306
|
// Render every observation so content[] carries the same rows as structuredContent —
|
|
245
307
|
// both surfaces are already bounded by the row cap the decoder applies.
|
|
246
308
|
for (const obs of result.observations) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eurostat-query-dataset.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/eurostat-query-dataset.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAiB,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAAE,sBAAsB,EAAE,MAAM,mDAAmD,CAAC;AAC3F,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAE9E,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC,wBAAwB,EAAE;IACjE,KAAK,EAAE,wBAAwB;IAC/B,WAAW,EACT,wlBAAwlB;IAC1lB,WAAW,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE;IAC9E,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ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,GAAG,CAAC,MAAM,CAAC,IAAI,KAAK,GAAG,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YAClF,KAAK,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,UAAU,EAAE,CAAC,CAAC;QAC9D,CAAC;QAED,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpD,CAAC;CACF,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"eurostat-query-dataset.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/eurostat-query-dataset.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAiB,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EACL,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAE9E,yFAAyF;AACzF,SAAS,YAAY;IACnB,OAAO,MAAM,UAAU,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;AAC5D,CAAC;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC,wBAAwB,EAAE;IACjE,KAAK,EAAE,wBAAwB;IAC/B,WAAW,EACT,82BAA82B;IACh3B,WAAW,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE;IAC9E,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;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AAS,kBAAkB,MAAM,CAAC,QAAQ,sBAAsB,MAAM,CAAC,cAAc,4CAA4C,CAChK,CAAC;QACJ,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEf,qFAAqF;QACrF,wEAAwE;QACxE,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;YACtC,yFAAyF;YACzF,MAAM,IAAI,GAAG,GAAG,CAAC,UAAyE,CAAC;YAC3F,MAAM,QAAQ,GAAG,MAAM,CAAC,cAAc,CAAC,GAAG,CACxC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,IAAI,GAAG,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,IAAI,GAAG,GAAG,CACzE,CAAC;YACF,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;YAC1D,MAAM,UAAU,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,IAAI,KAAK,GAAG,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YAClF,KAAK,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,UAAU,EAAE,CAAC,CAAC;QAC9D,CAAC;QAED,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpD,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Module-level accessor for the framework's optional DataCanvas
|
|
3
|
+
* service, plus the acquire helper every canvas-touching handler goes through.
|
|
4
|
+
* @module services/canvas-accessor
|
|
5
|
+
*/
|
|
6
|
+
import type { Context } from '@cyanheads/mcp-ts-core';
|
|
7
|
+
import type { CanvasInstance, DataCanvas } from '@cyanheads/mcp-ts-core/canvas';
|
|
8
|
+
/** Wired from `setup(core)` in `src/index.ts`. `undefined` when canvas is off. */
|
|
9
|
+
export declare function setCanvas(canvas: DataCanvas | undefined): void;
|
|
10
|
+
/**
|
|
11
|
+
* The DataCanvas service, or `undefined` when `CANVAS_PROVIDER_TYPE` is not
|
|
12
|
+
* `duckdb`. Callers branch on the absence rather than assuming a canvas exists:
|
|
13
|
+
* the server is a supported configuration with and without one.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getCanvas(): DataCanvas | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Acquire a canvas, translating a scratch-directory permission failure into an
|
|
18
|
+
* error that names the variable to change.
|
|
19
|
+
*
|
|
20
|
+
* DuckDB writes spill files under `CANVAS_TEMP_PATH`, whose directory is created
|
|
21
|
+
* on the first acquire. A container running as a non-root user against a
|
|
22
|
+
* root-owned or read-only path otherwise surfaces a bare `EACCES … mkdir` with
|
|
23
|
+
* nothing to connect it to a configuration knob.
|
|
24
|
+
*/
|
|
25
|
+
export declare function acquireCanvas(canvas: DataCanvas, canvasId: string | undefined, ctx: Context): Promise<CanvasInstance>;
|
|
26
|
+
//# sourceMappingURL=canvas-accessor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canvas-accessor.d.ts","sourceRoot":"","sources":["../../src/services/canvas-accessor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAKhF,kFAAkF;AAClF,wBAAgB,SAAS,CAAC,MAAM,EAAE,UAAU,GAAG,SAAS,GAAG,IAAI,CAE9D;AAED;;;;GAIG;AACH,wBAAgB,SAAS,IAAI,UAAU,GAAG,SAAS,CAElD;AAoBD;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,GAAG,EAAE,OAAO,GACX,OAAO,CAAC,cAAc,CAAC,CAYzB"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Module-level accessor for the framework's optional DataCanvas
|
|
3
|
+
* service, plus the acquire helper every canvas-touching handler goes through.
|
|
4
|
+
* @module services/canvas-accessor
|
|
5
|
+
*/
|
|
6
|
+
import { serviceUnavailable } from '@cyanheads/mcp-ts-core/errors';
|
|
7
|
+
let _canvas;
|
|
8
|
+
/** Wired from `setup(core)` in `src/index.ts`. `undefined` when canvas is off. */
|
|
9
|
+
export function setCanvas(canvas) {
|
|
10
|
+
_canvas = canvas;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The DataCanvas service, or `undefined` when `CANVAS_PROVIDER_TYPE` is not
|
|
14
|
+
* `duckdb`. Callers branch on the absence rather than assuming a canvas exists:
|
|
15
|
+
* the server is a supported configuration with and without one.
|
|
16
|
+
*/
|
|
17
|
+
export function getCanvas() {
|
|
18
|
+
return _canvas;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Errno codes meaning the configured scratch root cannot be written to.
|
|
22
|
+
*
|
|
23
|
+
* `ENOENT` is deliberately absent — `mkdir` is recursive, so a missing parent
|
|
24
|
+
* is created rather than reported.
|
|
25
|
+
*/
|
|
26
|
+
const UNWRITABLE_ERRNOS = new Set(['EACCES', 'EPERM', 'EROFS', 'ENOSPC']);
|
|
27
|
+
/** First `errno` code found on an error or any link of its `cause` chain. */
|
|
28
|
+
function errnoOf(err) {
|
|
29
|
+
for (let cur = err, depth = 0; cur instanceof Error && depth < 5; depth++) {
|
|
30
|
+
const code = cur.code;
|
|
31
|
+
if (typeof code === 'string' && UNWRITABLE_ERRNOS.has(code))
|
|
32
|
+
return code;
|
|
33
|
+
cur = cur.cause;
|
|
34
|
+
}
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Acquire a canvas, translating a scratch-directory permission failure into an
|
|
39
|
+
* error that names the variable to change.
|
|
40
|
+
*
|
|
41
|
+
* DuckDB writes spill files under `CANVAS_TEMP_PATH`, whose directory is created
|
|
42
|
+
* on the first acquire. A container running as a non-root user against a
|
|
43
|
+
* root-owned or read-only path otherwise surfaces a bare `EACCES … mkdir` with
|
|
44
|
+
* nothing to connect it to a configuration knob.
|
|
45
|
+
*/
|
|
46
|
+
export async function acquireCanvas(canvas, canvasId, ctx) {
|
|
47
|
+
try {
|
|
48
|
+
return await canvas.acquire(canvasId, ctx);
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
const errno = errnoOf(err);
|
|
52
|
+
if (!errno)
|
|
53
|
+
throw err;
|
|
54
|
+
throw serviceUnavailable(`DataCanvas could not create its scratch directory (${errno}). Point CANVAS_TEMP_PATH at a directory the server process can write to, or set CANVAS_PROVIDER_TYPE=none to run without the dataframe tools.`, { reason: 'canvas_unavailable', errno }, { cause: err instanceof Error ? err : undefined });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=canvas-accessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canvas-accessor.js","sourceRoot":"","sources":["../../src/services/canvas-accessor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,IAAI,OAA+B,CAAC;AAEpC,kFAAkF;AAClF,MAAM,UAAU,SAAS,CAAC,MAA8B;IACtD,OAAO,GAAG,MAAM,CAAC;AACnB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS;IACvB,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;GAKG;AACH,MAAM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ema } from '@cyanheads/mcp-ts-core/canvas';
|
|
7
8
|
import type { AppConfig } from '@cyanheads/mcp-ts-core/config';
|
|
8
9
|
import type { StorageService } from '@cyanheads/mcp-ts-core/storage';
|
|
9
|
-
import { type DatasetMeta, type DimensionValuesResult, type GeoLevel, type
|
|
10
|
+
import { type DatasetMeta, type DimensionValuesResult, type GeoLevel, type Observation, type ObservationRow, type QueryExecution } from './types.js';
|
|
10
11
|
export declare class EurostatDataService {
|
|
11
12
|
constructor(_config: AppConfig, _storage: StorageService);
|
|
12
13
|
private buildUrl;
|
|
@@ -27,12 +28,26 @@ export declare class EurostatDataService {
|
|
|
27
28
|
*/
|
|
28
29
|
private scanCells;
|
|
29
30
|
/**
|
|
30
|
-
*
|
|
31
|
+
* Walk a JSON-stat 2.0 response's populated cells, yielding one labeled
|
|
32
|
+
* observation at a time via stride-based indexing.
|
|
31
33
|
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
34
|
+
* Cells come out in ascending linear-index order — an order this walk sets
|
|
35
|
+
* itself rather than reading from the upstream key order, so a given response
|
|
36
|
+
* always yields the same rows in the same sequence. Being a generator, it
|
|
37
|
+
* allocates one observation per pull and none in advance, which is what lets
|
|
38
|
+
* the same walk serve both a capped decode and an uncapped dataframe spill.
|
|
39
|
+
*
|
|
40
|
+
* This is the only place cell membership is decided: a cell is an observation
|
|
41
|
+
* when its linear index appears in `value` or in `status`. `scanCells` counts
|
|
42
|
+
* that same predicate from the other direction (over the key maps) so the
|
|
43
|
+
* totals it reports describe exactly this set.
|
|
44
|
+
*/
|
|
45
|
+
private iterateObservations;
|
|
46
|
+
/**
|
|
47
|
+
* Take the first `limit` observations off {@link iterateObservations}.
|
|
48
|
+
*
|
|
49
|
+
* Bounding here keeps an oversized match from ever materializing as observation
|
|
50
|
+
* objects — the walk stops the moment the cap is reached. The counts that
|
|
36
51
|
* describe the whole match come from `scanCells`.
|
|
37
52
|
*/
|
|
38
53
|
private decodeObservations;
|
|
@@ -89,10 +104,40 @@ export declare class EurostatDataService {
|
|
|
89
104
|
getDimensionValues(datasetCode: string, dimension: string, geoLevel: GeoLevel | undefined, ctx: Context): Promise<DimensionValuesResult>;
|
|
90
105
|
/**
|
|
91
106
|
* Query dataset observations with dimension filters.
|
|
92
|
-
*
|
|
107
|
+
*
|
|
108
|
+
* Returns the capped observation list alongside `rows()`, a lazy generator
|
|
109
|
+
* over the whole match. Both read the same response body — already in memory
|
|
110
|
+
* before decoding starts — so reaching the rows past the cap costs no
|
|
111
|
+
* additional upstream request.
|
|
93
112
|
*/
|
|
94
|
-
queryDataset(datasetCode: string, filters: Record<string, string[]>, geoLevel: GeoLevel | undefined, sinceP: string | undefined, untilP: string | undefined, lastN: number | undefined, lang: string, ctx: Context): Promise<
|
|
113
|
+
queryDataset(datasetCode: string, filters: Record<string, string[]>, geoLevel: GeoLevel | undefined, sinceP: string | undefined, untilP: string | undefined, lastN: number | undefined, lang: string, ctx: Context): Promise<QueryExecution>;
|
|
114
|
+
/** {@link iterateObservations}, flattened to dataframe rows one at a time. */
|
|
115
|
+
private iterateRows;
|
|
95
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Flatten one observation into a dataframe row.
|
|
119
|
+
*
|
|
120
|
+
* The inverse of the nested shape `Observation` carries: each dimension
|
|
121
|
+
* contributes `<dim>` (code) and `<dim>_label`, and the status flag contributes
|
|
122
|
+
* `obs_flag` / `obs_flag_label`. A dimension the observation does not carry
|
|
123
|
+
* yields `null` in both of its columns rather than an absent key, so every row
|
|
124
|
+
* has the same column set the table is declared with.
|
|
125
|
+
*/
|
|
126
|
+
export declare function toObservationRow(obs: Observation, dimensionsUsed: string[]): ObservationRow;
|
|
127
|
+
/**
|
|
128
|
+
* Explicit canvas column schema for {@link toObservationRow}'s output.
|
|
129
|
+
*
|
|
130
|
+
* Declared rather than sniffed. Inference reads only the leading rows, which is
|
|
131
|
+
* enough to get the measure column wrong twice over: an all-integer prefix types
|
|
132
|
+
* it `BIGINT`, which the canvas then serializes as a string, and an all-missing
|
|
133
|
+
* prefix types it from nulls alone. Every column is nullable — a dimension can
|
|
134
|
+
* be absent from a cell, and a status flag usually is.
|
|
135
|
+
*
|
|
136
|
+
* Names and order mirror {@link toObservationRow}. Nothing in the type system
|
|
137
|
+
* ties a row's keys to a schema's names, so the service tests assert the two
|
|
138
|
+
* against each other instead.
|
|
139
|
+
*/
|
|
140
|
+
export declare function observationRowSchema(dimensionsUsed: string[]): ColumnSchema[];
|
|
96
141
|
export declare function initEurostatDataService(config: AppConfig, storage: StorageService): void;
|
|
97
142
|
export declare function getEurostatDataService(): EurostatDataService;
|
|
98
143
|
//# sourceMappingURL=eurostat-data-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eurostat-data-service.d.ts","sourceRoot":"","sources":["../../../src/services/eurostat-data/eurostat-data-service.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAO/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAGrE,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,qBAAqB,EAC1B,KAAK,QAAQ,
|
|
1
|
+
{"version":3,"file":"eurostat-data-service.d.ts","sourceRoot":"","sources":["../../../src/services/eurostat-data/eurostat-data-service.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAO/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAGrE,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,qBAAqB,EAC1B,KAA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A8E;IAC9E,OAAO,CAAE,WAAW;CAQrB;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,cAAc,CAW3F;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,cAAc,EAAE,MAAM,EAAE,GAAG,YAAY,EAAE,CAU7E;AAMD,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI,CAExF;AAED,wBAAgB,sBAAsB,IAAI,mBAAmB,CAO5D"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { McpError, notFound, serviceUnavailable, validationError, } from '@cyanheads/mcp-ts-core/errors';
|
|
7
7
|
import { fetchWithTimeout, withRetry } from '@cyanheads/mcp-ts-core/utils';
|
|
8
8
|
import { getServerConfig } from '../../config/server-config.js';
|
|
9
|
-
import { OBS_CAP, } from './types.js';
|
|
9
|
+
import { OBS_CAP, OBS_FLAG_COLUMN, OBS_FLAG_LABEL_COLUMN, OBS_VALUE_COLUMN, } from './types.js';
|
|
10
10
|
// Context satisfies the runtime contract of RequestContext but lacks the index signature
|
|
11
11
|
// required by fetchWithTimeout/withRetry.
|
|
12
12
|
const asReqCtx = (ctx) => ctx;
|
|
@@ -176,17 +176,23 @@ export class EurostatDataService {
|
|
|
176
176
|
return { obsCount, missingObsCount, timeCodes: timeCodes.sort() };
|
|
177
177
|
}
|
|
178
178
|
/**
|
|
179
|
-
*
|
|
179
|
+
* Walk a JSON-stat 2.0 response's populated cells, yielding one labeled
|
|
180
|
+
* observation at a time via stride-based indexing.
|
|
180
181
|
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
182
|
+
* Cells come out in ascending linear-index order — an order this walk sets
|
|
183
|
+
* itself rather than reading from the upstream key order, so a given response
|
|
184
|
+
* always yields the same rows in the same sequence. Being a generator, it
|
|
185
|
+
* allocates one observation per pull and none in advance, which is what lets
|
|
186
|
+
* the same walk serve both a capped decode and an uncapped dataframe spill.
|
|
187
|
+
*
|
|
188
|
+
* This is the only place cell membership is decided: a cell is an observation
|
|
189
|
+
* when its linear index appears in `value` or in `status`. `scanCells` counts
|
|
190
|
+
* that same predicate from the other direction (over the key maps) so the
|
|
191
|
+
* totals it reports describe exactly this set.
|
|
186
192
|
*/
|
|
187
|
-
|
|
193
|
+
*iterateObservations(data) {
|
|
188
194
|
if (!data.id || !data.size || !data.dimension)
|
|
189
|
-
return
|
|
195
|
+
return;
|
|
190
196
|
const dims = data.id;
|
|
191
197
|
const sizes = data.size;
|
|
192
198
|
const value = data.value ?? {};
|
|
@@ -205,9 +211,8 @@ export class EurostatDataService {
|
|
|
205
211
|
label: cat.label?.[code] ?? code,
|
|
206
212
|
}));
|
|
207
213
|
});
|
|
208
|
-
const observations = [];
|
|
209
214
|
const totalCells = sizes.reduce((a, b) => a * b, 1);
|
|
210
|
-
for (let linearIdx = 0; linearIdx < totalCells
|
|
215
|
+
for (let linearIdx = 0; linearIdx < totalCells; linearIdx++) {
|
|
211
216
|
const keyStr = String(linearIdx);
|
|
212
217
|
if (!(keyStr in value) && !(keyStr in status))
|
|
213
218
|
continue;
|
|
@@ -233,7 +238,22 @@ export class EurostatDataService {
|
|
|
233
238
|
label: statusLabels[statusCode] ?? statusCode,
|
|
234
239
|
};
|
|
235
240
|
}
|
|
241
|
+
yield obs;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Take the first `limit` observations off {@link iterateObservations}.
|
|
246
|
+
*
|
|
247
|
+
* Bounding here keeps an oversized match from ever materializing as observation
|
|
248
|
+
* objects — the walk stops the moment the cap is reached. The counts that
|
|
249
|
+
* describe the whole match come from `scanCells`.
|
|
250
|
+
*/
|
|
251
|
+
decodeObservations(data, limit) {
|
|
252
|
+
const observations = [];
|
|
253
|
+
for (const obs of this.iterateObservations(data)) {
|
|
236
254
|
observations.push(obs);
|
|
255
|
+
if (observations.length >= limit)
|
|
256
|
+
break;
|
|
237
257
|
}
|
|
238
258
|
return observations;
|
|
239
259
|
}
|
|
@@ -395,7 +415,11 @@ export class EurostatDataService {
|
|
|
395
415
|
}
|
|
396
416
|
/**
|
|
397
417
|
* Query dataset observations with dimension filters.
|
|
398
|
-
*
|
|
418
|
+
*
|
|
419
|
+
* Returns the capped observation list alongside `rows()`, a lazy generator
|
|
420
|
+
* over the whole match. Both read the same response body — already in memory
|
|
421
|
+
* before decoding starts — so reaching the rows past the cap costs no
|
|
422
|
+
* additional upstream request.
|
|
399
423
|
*/
|
|
400
424
|
async queryDataset(datasetCode, filters, geoLevel, sinceP, untilP, lastN, lang, ctx) {
|
|
401
425
|
// A zero-length filter array places no restriction on the request. Drop those entries once,
|
|
@@ -446,17 +470,70 @@ export class EurostatDataService {
|
|
|
446
470
|
const start = timeCodes[0] ?? this.extractAnnotation(data, 'OBS_PERIOD_OVERALL_OLDEST', 'title');
|
|
447
471
|
const end = timeCodes.at(-1) ?? this.extractAnnotation(data, 'OBS_PERIOD_OVERALL_LATEST', 'title');
|
|
448
472
|
const timeRange = { ...(start && { start }), ...(end && { end }) };
|
|
473
|
+
const dimensionsUsed = data.id ?? [];
|
|
449
474
|
return {
|
|
450
475
|
datasetCode,
|
|
451
476
|
datasetLabel: data.label ?? datasetCode,
|
|
452
|
-
dimensionsUsed
|
|
477
|
+
dimensionsUsed,
|
|
453
478
|
observations,
|
|
454
479
|
obsCount,
|
|
455
480
|
timeRange,
|
|
456
481
|
missingObsCount,
|
|
457
482
|
appliedFilters,
|
|
483
|
+
rows: () => this.iterateRows(data, dimensionsUsed),
|
|
458
484
|
};
|
|
459
485
|
}
|
|
486
|
+
/** {@link iterateObservations}, flattened to dataframe rows one at a time. */
|
|
487
|
+
*iterateRows(data, dimensionsUsed) {
|
|
488
|
+
for (const obs of this.iterateObservations(data)) {
|
|
489
|
+
yield toObservationRow(obs, dimensionsUsed);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Flatten one observation into a dataframe row.
|
|
495
|
+
*
|
|
496
|
+
* The inverse of the nested shape `Observation` carries: each dimension
|
|
497
|
+
* contributes `<dim>` (code) and `<dim>_label`, and the status flag contributes
|
|
498
|
+
* `obs_flag` / `obs_flag_label`. A dimension the observation does not carry
|
|
499
|
+
* yields `null` in both of its columns rather than an absent key, so every row
|
|
500
|
+
* has the same column set the table is declared with.
|
|
501
|
+
*/
|
|
502
|
+
export function toObservationRow(obs, dimensionsUsed) {
|
|
503
|
+
const row = {};
|
|
504
|
+
for (const dim of dimensionsUsed) {
|
|
505
|
+
const cell = obs.dimensions[dim];
|
|
506
|
+
row[dim] = cell?.code ?? null;
|
|
507
|
+
row[`${dim}_label`] = cell?.label ?? null;
|
|
508
|
+
}
|
|
509
|
+
row[OBS_VALUE_COLUMN] = obs.value;
|
|
510
|
+
row[OBS_FLAG_COLUMN] = obs.status?.code ?? null;
|
|
511
|
+
row[OBS_FLAG_LABEL_COLUMN] = obs.status?.label ?? null;
|
|
512
|
+
return row;
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Explicit canvas column schema for {@link toObservationRow}'s output.
|
|
516
|
+
*
|
|
517
|
+
* Declared rather than sniffed. Inference reads only the leading rows, which is
|
|
518
|
+
* enough to get the measure column wrong twice over: an all-integer prefix types
|
|
519
|
+
* it `BIGINT`, which the canvas then serializes as a string, and an all-missing
|
|
520
|
+
* prefix types it from nulls alone. Every column is nullable — a dimension can
|
|
521
|
+
* be absent from a cell, and a status flag usually is.
|
|
522
|
+
*
|
|
523
|
+
* Names and order mirror {@link toObservationRow}. Nothing in the type system
|
|
524
|
+
* ties a row's keys to a schema's names, so the service tests assert the two
|
|
525
|
+
* against each other instead.
|
|
526
|
+
*/
|
|
527
|
+
export function observationRowSchema(dimensionsUsed) {
|
|
528
|
+
return [
|
|
529
|
+
...dimensionsUsed.flatMap((dim) => [
|
|
530
|
+
{ name: dim, type: 'VARCHAR', nullable: true },
|
|
531
|
+
{ name: `${dim}_label`, type: 'VARCHAR', nullable: true },
|
|
532
|
+
]),
|
|
533
|
+
{ name: OBS_VALUE_COLUMN, type: 'DOUBLE', nullable: true },
|
|
534
|
+
{ name: OBS_FLAG_COLUMN, type: 'VARCHAR', nullable: true },
|
|
535
|
+
{ name: OBS_FLAG_LABEL_COLUMN, type: 'VARCHAR', nullable: true },
|
|
536
|
+
];
|
|
460
537
|
}
|
|
461
538
|
// --- Init/accessor pattern ---
|
|
462
539
|
let _service;
|