@cyanheads/eurostat-mcp-server 0.8.1 → 0.10.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/AGENTS.md +27 -21
- package/CLAUDE.md +27 -21
- package/Dockerfile +94 -46
- package/README.md +42 -38
- package/changelog/0.10.x/0.10.0.md +40 -0
- package/changelog/0.9.x/0.9.0.md +43 -0
- package/dist/config/server-config.d.ts +1 -0
- package/dist/config/server-config.d.ts.map +1 -1
- package/dist/config/server-config.js +5 -0
- package/dist/config/server-config.js.map +1 -1
- package/dist/index.js +45 -5
- package/dist/index.js.map +1 -1
- package/dist/mcp-server/tools/definitions/eurostat-browse-themes.tool.d.ts +10 -2
- package/dist/mcp-server/tools/definitions/eurostat-browse-themes.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/eurostat-browse-themes.tool.js +63 -10
- package/dist/mcp-server/tools/definitions/eurostat-browse-themes.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/eurostat-dataframe-describe.tool.d.ts +0 -1
- package/dist/mcp-server/tools/definitions/eurostat-dataframe-describe.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/eurostat-dataframe-describe.tool.js +15 -5
- package/dist/mcp-server/tools/definitions/eurostat-dataframe-describe.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/eurostat-dataframe-drop.tool.d.ts +34 -0
- package/dist/mcp-server/tools/definitions/eurostat-dataframe-drop.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/eurostat-dataframe-drop.tool.js +112 -0
- package/dist/mcp-server/tools/definitions/eurostat-dataframe-drop.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/eurostat-dataframe-query.tool.d.ts +0 -2
- package/dist/mcp-server/tools/definitions/eurostat-dataframe-query.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/eurostat-dataframe-query.tool.js +18 -6
- package/dist/mcp-server/tools/definitions/eurostat-dataframe-query.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/eurostat-download-dataset.tool.d.ts +1 -2
- package/dist/mcp-server/tools/definitions/eurostat-download-dataset.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/eurostat-download-dataset.tool.js +39 -14
- package/dist/mcp-server/tools/definitions/eurostat-download-dataset.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/eurostat-get-dataset-info.tool.d.ts +1 -1
- package/dist/mcp-server/tools/definitions/eurostat-get-dataset-info.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/eurostat-get-dataset-info.tool.js +10 -1
- package/dist/mcp-server/tools/definitions/eurostat-get-dataset-info.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/eurostat-get-dimension-values.tool.d.ts +13 -6
- package/dist/mcp-server/tools/definitions/eurostat-get-dimension-values.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/eurostat-get-dimension-values.tool.js +235 -53
- package/dist/mcp-server/tools/definitions/eurostat-get-dimension-values.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/eurostat-query-dataset.tool.d.ts +9 -5
- 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 +45 -19
- package/dist/mcp-server/tools/definitions/eurostat-query-dataset.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/eurostat-search-datasets.tool.d.ts +10 -2
- package/dist/mcp-server/tools/definitions/eurostat-search-datasets.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/eurostat-search-datasets.tool.js +79 -14
- package/dist/mcp-server/tools/definitions/eurostat-search-datasets.tool.js.map +1 -1
- package/dist/mcp-server/tools/narrowing-advice.d.ts +2 -1
- package/dist/mcp-server/tools/narrowing-advice.d.ts.map +1 -1
- package/dist/mcp-server/tools/narrowing-advice.js +4 -1
- package/dist/mcp-server/tools/narrowing-advice.js.map +1 -1
- package/dist/mcp-server/tools/value-list-paging.d.ts +49 -0
- package/dist/mcp-server/tools/value-list-paging.d.ts.map +1 -0
- package/dist/mcp-server/tools/value-list-paging.js +73 -0
- package/dist/mcp-server/tools/value-list-paging.js.map +1 -0
- package/dist/services/canvas-accessor.d.ts +21 -7
- package/dist/services/canvas-accessor.d.ts.map +1 -1
- package/dist/services/canvas-accessor.js +26 -11
- package/dist/services/canvas-accessor.js.map +1 -1
- package/dist/services/eurostat-bulk/eurostat-bulk-service.d.ts +8 -4
- package/dist/services/eurostat-bulk/eurostat-bulk-service.d.ts.map +1 -1
- package/dist/services/eurostat-bulk/eurostat-bulk-service.js +62 -25
- package/dist/services/eurostat-bulk/eurostat-bulk-service.js.map +1 -1
- package/dist/services/eurostat-catalogue/eurostat-catalogue-service.d.ts +46 -4
- package/dist/services/eurostat-catalogue/eurostat-catalogue-service.d.ts.map +1 -1
- package/dist/services/eurostat-catalogue/eurostat-catalogue-service.js +134 -33
- package/dist/services/eurostat-catalogue/eurostat-catalogue-service.js.map +1 -1
- package/dist/services/eurostat-data/eurostat-data-service.d.ts +5 -0
- package/dist/services/eurostat-data/eurostat-data-service.d.ts.map +1 -1
- package/dist/services/eurostat-data/eurostat-data-service.js +133 -24
- package/dist/services/eurostat-data/eurostat-data-service.js.map +1 -1
- package/dist/services/eurostat-filters.d.ts +13 -0
- package/dist/services/eurostat-filters.d.ts.map +1 -0
- package/dist/services/eurostat-filters.js +21 -0
- package/dist/services/eurostat-filters.js.map +1 -0
- package/dist/services/eurostat-outage.d.ts +27 -0
- package/dist/services/eurostat-outage.d.ts.map +1 -0
- package/dist/services/eurostat-outage.js +44 -0
- package/dist/services/eurostat-outage.js.map +1 -0
- package/package.json +12 -11
- package/server.json +26 -26
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { tool, z } from '@cyanheads/mcp-ts-core';
|
|
6
6
|
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
7
7
|
import { getEurostatCatalogueService } from '../../../services/eurostat-catalogue/eurostat-catalogue-service.js';
|
|
8
|
+
import { outageAnswer } from '../../../services/eurostat-outage.js';
|
|
8
9
|
export const eurostatBrowseThemes = tool('eurostat_browse_themes', {
|
|
9
10
|
title: 'Browse Eurostat Theme Hierarchy',
|
|
10
11
|
description: 'Navigate the Eurostat theme tree. Without theme_code returns the top-level theme folders (Economy, Population, Transport, etc.) — the practical starting points. With a theme_code returns its immediate children: subtheme folders and datasets in that branch. Use this for structured discovery when you know the domain but not the dataset code, or to drill down from a broad topic to a specific dataset. Pair with eurostat_search_datasets for keyword-based discovery. The tree is the dissemination table of contents plus the Comext host\'s DS-* collections: detailed trade under ext_go_detail (inside ext_go, "International trade in goods") and PRODCOM under prom (inside icts, "Industry, trade and services"). A collection on neither, such as the legacy PRODCOM DS-056120, is not disseminated and appears nowhere in the tree.',
|
|
@@ -61,13 +62,25 @@ export const eurostatBrowseThemes = tool('eurostat_browse_themes', {
|
|
|
61
62
|
enrichment: {
|
|
62
63
|
itemCount: z.number().describe('Number of items returned in this level.'),
|
|
63
64
|
themeCode: z.string().optional().describe('Folder code that was browsed, or omitted for root.'),
|
|
65
|
+
comextListMissing: z
|
|
66
|
+
.boolean()
|
|
67
|
+
.optional()
|
|
68
|
+
.describe('True on a browse of ext_go or icts when the Comext dataflow list could not be loaded, so the DS-* collection folder filed there is not listed. Omitted otherwise.'),
|
|
69
|
+
catalogueLoadedAt: z
|
|
70
|
+
.string()
|
|
71
|
+
.optional()
|
|
72
|
+
.describe('When the catalogue that answered was loaded (ISO 8601). Present only when a refresh failed and that older copy is still in service; omitted otherwise.'),
|
|
73
|
+
notice: z
|
|
74
|
+
.string()
|
|
75
|
+
.optional()
|
|
76
|
+
.describe('Names each part of the catalogue this listing is missing — the Comext collections, or updates since a refresh failed — and what to do about it. Omitted when the whole catalogue answered.'),
|
|
64
77
|
},
|
|
65
78
|
errors: [
|
|
66
79
|
{
|
|
67
80
|
reason: 'not_found',
|
|
68
81
|
code: JsonRpcErrorCode.NotFound,
|
|
69
|
-
when: 'The provided theme_code does not exist in the TOC.',
|
|
70
|
-
recovery: 'Call eurostat_browse_themes without theme_code to see valid root themes, then navigate from there.',
|
|
82
|
+
when: 'The provided theme_code does not exist in the TOC — or is a Comext folder (ext_go_detail, prom, comext) or DS-* code while the Comext dataflow list cannot be loaded.',
|
|
83
|
+
recovery: 'Call eurostat_browse_themes without theme_code to see valid root themes, then navigate from there. A Comext folder missing because its list could not be loaded returns once the merge is retried, about once a minute; eurostat_get_dataset_info reads a DS-* code directly.',
|
|
71
84
|
},
|
|
72
85
|
{
|
|
73
86
|
reason: 'not_a_folder',
|
|
@@ -75,6 +88,12 @@ export const eurostatBrowseThemes = tool('eurostat_browse_themes', {
|
|
|
75
88
|
when: 'The provided theme_code identifies a dataset or table entry instead of a folder.',
|
|
76
89
|
recovery: 'Pass the code to eurostat_get_dataset_info to inspect it, then eurostat_query_dataset to retrieve data.',
|
|
77
90
|
},
|
|
91
|
+
{
|
|
92
|
+
reason: 'upstream_fault',
|
|
93
|
+
code: JsonRpcErrorCode.ServiceUnavailable,
|
|
94
|
+
when: "The server had no catalogue loaded yet, and Eurostat's table of contents answered HTTP 5xx or could not be reached on every retry, which the error marks retryable. Once a catalogue is loaded, a failed refresh serves that copy instead.",
|
|
95
|
+
recovery: "Retry in a few minutes: the catalogue load failed on Eurostat's side and runs again on the next call.",
|
|
96
|
+
},
|
|
78
97
|
],
|
|
79
98
|
async handler(input, ctx) {
|
|
80
99
|
const svc = getEurostatCatalogueService();
|
|
@@ -86,10 +105,20 @@ export const eurostatBrowseThemes = tool('eurostat_browse_themes', {
|
|
|
86
105
|
catch (err) {
|
|
87
106
|
const data = err.data;
|
|
88
107
|
if (data?.reason === 'not_found') {
|
|
108
|
+
const stale = data.catalogueLoadedAt
|
|
109
|
+
? `The catalogue could not be refreshed, so this lookup ran against the copy loaded at ${data.catalogueLoadedAt}; folders Eurostat added since then are not in it.`
|
|
110
|
+
: undefined;
|
|
111
|
+
const hint = data.comextListMissing
|
|
112
|
+
? [
|
|
113
|
+
`The Comext dataflow list merge is retried about once a minute: browse "${themeCode}" again after that. eurostat_get_dataset_info reads a DS-* code directly.`,
|
|
114
|
+
stale,
|
|
115
|
+
]
|
|
116
|
+
: [
|
|
117
|
+
stale,
|
|
118
|
+
'Call eurostat_browse_themes without theme_code to see valid root themes, then navigate from there.',
|
|
119
|
+
];
|
|
89
120
|
throw ctx.fail('not_found', err.message, {
|
|
90
|
-
recovery: {
|
|
91
|
-
hint: 'Call eurostat_browse_themes without theme_code to see valid root themes, then navigate from there.',
|
|
92
|
-
},
|
|
121
|
+
recovery: { hint: hint.filter(Boolean).join(' ') },
|
|
93
122
|
});
|
|
94
123
|
}
|
|
95
124
|
if (data?.reason === 'not_a_folder') {
|
|
@@ -101,16 +130,40 @@ export const eurostatBrowseThemes = tool('eurostat_browse_themes', {
|
|
|
101
130
|
},
|
|
102
131
|
});
|
|
103
132
|
}
|
|
133
|
+
if (data?.reason === 'upstream_fault' && data.retryable === true) {
|
|
134
|
+
throw ctx.fail('upstream_fault', err.message, {
|
|
135
|
+
retryable: true,
|
|
136
|
+
recovery: {
|
|
137
|
+
hint: `Eurostat's table of contents ${outageAnswer(data.status)} on every attempt, so there is no catalogue to browse yet — an upstream outage, not a fault in the request. The load runs again on the next call, so retry in a few minutes.`,
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
}
|
|
104
141
|
throw err;
|
|
105
142
|
}
|
|
106
|
-
|
|
107
|
-
ctx.
|
|
108
|
-
|
|
143
|
+
const { comextListMissing, catalogueLoadedAt, ...listing } = browsed;
|
|
144
|
+
ctx.log.info('Theme browse complete', { themeCode, itemCount: listing.items.length });
|
|
145
|
+
ctx.enrich({
|
|
146
|
+
itemCount: listing.items.length,
|
|
147
|
+
...(themeCode && { themeCode }),
|
|
148
|
+
...(comextListMissing && { comextListMissing }),
|
|
149
|
+
...(catalogueLoadedAt && { catalogueLoadedAt }),
|
|
150
|
+
});
|
|
151
|
+
// `notice` is last-wins, so every sentence is collected here and written once.
|
|
152
|
+
const notices = [];
|
|
153
|
+
if (comextListMissing) {
|
|
154
|
+
notices.push('The Comext dataflow list could not be loaded, so the DS-* collections filed in this folder are not listed; the merge is retried about once a minute. eurostat_get_dataset_info reads a DS-* code directly.');
|
|
155
|
+
}
|
|
156
|
+
if (catalogueLoadedAt) {
|
|
157
|
+
notices.push(`The catalogue could not be refreshed, so this listing comes from the copy loaded at ${catalogueLoadedAt}; folders and datasets Eurostat added or changed since then are not reflected.`);
|
|
158
|
+
}
|
|
159
|
+
if (notices.length > 0)
|
|
160
|
+
ctx.enrich.notice(notices.join(' '));
|
|
161
|
+
const nextStep = listing.items.length === 0
|
|
109
162
|
? undefined
|
|
110
|
-
:
|
|
163
|
+
: listing.items.some((i) => i.type !== 'folder')
|
|
111
164
|
? `Pass a dataset/table code to eurostat_get_dataset_info to inspect dimensions. Pass a folder code back to theme_code to drill deeper.`
|
|
112
165
|
: `Pass a folder code back to theme_code to drill into sub-themes.`;
|
|
113
|
-
return { ...
|
|
166
|
+
return { ...listing, ...(nextStep && { nextStep }) };
|
|
114
167
|
},
|
|
115
168
|
format: (result) => {
|
|
116
169
|
const lines = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eurostat-browse-themes.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/eurostat-browse-themes.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,2BAA2B,EAAE,MAAM,6DAA6D,CAAC;
|
|
1
|
+
{"version":3,"file":"eurostat-browse-themes.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/eurostat-browse-themes.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,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declare const eurostatDataframeDescribe: import("@cyanheads/mcp-ts-core")
|
|
|
34
34
|
readonly code: JsonRpcErrorCode.NotFound;
|
|
35
35
|
readonly when: "The canvas_id is unknown or its lifetime has elapsed.";
|
|
36
36
|
readonly recovery: "Re-run eurostat_query_dataset or eurostat_download_dataset without canvas_id and use the canvasId it returns; eurostat_get_dimension_values stages onto that canvas but never starts one.";
|
|
37
|
-
readonly thrownBy: "service";
|
|
38
37
|
}], {
|
|
39
38
|
readonly notice: z.ZodOptional<z.ZodString>;
|
|
40
39
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eurostat-dataframe-describe.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/eurostat-dataframe-describe.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGjE,eAAO,MAAM,yBAAyB
|
|
1
|
+
{"version":3,"file":"eurostat-dataframe-describe.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/eurostat-dataframe-describe.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGjE,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8IpC,CAAC"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { tool, z } from '@cyanheads/mcp-ts-core';
|
|
6
6
|
import { CanvasIdSchema } from '@cyanheads/mcp-ts-core/canvas';
|
|
7
7
|
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
8
|
-
import { acquireCanvas, getCanvas } from '../../../services/canvas-accessor.js';
|
|
8
|
+
import { acquireCanvas, getCanvas, isCanvasFailure } from '../../../services/canvas-accessor.js';
|
|
9
9
|
export const eurostatDataframeDescribe = tool('eurostat_dataframe_describe', {
|
|
10
10
|
title: 'Describe Eurostat Dataframes',
|
|
11
11
|
description: 'List the tables staged on a Eurostat dataframe canvas, with their row counts and column names and types. Call this before eurostat_dataframe_query to learn the table and column names to write SQL against. The canvas_id comes from a eurostat_query_dataset or eurostat_download_dataset response that reported a staged table. Three tools stage tables, and they write different columns, so read the columns reported here rather than assuming. The two observation stagers keep every column flat: eurostat_query_dataset gives each dimension a code column named after the dimension (e.g. "geo") plus a label companion (e.g. "geo_label"); eurostat_download_dataset gives code columns only — the bulk endpoint carries no labels — plus a "time" column. Both write the same five measure columns — obs_value, obs_flag, obs_flag_label, conf_status, conf_status_label — carrying the same codes for the same observation, so their tables join on dimension codes and time and compare like with like. A table staged from a DS-* dataset (Comext detailed trade, PRODCOM) adds obs_value_text, holding a value Eurostat published as text, such as a PRODCOM quantity unit. eurostat_get_dimension_values, given a canvas_id, stages one dimension\'s value list as two columns, code and label, which labels a download\'s code column through a join (e.g. d.geo = g.code).',
|
|
@@ -62,16 +62,26 @@ export const eurostatDataframeDescribe = tool('eurostat_dataframe_describe', {
|
|
|
62
62
|
code: JsonRpcErrorCode.NotFound,
|
|
63
63
|
when: 'The canvas_id is unknown or its lifetime has elapsed.',
|
|
64
64
|
recovery: 'Re-run eurostat_query_dataset or eurostat_download_dataset without canvas_id and use the canvasId it returns; eurostat_get_dimension_values stages onto that canvas but never starts one.',
|
|
65
|
-
thrownBy: 'service',
|
|
66
65
|
},
|
|
67
66
|
],
|
|
68
67
|
async handler(input, ctx) {
|
|
69
68
|
const canvas = getCanvas();
|
|
70
69
|
if (!canvas) {
|
|
71
|
-
throw ctx.fail('canvas_disabled'
|
|
70
|
+
throw ctx.fail('canvas_disabled');
|
|
72
71
|
}
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Re-thrown so the declared recovery replaces the canvas service's generic one. A
|
|
74
|
+
* canvas can also expire between the acquire and the describe, so both calls go
|
|
75
|
+
* through the same mapping.
|
|
76
|
+
*/
|
|
77
|
+
const asDeclared = (err) => {
|
|
78
|
+
if (isCanvasFailure(err, 'canvas_not_found')) {
|
|
79
|
+
throw ctx.fail('canvas_not_found', err.message, { canvasId: input.canvas_id }, { cause: err });
|
|
80
|
+
}
|
|
81
|
+
throw err;
|
|
82
|
+
};
|
|
83
|
+
const instance = await acquireCanvas(canvas, input.canvas_id, ctx).catch(asDeclared);
|
|
84
|
+
const tables = await instance.describe().catch(asDeclared);
|
|
75
85
|
ctx.log.info('Described canvas', { canvasId: instance.canvasId, tableCount: tables.length });
|
|
76
86
|
if (tables.length === 0) {
|
|
77
87
|
ctx.enrich.notice(`Canvas ${instance.canvasId} holds no tables. Staged tables expire on their own schedule — re-run the tool that staged the data to stage it again: eurostat_query_dataset, eurostat_download_dataset, or eurostat_get_dimension_values with this canvas_id.`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eurostat-dataframe-describe.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/eurostat-dataframe-describe.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"eurostat-dataframe-describe.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/eurostat-dataframe-describe.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,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M,EAAE,CAAC,MAAM,EAAE,EAAE;QACjB,MAAM,KAAK,GAAa;YACtB,cAAc,MAAM,CAAC,QAAQ,IAAI;YACjC,gBAAgB,MAAM,CAAC,SAAS,kBAAkB,MAAM,CAAC,MAAM,CAAC,MAAM,IAAI;SAC3E,CAAC;QACF,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClC,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,qBAAqB,KAAK,CAAC,SAAS,EAAE,CAAC;YAC3F,KAAK,CAAC,IAAI,CAAC,QAAQ,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC;YACnD,KAAK,CAAC,IAAI,CAAC,aAAa,KAAK,CAAC,QAAQ,GAAG,MAAM,EAAE,CAAC,CAAC;YACnD,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;gBAChC,KAAK,CAAC,IAAI,CAAC,OAAO,GAAG,CAAC,IAAI,MAAM,GAAG,CAAC,IAAI,eAAe,GAAG,CAAC,QAAQ,GAAG,CAAC,CAAC;YAC1E,CAAC;YACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACjB,CAAC;QACD,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,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Tool for removing one staged table from a Eurostat DataCanvas.
|
|
3
|
+
* @module mcp-server/tools/definitions/eurostat-dataframe-drop.tool
|
|
4
|
+
*/
|
|
5
|
+
import { z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
7
|
+
export declare const eurostatDataframeDrop: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
|
|
8
|
+
canvas_id: z.ZodString;
|
|
9
|
+
table_name: z.ZodString;
|
|
10
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
11
|
+
canvasId: z.ZodString;
|
|
12
|
+
tableName: z.ZodString;
|
|
13
|
+
dropped: z.ZodBoolean;
|
|
14
|
+
expiresAt: z.ZodString;
|
|
15
|
+
}, z.core.$strip>, readonly [{
|
|
16
|
+
readonly reason: "canvas_disabled";
|
|
17
|
+
readonly code: JsonRpcErrorCode.ServiceUnavailable;
|
|
18
|
+
readonly when: "This deployment runs without a dataframe canvas, so there are no staged tables to drop.";
|
|
19
|
+
readonly retryable: false;
|
|
20
|
+
readonly recovery: "Nothing is staged without a dataframe canvas, so there is nothing to drop; eurostat_query_dataset answers inline with narrower dimension filters.";
|
|
21
|
+
}, {
|
|
22
|
+
readonly reason: "canvas_not_found";
|
|
23
|
+
readonly code: JsonRpcErrorCode.NotFound;
|
|
24
|
+
readonly when: "The canvas_id is unknown or its lifetime has elapsed.";
|
|
25
|
+
readonly recovery: "An expired canvas has already released every table it held, so nothing is left to drop; otherwise copy the canvasId exactly as eurostat_query_dataset, eurostat_download_dataset, or eurostat_get_dimension_values returned it.";
|
|
26
|
+
}, {
|
|
27
|
+
readonly reason: "identifier_reserved";
|
|
28
|
+
readonly code: JsonRpcErrorCode.ValidationError;
|
|
29
|
+
readonly when: "The table_name is a bare SQL keyword (e.g. \"select\"), which no staged table can carry.";
|
|
30
|
+
readonly recovery: "Call eurostat_dataframe_describe and copy a table name exactly as it is listed.";
|
|
31
|
+
}], {
|
|
32
|
+
readonly notice: z.ZodOptional<z.ZodString>;
|
|
33
|
+
}>;
|
|
34
|
+
//# sourceMappingURL=eurostat-dataframe-drop.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eurostat-dataframe-drop.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/eurostat-dataframe-drop.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAY,MAAM,+BAA+B,CAAC;AAG3E,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;EAsIhC,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Tool for removing one staged table from a Eurostat DataCanvas.
|
|
3
|
+
* @module mcp-server/tools/definitions/eurostat-dataframe-drop.tool
|
|
4
|
+
*/
|
|
5
|
+
import { tool, z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
import { CANVAS_IDENTIFIER_REGEX, CanvasIdSchema } from '@cyanheads/mcp-ts-core/canvas';
|
|
7
|
+
import { JsonRpcErrorCode, McpError } from '@cyanheads/mcp-ts-core/errors';
|
|
8
|
+
import { acquireCanvas, getCanvas } from '../../../services/canvas-accessor.js';
|
|
9
|
+
export const eurostatDataframeDrop = tool('eurostat_dataframe_drop', {
|
|
10
|
+
title: 'Drop Eurostat Dataframe',
|
|
11
|
+
description: 'Remove one table from a Eurostat dataframe canvas, leaving the canvas and every other table on it in place — to free the memory a large eurostat_download_dataset table holds once its analysis is done, or to discard an intermediate result. Pass the table name exactly as eurostat_dataframe_describe lists it, case included. A drop cannot be undone: re-run the tool that staged the table to stage it again. A name with nothing staged under it — never staged, already dropped, or expired — returns dropped: false rather than an error, so repeating a drop is safe.',
|
|
12
|
+
annotations: {
|
|
13
|
+
readOnlyHint: false,
|
|
14
|
+
destructiveHint: true,
|
|
15
|
+
idempotentHint: true,
|
|
16
|
+
openWorldHint: false,
|
|
17
|
+
},
|
|
18
|
+
input: z.object({
|
|
19
|
+
canvas_id: CanvasIdSchema.describe('Canvas identifier returned as canvasId by eurostat_query_dataset, eurostat_download_dataset, or eurostat_get_dimension_values. Identifies the workspace holding the table to drop.'),
|
|
20
|
+
table_name: z
|
|
21
|
+
.string()
|
|
22
|
+
.regex(CANVAS_IDENTIFIER_REGEX, 'Expected a table name exactly as eurostat_dataframe_describe lists it: letters, digits, and underscores, starting with a letter or underscore, at most 63 characters.')
|
|
23
|
+
.describe('Name of the table to drop, exactly as eurostat_dataframe_describe lists it, case included (e.g. "df_a1b2c3d4"): letters, digits, and underscores.'),
|
|
24
|
+
}),
|
|
25
|
+
output: z.object({
|
|
26
|
+
canvasId: z.string().describe('Canvas identifier the drop ran against.'),
|
|
27
|
+
tableName: z.string().describe('Table name the drop was asked to remove, as sent.'),
|
|
28
|
+
dropped: z
|
|
29
|
+
.boolean()
|
|
30
|
+
.describe('True when a table by that name was staged and is now removed. False when nothing by that name was staged at call time — never staged, already dropped, or expired — so the canvas is unchanged.'),
|
|
31
|
+
expiresAt: z
|
|
32
|
+
.string()
|
|
33
|
+
.describe('ISO 8601 timestamp when the canvas expires. The drop slid it forward; the canvas and its other tables remain.'),
|
|
34
|
+
}),
|
|
35
|
+
enrichment: {
|
|
36
|
+
notice: z
|
|
37
|
+
.string()
|
|
38
|
+
.optional()
|
|
39
|
+
.describe('Guidance when nothing by that name was staged, so nothing was dropped. Omitted when a table was dropped.'),
|
|
40
|
+
},
|
|
41
|
+
errors: [
|
|
42
|
+
{
|
|
43
|
+
reason: 'canvas_disabled',
|
|
44
|
+
code: JsonRpcErrorCode.ServiceUnavailable,
|
|
45
|
+
when: 'This deployment runs without a dataframe canvas, so there are no staged tables to drop.',
|
|
46
|
+
retryable: false,
|
|
47
|
+
recovery: 'Nothing is staged without a dataframe canvas, so there is nothing to drop; eurostat_query_dataset answers inline with narrower dimension filters.',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
reason: 'canvas_not_found',
|
|
51
|
+
code: JsonRpcErrorCode.NotFound,
|
|
52
|
+
when: 'The canvas_id is unknown or its lifetime has elapsed.',
|
|
53
|
+
recovery: 'An expired canvas has already released every table it held, so nothing is left to drop; otherwise copy the canvasId exactly as eurostat_query_dataset, eurostat_download_dataset, or eurostat_get_dimension_values returned it.',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
reason: 'identifier_reserved',
|
|
57
|
+
code: JsonRpcErrorCode.ValidationError,
|
|
58
|
+
when: 'The table_name is a bare SQL keyword (e.g. "select"), which no staged table can carry.',
|
|
59
|
+
recovery: 'Call eurostat_dataframe_describe and copy a table name exactly as it is listed.',
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
async handler(input, ctx) {
|
|
63
|
+
const canvas = getCanvas();
|
|
64
|
+
if (!canvas) {
|
|
65
|
+
throw ctx.fail('canvas_disabled');
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The canvas words both rejections for staging — re-run the tool that
|
|
69
|
+
* staged the data, choose another table name — which for a drop restores
|
|
70
|
+
* what was meant to go. Re-thrown through `ctx.fail`, they carry this tool's
|
|
71
|
+
* declared recovery instead.
|
|
72
|
+
*/
|
|
73
|
+
const asDropFailure = (err) => {
|
|
74
|
+
if (err instanceof McpError && err.data?.reason === 'canvas_not_found') {
|
|
75
|
+
throw ctx.fail('canvas_not_found', err.message, { canvasId: input.canvas_id });
|
|
76
|
+
}
|
|
77
|
+
if (err instanceof McpError && err.data?.reason === 'identifier_reserved') {
|
|
78
|
+
throw ctx.fail('identifier_reserved', `"${input.table_name}" is a reserved SQL keyword, so no staged table carries that name.`, { tableName: input.table_name });
|
|
79
|
+
}
|
|
80
|
+
throw err;
|
|
81
|
+
};
|
|
82
|
+
const instance = await acquireCanvas(canvas, input.canvas_id, ctx).catch(asDropFailure);
|
|
83
|
+
const dropped = await instance.drop(input.table_name).catch(asDropFailure);
|
|
84
|
+
ctx.log.info('Canvas table drop', {
|
|
85
|
+
canvasId: instance.canvasId,
|
|
86
|
+
tableName: input.table_name,
|
|
87
|
+
dropped,
|
|
88
|
+
});
|
|
89
|
+
if (!dropped) {
|
|
90
|
+
ctx.enrich.notice(`Canvas ${instance.canvasId} holds no table named "${input.table_name}", so nothing was dropped. Names match exactly, case included — eurostat_dataframe_describe lists what is staged.`);
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
canvasId: instance.canvasId,
|
|
94
|
+
tableName: input.table_name,
|
|
95
|
+
dropped,
|
|
96
|
+
expiresAt: instance.expiresAt,
|
|
97
|
+
};
|
|
98
|
+
},
|
|
99
|
+
format: (result) => [
|
|
100
|
+
{
|
|
101
|
+
type: 'text',
|
|
102
|
+
text: [
|
|
103
|
+
`# Drop \`${result.tableName}\` (canvas \`${result.canvasId}\`)`,
|
|
104
|
+
`**Dropped:** ${result.dropped} — ${result.dropped
|
|
105
|
+
? 'removed; the canvas and its other tables are unchanged'
|
|
106
|
+
: 'nothing by that name was staged'}`,
|
|
107
|
+
`**Canvas expires:** ${result.expiresAt}`,
|
|
108
|
+
].join('\n'),
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
});
|
|
112
|
+
//# sourceMappingURL=eurostat-dataframe-drop.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eurostat-dataframe-drop.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/eurostat-dataframe-drop.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACxF,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAEzE,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC,yBAAyB,EAAE;IACnE,KAAK,EAAE,yBAAyB;IAChC,WAAW,EACT,kjBAAkjB;IACpjB,WAAW,EAAE;QACX,YAAY,EAAE,KAAK;QACnB,eAAe,EAAE,IAAI;QACrB,cAAc,EAAE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Q,0BAA0B,KAAK,CAAC,UAAU,mHAAmH,CACzL,CAAC;QACJ,CAAC;QAED,OAAO;YACL,QAAQ,EAAE,QAAQ,CAAC,QAAQ;YAC3B,SAAS,EAAE,KAAK,CAAC,UAAU;YAC3B,OAAO;YACP,SAAS,EAAE,QAAQ,CAAC,SAAS;SAC9B,CAAC;IACJ,CAAC;IAED,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC;QAClB;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE;gBACJ,YAAY,MAAM,CAAC,SAAS,gBAAgB,MAAM,CAAC,QAAQ,KAAK;gBAChE,gBAAgB,MAAM,CAAC,OAAO,MAC5B,MAAM,CAAC,OAAO;oBACZ,CAAC,CAAC,wDAAwD;oBAC1D,CAAC,CAAC,iCACN,EAAE;gBACF,uBAAuB,MAAM,CAAC,SAAS,EAAE;aAC1C,CAAC,IAAI,CAAC,IAAI,CAAC;SACb;KACF;CACF,CAAC,CAAC"}
|
|
@@ -25,12 +25,10 @@ export declare const eurostatDataframeQuery: import("@cyanheads/mcp-ts-core").To
|
|
|
25
25
|
readonly code: JsonRpcErrorCode.NotFound;
|
|
26
26
|
readonly when: "The canvas_id is unknown or its lifetime has elapsed.";
|
|
27
27
|
readonly recovery: "Re-run eurostat_query_dataset or eurostat_download_dataset without canvas_id and use the canvasId it returns; eurostat_get_dimension_values stages onto that canvas but never starts one.";
|
|
28
|
-
readonly thrownBy: "service";
|
|
29
28
|
}, {
|
|
30
29
|
readonly reason: "missing_table";
|
|
31
30
|
readonly code: JsonRpcErrorCode.NotFound;
|
|
32
31
|
readonly when: "The SQL names a table that is not staged on this canvas, or that has expired.";
|
|
33
32
|
readonly recovery: "Call eurostat_dataframe_describe for the staged table names, or re-run the tool that staged them (eurostat_query_dataset, eurostat_download_dataset, or eurostat_get_dimension_values with canvas_id).";
|
|
34
|
-
readonly thrownBy: "service";
|
|
35
33
|
}], undefined>;
|
|
36
34
|
//# sourceMappingURL=eurostat-dataframe-query.tool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eurostat-dataframe-query.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/eurostat-dataframe-query.tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGjE,eAAO,MAAM,sBAAsB
|
|
1
|
+
{"version":3,"file":"eurostat-dataframe-query.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/eurostat-dataframe-query.tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGjE,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;cAuIjC,CAAC"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { tool, z } from '@cyanheads/mcp-ts-core';
|
|
7
7
|
import { CanvasIdSchema } from '@cyanheads/mcp-ts-core/canvas';
|
|
8
8
|
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
9
|
-
import { acquireCanvas, getCanvas } from '../../../services/canvas-accessor.js';
|
|
9
|
+
import { acquireCanvas, getCanvas, isCanvasFailure } from '../../../services/canvas-accessor.js';
|
|
10
10
|
export const eurostatDataframeQuery = tool('eurostat_dataframe_query', {
|
|
11
11
|
title: 'Query Eurostat Dataframes',
|
|
12
12
|
description: 'Run a read-only SQL SELECT against tables staged on a Eurostat dataframe canvas — the way to reach observations past the 5,000-row inline cap of eurostat_query_dataset and past the inline preview of a eurostat_download_dataset bulk download, and to aggregate, group, or join across staged tables without re-fetching from Eurostat. Call eurostat_dataframe_describe first for the table and column names, which differ between the tools that stage them. Only a single SELECT statement runs: statement chaining, non-SELECT verbs, and functions that read files or external data are rejected. Columns are flat — every dimension is a code column named after the dimension, the measure is obs_value, the observation flag is obs_flag / obs_flag_label and the confidentiality marker is conf_status / conf_status_label; a "_label" companion per dimension exists only on tables eurostat_query_dataset staged. Both observation stagers write the same five measure columns with the same codes, so join their tables on dimension codes and time and compare obs_flag or conf_status across them directly; a DS-* table also carries obs_value_text, a value published as text (e.g. a PRODCOM unit "KG"). A value list eurostat_get_dimension_values staged has two columns, code and label: join it to the code column of a download (e.g. JOIN df_x g ON d.geo = g.code) to label that table.',
|
|
@@ -44,22 +44,34 @@ export const eurostatDataframeQuery = tool('eurostat_dataframe_query', {
|
|
|
44
44
|
code: JsonRpcErrorCode.NotFound,
|
|
45
45
|
when: 'The canvas_id is unknown or its lifetime has elapsed.',
|
|
46
46
|
recovery: 'Re-run eurostat_query_dataset or eurostat_download_dataset without canvas_id and use the canvasId it returns; eurostat_get_dimension_values stages onto that canvas but never starts one.',
|
|
47
|
-
thrownBy: 'service',
|
|
48
47
|
},
|
|
49
48
|
{
|
|
50
49
|
reason: 'missing_table',
|
|
51
50
|
code: JsonRpcErrorCode.NotFound,
|
|
52
51
|
when: 'The SQL names a table that is not staged on this canvas, or that has expired.',
|
|
53
52
|
recovery: 'Call eurostat_dataframe_describe for the staged table names, or re-run the tool that staged them (eurostat_query_dataset, eurostat_download_dataset, or eurostat_get_dimension_values with canvas_id).',
|
|
54
|
-
thrownBy: 'service',
|
|
55
53
|
},
|
|
56
54
|
],
|
|
57
55
|
async handler(input, ctx) {
|
|
58
56
|
const canvas = getCanvas();
|
|
59
57
|
if (!canvas) {
|
|
60
|
-
throw ctx.fail('canvas_disabled'
|
|
58
|
+
throw ctx.fail('canvas_disabled');
|
|
61
59
|
}
|
|
62
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Both are re-thrown so the declared recovery replaces the canvas service's
|
|
62
|
+
* generic one. A canvas can also expire between the acquire and the query,
|
|
63
|
+
* so both calls go through the same mapping.
|
|
64
|
+
*/
|
|
65
|
+
const asDeclared = (err) => {
|
|
66
|
+
if (isCanvasFailure(err, 'canvas_not_found')) {
|
|
67
|
+
throw ctx.fail('canvas_not_found', err.message, { canvasId: input.canvas_id }, { cause: err });
|
|
68
|
+
}
|
|
69
|
+
if (isCanvasFailure(err, 'missing_table')) {
|
|
70
|
+
throw ctx.fail('missing_table', err.message, { tableName: err.data?.tableName }, { cause: err });
|
|
71
|
+
}
|
|
72
|
+
throw err;
|
|
73
|
+
};
|
|
74
|
+
const instance = await acquireCanvas(canvas, input.canvas_id, ctx).catch(asDeclared);
|
|
63
75
|
/**
|
|
64
76
|
* The SQL is not sanitized here on purpose. The canvas gate rejects
|
|
65
77
|
* anything that is not a single SELECT — statement count, statement type,
|
|
@@ -68,7 +80,7 @@ export const eurostatDataframeQuery = tool('eurostat_dataframe_query', {
|
|
|
68
80
|
* second, weaker string filter in front of it would only shadow those
|
|
69
81
|
* reasons with a vaguer message.
|
|
70
82
|
*/
|
|
71
|
-
const result = await instance.query(input.sql, { signal: ctx.signal });
|
|
83
|
+
const result = await instance.query(input.sql, { signal: ctx.signal }).catch(asDeclared);
|
|
72
84
|
ctx.log.info('Canvas query complete', {
|
|
73
85
|
canvasId: instance.canvasId,
|
|
74
86
|
rowCount: result.rowCount,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eurostat-dataframe-query.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/eurostat-dataframe-query.tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"eurostat-dataframe-query.tool.js","sourceRoot":"","sources":["../../../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AAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAC3F,CAAC;QACJ,CAAC;QACD,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpD,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -73,7 +73,7 @@ export declare const eurostatDownloadDataset: import("@cyanheads/mcp-ts-core").T
|
|
|
73
73
|
}, {
|
|
74
74
|
readonly reason: "upstream_fault";
|
|
75
75
|
readonly code: JsonRpcErrorCode.ServiceUnavailable;
|
|
76
|
-
readonly when: "The SDMX endpoint returned a fault this server does not model, or a body that is not a TSV table.";
|
|
76
|
+
readonly when: "The SDMX data endpoint returned a fault this server does not model, or a body that is not a TSV table; or the data endpoint — or, for a filtered download, the structure endpoint — answered HTTP 5xx or could not be reached on every retry, which the error marks retryable.";
|
|
77
77
|
readonly recovery: "Retry in a few minutes, or narrow the request with dimension filters.";
|
|
78
78
|
readonly thrownBy: "service";
|
|
79
79
|
}, {
|
|
@@ -81,7 +81,6 @@ export declare const eurostatDownloadDataset: import("@cyanheads/mcp-ts-core").T
|
|
|
81
81
|
readonly code: JsonRpcErrorCode.NotFound;
|
|
82
82
|
readonly when: "A canvas_id was supplied for staging but is unknown or its lifetime has elapsed.";
|
|
83
83
|
readonly recovery: "Omit canvas_id so the download starts a fresh canvas and returns its canvasId.";
|
|
84
|
-
readonly thrownBy: "service";
|
|
85
84
|
}], {
|
|
86
85
|
readonly totalCount: z.ZodNumber;
|
|
87
86
|
readonly appliedQuery: z.ZodObject<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eurostat-download-dataset.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/eurostat-download-dataset.tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAiB,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"eurostat-download-dataset.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/eurostat-download-dataset.tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAiB,MAAM,+BAA+B,CAAC;AA4ChF,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAydlC,CAAC"}
|