@cyanheads/eurostat-mcp-server 0.8.0 → 0.9.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 +25 -19
- package/CLAUDE.md +25 -19
- package/Dockerfile +93 -46
- package/README.md +34 -35
- package/changelog/0.8.x/0.8.1.md +11 -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 +44 -4
- package/dist/index.js.map +1 -1
- package/dist/mcp-server/tools/definitions/eurostat-dataframe-describe.tool.js +1 -1
- 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.js +1 -1
- package/dist/mcp-server/tools/definitions/eurostat-dataframe-query.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/eurostat-download-dataset.tool.js +1 -1
- package/dist/mcp-server/tools/definitions/eurostat-download-dataset.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/eurostat-query-dataset.tool.js +2 -2
- package/dist/mcp-server/tools/definitions/eurostat-query-dataset.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/services/canvas-accessor.d.ts +10 -6
- package/dist/services/canvas-accessor.d.ts.map +1 -1
- package/dist/services/canvas-accessor.js +14 -10
- package/dist/services/canvas-accessor.js.map +1 -1
- package/package.json +10 -9
- package/server.json +26 -26
package/AGENTS.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# Agent Protocol
|
|
2
2
|
|
|
3
3
|
**Server:** @cyanheads/eurostat-mcp-server
|
|
4
|
-
**Version:** 0.
|
|
5
|
-
**Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core) `^0.13.
|
|
4
|
+
**Version:** 0.9.0
|
|
5
|
+
**Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core) `^0.13.11`
|
|
6
6
|
**Engines:** Bun ≥1.4.0, Node ≥24.0.0
|
|
7
|
-
**MCP SDK:** `@modelcontextprotocol/server` `^2.
|
|
7
|
+
**MCP SDK:** `@modelcontextprotocol/server` `^2.2.0`
|
|
8
8
|
**Zod:** `^4.6.5`
|
|
9
9
|
|
|
10
10
|
> **Read the framework docs first:** `node_modules/@cyanheads/mcp-ts-core/CLAUDE.md` contains the full API reference — builders, Context, error codes, exports, patterns. This file covers server-specific conventions only.
|
|
@@ -37,6 +37,7 @@ Tailor suggestions to what's actually missing or stale — don't recite the full
|
|
|
37
37
|
- **Use `ctx.state`** for tenant-scoped storage. Never access persistence directly.
|
|
38
38
|
- **Need input the caller didn't supply?** `return ctx.requestInput(...)` and read `ctx.inputs` when the handler is re-entered. Never `await` for user input mid-handler.
|
|
39
39
|
- **Secrets in env vars only** — never hardcoded.
|
|
40
|
+
- **Cut noise.** Add only what earns its place: no speculative generality, no guards for states the framework already prevents (Zod-validated params, classified errors), no abstraction until a third caller proves it, no option nothing sets.
|
|
40
41
|
- **Close the loop on issues.** When implementing work tracked by a GitHub issue, comment on the issue with what landed and close it. Do both — a comment without a close leaves stale issues open; a close without a comment leaves no record of what shipped. The comment is for future readers — state the concrete changes, not the conversation that produced them.
|
|
41
42
|
|
|
42
43
|
---
|
|
@@ -53,7 +54,7 @@ export const searchItems = tool('search_items', {
|
|
|
53
54
|
annotations: { readOnlyHint: true },
|
|
54
55
|
input: z.object({
|
|
55
56
|
query: z.string().describe('Search terms'),
|
|
56
|
-
limit: z.number().default(10).describe('Max results'),
|
|
57
|
+
limit: z.number().int().min(1).max(100).default(10).describe('Max results (1–100)'),
|
|
57
58
|
}),
|
|
58
59
|
output: z.object({
|
|
59
60
|
items: z.array(z.object({
|
|
@@ -141,7 +142,7 @@ export function getServerConfig() {
|
|
|
141
142
|
|
|
142
143
|
`parseEnvConfig` maps Zod schema paths → env var names so errors name the variable (`MY_API_KEY`) not the path (`apiKey`). Throws `ConfigurationError`, which the framework prints as a clean startup banner.
|
|
143
144
|
|
|
144
|
-
For env booleans use `z.stringbool()`, never `z.coerce.boolean()` — `Boolean("false")` is `true`, so a coerced flag can't be disabled through the environment. `z.stringbool()` parses `true/false/1/0/yes/no/on/off` and rejects anything else.
|
|
145
|
+
For env booleans use `z.stringbool()`, never `z.coerce.boolean()` — `Boolean("false")` is `true`, so a coerced flag can't be disabled through the environment. `z.stringbool()` parses `true/false/1/0/yes/no/on/off` and rejects anything else, so `=false` actually disables.
|
|
145
146
|
|
|
146
147
|
### Server identity and instructions
|
|
147
148
|
|
|
@@ -173,14 +174,15 @@ Handlers receive a unified `ctx` object. Key properties:
|
|
|
173
174
|
|
|
174
175
|
| Property | Description |
|
|
175
176
|
|:---------|:------------|
|
|
176
|
-
| `ctx.log` | Request-scoped logger — `.debug()`, `.info()`, `.notice()`, `.warning()`, `.error()`. Auto-correlates requestId, traceId, tenantId. Dual-sink: Pino and
|
|
177
|
-
| `ctx.state` | Tenant-scoped KV — `.get(key)`, `.set(key, value, { ttl? })`, `.delete(key)`, `.getMany(keys)`, `.list(prefix, { cursor, limit })`. Accepts any serializable value. |
|
|
178
|
-
| `ctx.requestInput` | Suspend and ask the caller for more input — `return ctx.requestInput({ inputRequests: { key: inputRequired.elicit({ message, requestedSchema }) } })`. Never returns; the handler is re-entered with the answers. |
|
|
179
|
-
| `ctx.inputs` |
|
|
177
|
+
| `ctx.log` | Request-scoped logger — `.debug()`, `.info()`, `.notice()`, `.warning()`, `.error()`. Auto-correlates requestId, traceId, tenantId. Dual-sink: Pino **and** `notifications/message` to the client, so treat it as client-visible. |
|
|
178
|
+
| `ctx.state` | Tenant-scoped KV — `.get(key)`, `.set(key, value, { ttl? })`, `.delete(key)`, `.getMany(keys)`, `.list(prefix, { cursor, limit })`. Accepts any JSON-serializable value; reads return its JSON form (a `Date` comes back as an ISO string). |
|
|
179
|
+
| `ctx.requestInput` | Suspend and ask the caller for more input — `return ctx.requestInput({ inputRequests: { key: inputRequired.elicit({ message, requestedSchema }) } })`. Never returns; the handler is re-entered with the answers. Always present. |
|
|
180
|
+
| `ctx.inputs` | The request's responses — `.accepted(key, schema)`, `.view(key)`, `.state()`, `.dropped` — limited to what the client declared (`elicitation` and its form/url modes, `sampling`, `roots`). Client-supplied: a consent gate trusts only a `ctx.state` record it stored when it asked, bound to the operation, caller, and target (see the `api-context` skill). |
|
|
181
|
+
| `ctx.clientCapabilities` | What the client declared for this request, `undefined` when no view exists. Decides whether to ask for optional context (e.g. roots); never a reason to skip a consent prompt. |
|
|
180
182
|
| `ctx.enrich` | Success-path agent context (empty-result notices, query echo, pagination totals) — `ctx.enrich(...)` or `.notice()` / `.total()` / `.echo()` / `.truncated()`. Reaches `structuredContent` and `content[]`; lands only when the definition declares an `enrichment` block (no-op otherwise). |
|
|
181
183
|
| `ctx.content` | Non-text content blocks — `.image(data, mimeType)`, `.audio(data, mimeType)`, or `ctx.content(block)` for a raw block. Prepended to `content[]` after `format()`; never enters `structuredContent`. |
|
|
182
184
|
| `ctx.signal` | `AbortSignal` for cancellation. |
|
|
183
|
-
| `ctx.requestId` |
|
|
185
|
+
| `ctx.requestId` | Request ID — the one every log record of the call carries and its error envelope returns as `data.requestId`. |
|
|
184
186
|
| `ctx.tenantId` | Tenant ID from JWT; `'default'` for stdio or HTTP with auth off. |
|
|
185
187
|
|
|
186
188
|
---
|
|
@@ -189,7 +191,7 @@ Handlers receive a unified `ctx` object. Key properties:
|
|
|
189
191
|
|
|
190
192
|
Handlers throw — the framework catches, classifies, and formats.
|
|
191
193
|
|
|
192
|
-
**Recommended: typed error contract.** Declare `errors: [{ reason, code, when, recovery, retryable?, severity?, thrownBy? }]` on `tool()` / `resource()` to receive `ctx.fail(reason, …)` typed against the reason union. TypeScript catches typos at compile time, `data.reason` is auto-populated for observability, linter enforces conformance against the handler body. `recovery` is required (≥ 5 words, lint-validated) — the single source of truth for the agent's next move.
|
|
194
|
+
**Recommended: typed error contract.** Declare `errors: [{ reason, code, when, recovery, retryable?, severity?, thrownBy? }]` on `tool()` / `resource()` to receive `ctx.fail(reason, …)` typed against the reason union. TypeScript catches typos at compile time, `data.reason` is auto-populated for observability, linter enforces conformance against the handler body. `recovery` is required (≥ 5 words, lint-validated) — the single source of truth for the agent's next move. The framework puts it on the wire whenever a failure carrying that `reason` arrives without a hint — a bare `ctx.fail('reason')` or a service throw with `data: { reason }` — as `data.recovery.hint`, mirrored into `content[]` text unless the message already contains it verbatim; override with an explicit `{ recovery: { hint: '...' } }` when dynamic runtime context matters. Every error envelope also carries `data.requestId`, the id the server's log records for that call carry, and `content[]` closes with `(reason … · request <id>)`. Mark an entry the service layer throws with `thrownBy: 'service'` so `error-contract-unthrown` skips it — lint-only metadata, nothing at runtime reads it. Baseline codes (`InternalError`, `ServiceUnavailable`, `Timeout`, `ValidationError`, `SerializationError`, `RequestCancelled`) bubble freely and don't need declaring.
|
|
193
195
|
|
|
194
196
|
```ts
|
|
195
197
|
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
@@ -201,7 +203,7 @@ errors: [
|
|
|
201
203
|
],
|
|
202
204
|
async handler(input, ctx) {
|
|
203
205
|
const item = await db.find(input.id);
|
|
204
|
-
if (!item) throw ctx.fail('no_match', `No item ${input.id}
|
|
206
|
+
if (!item) throw ctx.fail('no_match', `No item ${input.id}`);
|
|
205
207
|
return item;
|
|
206
208
|
}
|
|
207
209
|
```
|
|
@@ -222,7 +224,7 @@ throw new Error('Invalid query format'); // → ValidationError
|
|
|
222
224
|
|
|
223
225
|
// McpError — when no factory exists for the code
|
|
224
226
|
import { McpError, JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
225
|
-
throw new McpError(JsonRpcErrorCode.
|
|
227
|
+
throw new McpError(JsonRpcErrorCode.InitializationFailed, 'Connection failed', { pool: 'primary' });
|
|
226
228
|
```
|
|
227
229
|
|
|
228
230
|
See framework CLAUDE.md and the `api-errors` skill for the full auto-classification table, all available factories, and the contract reference.
|
|
@@ -306,12 +308,16 @@ Available skills:
|
|
|
306
308
|
| `api-telemetry` | OTel catalog: spans, metrics, completion logs, env config, cardinality rules |
|
|
307
309
|
| `api-workers` | Cloudflare Workers runtime |
|
|
308
310
|
|
|
311
|
+
**Chaining skills into pipelines.** When the user wants a multi-phase effort — build this server out, QA-and-fix the surface, update-and-ship — *and you can spawn sub-agents*, `framework-skills/orchestrations/SKILL.md` sequences the task skills above into a gated pipeline with verification at each step. Read it to drive the run. Optional: skip it if you can't orchestrate sub-agents, and ignore it entirely if you were *spawned* as one — you've already been scoped to a single phase.
|
|
312
|
+
|
|
309
313
|
When you complete a skill's checklist, check the boxes and add a completion timestamp at the end (e.g., `Completed: 2026-03-11`).
|
|
310
314
|
|
|
311
315
|
---
|
|
312
316
|
|
|
313
317
|
## Commands
|
|
314
318
|
|
|
319
|
+
**Runtime:** Scripts use Bun's native TypeScript execution — `bun run <cmd>` is the standard invocation. `npm run <cmd>` also works (npm delegates to bun).
|
|
320
|
+
|
|
315
321
|
| Command | Purpose |
|
|
316
322
|
|:--------|:--------|
|
|
317
323
|
| `bun run build` | Compile TypeScript |
|
|
@@ -321,16 +327,16 @@ When you complete a skill's checklist, check the boxes and add a completion time
|
|
|
321
327
|
| `bun run audit:fix` | `bun audit fix` — upgrade vulnerable packages to the lowest safe version within existing ranges (`--dry-run` previews, `--latest` rewrites ranges). First response when `devcheck` flags a transitive advisory; then `bun update <name>`, then `bun dedupe` |
|
|
322
328
|
| `bun run audit:refresh` | Delete `bun.lock` and reinstall. Last resort after `audit:fix`, `bun update <name>`, and `bun dedupe` — re-resolves every ranged dep (the framework pin included) and rewrites the lockfile as `lockfileVersion: 2` |
|
|
323
329
|
| `bun run tree` | Generate directory structure doc |
|
|
324
|
-
| `bun run format` | Auto-fix formatting |
|
|
325
|
-
| `bun run format:unsafe` |
|
|
326
|
-
| `bun run test` | Run tests |
|
|
327
|
-
| `bun run lint:mcp` |
|
|
328
|
-
| `bun run lint:packaging` |
|
|
330
|
+
| `bun run format` | Auto-fix formatting (safe fixes only) |
|
|
331
|
+
| `bun run format:unsafe` | Also apply Biome's unsafe autofixes — review the diff; they can change behavior |
|
|
332
|
+
| `bun run test` | Run tests (Vitest — use `bun run test`, not `bun test`) |
|
|
333
|
+
| `bun run lint:mcp` | Run the MCP definition linter standalone (rule catalog: `api-linter` skill) |
|
|
334
|
+
| `bun run lint:packaging` | Packaging surface checks — `server.json`/`manifest.json` env-var parity (run by devcheck) |
|
|
329
335
|
| `bun run list-skills` | List skills in `framework-skills/` with name + description |
|
|
330
336
|
| `bun run release:github` | Create GitHub Release from the latest annotated tag (attach `.mcpb`, enforce title format) |
|
|
331
337
|
| `bun run bundle` | Build and pack as `dist/eurostat-mcp-server.mcpb` for one-click Claude Desktop install |
|
|
332
338
|
| `bun run changelog:build` | Regenerate `CHANGELOG.md` from `changelog/*.md` |
|
|
333
|
-
| `bun run changelog:check` | Verify `CHANGELOG.md` is in sync
|
|
339
|
+
| `bun run changelog:check` | Verify `CHANGELOG.md` is in sync (used by devcheck) |
|
|
334
340
|
| `bun run start:stdio` | Production mode (stdio) |
|
|
335
341
|
| `bun run start:http` | Production mode (HTTP) |
|
|
336
342
|
|
package/CLAUDE.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# Agent Protocol
|
|
2
2
|
|
|
3
3
|
**Server:** @cyanheads/eurostat-mcp-server
|
|
4
|
-
**Version:** 0.
|
|
5
|
-
**Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core) `^0.13.
|
|
4
|
+
**Version:** 0.9.0
|
|
5
|
+
**Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core) `^0.13.11`
|
|
6
6
|
**Engines:** Bun ≥1.4.0, Node ≥24.0.0
|
|
7
|
-
**MCP SDK:** `@modelcontextprotocol/server` `^2.
|
|
7
|
+
**MCP SDK:** `@modelcontextprotocol/server` `^2.2.0`
|
|
8
8
|
**Zod:** `^4.6.5`
|
|
9
9
|
|
|
10
10
|
> **Read the framework docs first:** `node_modules/@cyanheads/mcp-ts-core/CLAUDE.md` contains the full API reference — builders, Context, error codes, exports, patterns. This file covers server-specific conventions only.
|
|
@@ -37,6 +37,7 @@ Tailor suggestions to what's actually missing or stale — don't recite the full
|
|
|
37
37
|
- **Use `ctx.state`** for tenant-scoped storage. Never access persistence directly.
|
|
38
38
|
- **Need input the caller didn't supply?** `return ctx.requestInput(...)` and read `ctx.inputs` when the handler is re-entered. Never `await` for user input mid-handler.
|
|
39
39
|
- **Secrets in env vars only** — never hardcoded.
|
|
40
|
+
- **Cut noise.** Add only what earns its place: no speculative generality, no guards for states the framework already prevents (Zod-validated params, classified errors), no abstraction until a third caller proves it, no option nothing sets.
|
|
40
41
|
- **Close the loop on issues.** When implementing work tracked by a GitHub issue, comment on the issue with what landed and close it. Do both — a comment without a close leaves stale issues open; a close without a comment leaves no record of what shipped. The comment is for future readers — state the concrete changes, not the conversation that produced them.
|
|
41
42
|
|
|
42
43
|
---
|
|
@@ -53,7 +54,7 @@ export const searchItems = tool('search_items', {
|
|
|
53
54
|
annotations: { readOnlyHint: true },
|
|
54
55
|
input: z.object({
|
|
55
56
|
query: z.string().describe('Search terms'),
|
|
56
|
-
limit: z.number().default(10).describe('Max results'),
|
|
57
|
+
limit: z.number().int().min(1).max(100).default(10).describe('Max results (1–100)'),
|
|
57
58
|
}),
|
|
58
59
|
output: z.object({
|
|
59
60
|
items: z.array(z.object({
|
|
@@ -141,7 +142,7 @@ export function getServerConfig() {
|
|
|
141
142
|
|
|
142
143
|
`parseEnvConfig` maps Zod schema paths → env var names so errors name the variable (`MY_API_KEY`) not the path (`apiKey`). Throws `ConfigurationError`, which the framework prints as a clean startup banner.
|
|
143
144
|
|
|
144
|
-
For env booleans use `z.stringbool()`, never `z.coerce.boolean()` — `Boolean("false")` is `true`, so a coerced flag can't be disabled through the environment. `z.stringbool()` parses `true/false/1/0/yes/no/on/off` and rejects anything else.
|
|
145
|
+
For env booleans use `z.stringbool()`, never `z.coerce.boolean()` — `Boolean("false")` is `true`, so a coerced flag can't be disabled through the environment. `z.stringbool()` parses `true/false/1/0/yes/no/on/off` and rejects anything else, so `=false` actually disables.
|
|
145
146
|
|
|
146
147
|
### Server identity and instructions
|
|
147
148
|
|
|
@@ -173,14 +174,15 @@ Handlers receive a unified `ctx` object. Key properties:
|
|
|
173
174
|
|
|
174
175
|
| Property | Description |
|
|
175
176
|
|:---------|:------------|
|
|
176
|
-
| `ctx.log` | Request-scoped logger — `.debug()`, `.info()`, `.notice()`, `.warning()`, `.error()`. Auto-correlates requestId, traceId, tenantId. Dual-sink: Pino and
|
|
177
|
-
| `ctx.state` | Tenant-scoped KV — `.get(key)`, `.set(key, value, { ttl? })`, `.delete(key)`, `.getMany(keys)`, `.list(prefix, { cursor, limit })`. Accepts any serializable value. |
|
|
178
|
-
| `ctx.requestInput` | Suspend and ask the caller for more input — `return ctx.requestInput({ inputRequests: { key: inputRequired.elicit({ message, requestedSchema }) } })`. Never returns; the handler is re-entered with the answers. |
|
|
179
|
-
| `ctx.inputs` |
|
|
177
|
+
| `ctx.log` | Request-scoped logger — `.debug()`, `.info()`, `.notice()`, `.warning()`, `.error()`. Auto-correlates requestId, traceId, tenantId. Dual-sink: Pino **and** `notifications/message` to the client, so treat it as client-visible. |
|
|
178
|
+
| `ctx.state` | Tenant-scoped KV — `.get(key)`, `.set(key, value, { ttl? })`, `.delete(key)`, `.getMany(keys)`, `.list(prefix, { cursor, limit })`. Accepts any JSON-serializable value; reads return its JSON form (a `Date` comes back as an ISO string). |
|
|
179
|
+
| `ctx.requestInput` | Suspend and ask the caller for more input — `return ctx.requestInput({ inputRequests: { key: inputRequired.elicit({ message, requestedSchema }) } })`. Never returns; the handler is re-entered with the answers. Always present. |
|
|
180
|
+
| `ctx.inputs` | The request's responses — `.accepted(key, schema)`, `.view(key)`, `.state()`, `.dropped` — limited to what the client declared (`elicitation` and its form/url modes, `sampling`, `roots`). Client-supplied: a consent gate trusts only a `ctx.state` record it stored when it asked, bound to the operation, caller, and target (see the `api-context` skill). |
|
|
181
|
+
| `ctx.clientCapabilities` | What the client declared for this request, `undefined` when no view exists. Decides whether to ask for optional context (e.g. roots); never a reason to skip a consent prompt. |
|
|
180
182
|
| `ctx.enrich` | Success-path agent context (empty-result notices, query echo, pagination totals) — `ctx.enrich(...)` or `.notice()` / `.total()` / `.echo()` / `.truncated()`. Reaches `structuredContent` and `content[]`; lands only when the definition declares an `enrichment` block (no-op otherwise). |
|
|
181
183
|
| `ctx.content` | Non-text content blocks — `.image(data, mimeType)`, `.audio(data, mimeType)`, or `ctx.content(block)` for a raw block. Prepended to `content[]` after `format()`; never enters `structuredContent`. |
|
|
182
184
|
| `ctx.signal` | `AbortSignal` for cancellation. |
|
|
183
|
-
| `ctx.requestId` |
|
|
185
|
+
| `ctx.requestId` | Request ID — the one every log record of the call carries and its error envelope returns as `data.requestId`. |
|
|
184
186
|
| `ctx.tenantId` | Tenant ID from JWT; `'default'` for stdio or HTTP with auth off. |
|
|
185
187
|
|
|
186
188
|
---
|
|
@@ -189,7 +191,7 @@ Handlers receive a unified `ctx` object. Key properties:
|
|
|
189
191
|
|
|
190
192
|
Handlers throw — the framework catches, classifies, and formats.
|
|
191
193
|
|
|
192
|
-
**Recommended: typed error contract.** Declare `errors: [{ reason, code, when, recovery, retryable?, severity?, thrownBy? }]` on `tool()` / `resource()` to receive `ctx.fail(reason, …)` typed against the reason union. TypeScript catches typos at compile time, `data.reason` is auto-populated for observability, linter enforces conformance against the handler body. `recovery` is required (≥ 5 words, lint-validated) — the single source of truth for the agent's next move.
|
|
194
|
+
**Recommended: typed error contract.** Declare `errors: [{ reason, code, when, recovery, retryable?, severity?, thrownBy? }]` on `tool()` / `resource()` to receive `ctx.fail(reason, …)` typed against the reason union. TypeScript catches typos at compile time, `data.reason` is auto-populated for observability, linter enforces conformance against the handler body. `recovery` is required (≥ 5 words, lint-validated) — the single source of truth for the agent's next move. The framework puts it on the wire whenever a failure carrying that `reason` arrives without a hint — a bare `ctx.fail('reason')` or a service throw with `data: { reason }` — as `data.recovery.hint`, mirrored into `content[]` text unless the message already contains it verbatim; override with an explicit `{ recovery: { hint: '...' } }` when dynamic runtime context matters. Every error envelope also carries `data.requestId`, the id the server's log records for that call carry, and `content[]` closes with `(reason … · request <id>)`. Mark an entry the service layer throws with `thrownBy: 'service'` so `error-contract-unthrown` skips it — lint-only metadata, nothing at runtime reads it. Baseline codes (`InternalError`, `ServiceUnavailable`, `Timeout`, `ValidationError`, `SerializationError`, `RequestCancelled`) bubble freely and don't need declaring.
|
|
193
195
|
|
|
194
196
|
```ts
|
|
195
197
|
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
@@ -201,7 +203,7 @@ errors: [
|
|
|
201
203
|
],
|
|
202
204
|
async handler(input, ctx) {
|
|
203
205
|
const item = await db.find(input.id);
|
|
204
|
-
if (!item) throw ctx.fail('no_match', `No item ${input.id}
|
|
206
|
+
if (!item) throw ctx.fail('no_match', `No item ${input.id}`);
|
|
205
207
|
return item;
|
|
206
208
|
}
|
|
207
209
|
```
|
|
@@ -222,7 +224,7 @@ throw new Error('Invalid query format'); // → ValidationError
|
|
|
222
224
|
|
|
223
225
|
// McpError — when no factory exists for the code
|
|
224
226
|
import { McpError, JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
225
|
-
throw new McpError(JsonRpcErrorCode.
|
|
227
|
+
throw new McpError(JsonRpcErrorCode.InitializationFailed, 'Connection failed', { pool: 'primary' });
|
|
226
228
|
```
|
|
227
229
|
|
|
228
230
|
See framework CLAUDE.md and the `api-errors` skill for the full auto-classification table, all available factories, and the contract reference.
|
|
@@ -306,12 +308,16 @@ Available skills:
|
|
|
306
308
|
| `api-telemetry` | OTel catalog: spans, metrics, completion logs, env config, cardinality rules |
|
|
307
309
|
| `api-workers` | Cloudflare Workers runtime |
|
|
308
310
|
|
|
311
|
+
**Chaining skills into pipelines.** When the user wants a multi-phase effort — build this server out, QA-and-fix the surface, update-and-ship — *and you can spawn sub-agents*, `framework-skills/orchestrations/SKILL.md` sequences the task skills above into a gated pipeline with verification at each step. Read it to drive the run. Optional: skip it if you can't orchestrate sub-agents, and ignore it entirely if you were *spawned* as one — you've already been scoped to a single phase.
|
|
312
|
+
|
|
309
313
|
When you complete a skill's checklist, check the boxes and add a completion timestamp at the end (e.g., `Completed: 2026-03-11`).
|
|
310
314
|
|
|
311
315
|
---
|
|
312
316
|
|
|
313
317
|
## Commands
|
|
314
318
|
|
|
319
|
+
**Runtime:** Scripts use Bun's native TypeScript execution — `bun run <cmd>` is the standard invocation. `npm run <cmd>` also works (npm delegates to bun).
|
|
320
|
+
|
|
315
321
|
| Command | Purpose |
|
|
316
322
|
|:--------|:--------|
|
|
317
323
|
| `bun run build` | Compile TypeScript |
|
|
@@ -321,16 +327,16 @@ When you complete a skill's checklist, check the boxes and add a completion time
|
|
|
321
327
|
| `bun run audit:fix` | `bun audit fix` — upgrade vulnerable packages to the lowest safe version within existing ranges (`--dry-run` previews, `--latest` rewrites ranges). First response when `devcheck` flags a transitive advisory; then `bun update <name>`, then `bun dedupe` |
|
|
322
328
|
| `bun run audit:refresh` | Delete `bun.lock` and reinstall. Last resort after `audit:fix`, `bun update <name>`, and `bun dedupe` — re-resolves every ranged dep (the framework pin included) and rewrites the lockfile as `lockfileVersion: 2` |
|
|
323
329
|
| `bun run tree` | Generate directory structure doc |
|
|
324
|
-
| `bun run format` | Auto-fix formatting |
|
|
325
|
-
| `bun run format:unsafe` |
|
|
326
|
-
| `bun run test` | Run tests |
|
|
327
|
-
| `bun run lint:mcp` |
|
|
328
|
-
| `bun run lint:packaging` |
|
|
330
|
+
| `bun run format` | Auto-fix formatting (safe fixes only) |
|
|
331
|
+
| `bun run format:unsafe` | Also apply Biome's unsafe autofixes — review the diff; they can change behavior |
|
|
332
|
+
| `bun run test` | Run tests (Vitest — use `bun run test`, not `bun test`) |
|
|
333
|
+
| `bun run lint:mcp` | Run the MCP definition linter standalone (rule catalog: `api-linter` skill) |
|
|
334
|
+
| `bun run lint:packaging` | Packaging surface checks — `server.json`/`manifest.json` env-var parity (run by devcheck) |
|
|
329
335
|
| `bun run list-skills` | List skills in `framework-skills/` with name + description |
|
|
330
336
|
| `bun run release:github` | Create GitHub Release from the latest annotated tag (attach `.mcpb`, enforce title format) |
|
|
331
337
|
| `bun run bundle` | Build and pack as `dist/eurostat-mcp-server.mcpb` for one-click Claude Desktop install |
|
|
332
338
|
| `bun run changelog:build` | Regenerate `CHANGELOG.md` from `changelog/*.md` |
|
|
333
|
-
| `bun run changelog:check` | Verify `CHANGELOG.md` is in sync
|
|
339
|
+
| `bun run changelog:check` | Verify `CHANGELOG.md` is in sync (used by devcheck) |
|
|
334
340
|
| `bun run start:stdio` | Production mode (stdio) |
|
|
335
341
|
| `bun run start:http` | Production mode (HTTP) |
|
|
336
342
|
|
package/Dockerfile
CHANGED
|
@@ -5,16 +5,16 @@
|
|
|
5
5
|
# source code into JavaScript, and prepares the production assets.
|
|
6
6
|
#
|
|
7
7
|
# Pinned to $BUILDPLATFORM rather than the target platform: `bun run build` emits
|
|
8
|
-
# JavaScript, and only `dist/` crosses into the production stage
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
8
|
+
# JavaScript, and only `dist/` crosses into the production stage. Built for the
|
|
9
|
+
# target instead, the non-native leg of a `--platform linux/amd64,linux/arm64`
|
|
10
|
+
# build runs under QEMU, where bun >= 1.4 aborts with a JavaScriptCore allocator
|
|
11
|
+
# assertion and fails the multi-arch push.
|
|
12
12
|
#
|
|
13
13
|
# The constraint this assumes: the build stage produces platform-independent
|
|
14
14
|
# output. A stage that compiles a native addon needs the target-arch toolchain
|
|
15
15
|
# and cannot cross-compile this way — drop the flag there.
|
|
16
16
|
# ==============================================================================
|
|
17
|
-
FROM --platform=$BUILDPLATFORM oven/bun:1.4.
|
|
17
|
+
FROM --platform=$BUILDPLATFORM oven/bun:1.4.2 AS build
|
|
18
18
|
|
|
19
19
|
WORKDIR /usr/src/app
|
|
20
20
|
|
|
@@ -34,63 +34,110 @@ RUN bun run build
|
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
# ==============================================================================
|
|
37
|
-
# Production Stage
|
|
37
|
+
# Production Dependencies Stage
|
|
38
38
|
#
|
|
39
|
-
#
|
|
40
|
-
#
|
|
41
|
-
#
|
|
39
|
+
# Installs the production dependency tree for the target platform. Every step
|
|
40
|
+
# here can run JavaScript — bunfig.toml's security scanner runs as a Bun
|
|
41
|
+
# program, and so do the OTel and musl-prune scripts — so the stage runs on
|
|
42
|
+
# $BUILDPLATFORM and cross-installs with `--os`/`--cpu`, which pick each
|
|
43
|
+
# platform-specific optional dependency (native bindings such as DuckDB's) for
|
|
44
|
+
# the target. Only `node_modules` leaves this stage.
|
|
45
|
+
#
|
|
46
|
+
# A clean image rather than `FROM build`: the build stage's node_modules holds
|
|
47
|
+
# devDependencies.
|
|
42
48
|
# ==============================================================================
|
|
43
|
-
FROM oven/bun:1.4.
|
|
49
|
+
FROM --platform=$BUILDPLATFORM oven/bun:1.4.2 AS deps
|
|
44
50
|
|
|
45
51
|
WORKDIR /usr/src/app
|
|
46
52
|
|
|
47
|
-
#
|
|
48
|
-
#
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
#
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
#
|
|
60
|
-
|
|
53
|
+
# Copy dependency manifests. `bunfig.toml` rides along so every install below
|
|
54
|
+
# passes its release-age gate and security scanner, as a local install does.
|
|
55
|
+
COPY package.json bun.lock bunfig.toml ./
|
|
56
|
+
|
|
57
|
+
# The scanner bunfig.toml names is a devDependency, and Bun installs a missing
|
|
58
|
+
# scanner through the same production-filtered install, which omits it and
|
|
59
|
+
# aborts. Seed it from the build stage's full install instead. Remove this line,
|
|
60
|
+
# and the `rm` at the end of this stage, if bunfig.toml stops naming a scanner.
|
|
61
|
+
COPY --from=build /usr/src/app/node_modules/@socketsecurity/bun-security-scanner ./node_modules/@socketsecurity/bun-security-scanner
|
|
62
|
+
|
|
63
|
+
# Docker names the target architecture `amd64`/`arm64`; Bun's `--cpu` takes
|
|
64
|
+
# `x64`/`arm64`. Mapped once here, read by both installs below. `oven/bun`
|
|
65
|
+
# publishes only these two architectures, so any other target fails here.
|
|
66
|
+
ARG TARGETOS
|
|
67
|
+
ARG TARGETARCH
|
|
68
|
+
RUN case "$TARGETARCH" in \
|
|
69
|
+
amd64) echo x64 ;; \
|
|
70
|
+
arm64) echo arm64 ;; \
|
|
71
|
+
*) echo "Unsupported TARGETARCH '$TARGETARCH': expected amd64 or arm64" >&2; exit 1 ;; \
|
|
72
|
+
esac > .bun-cpu
|
|
61
73
|
|
|
62
74
|
# Install only production dependencies, ignoring any lifecycle scripts (like 'prepare')
|
|
63
75
|
# that are not needed in the final production image.
|
|
64
76
|
# `--omit=peer` drops the framework's optional peer tiers (test runner, service
|
|
65
77
|
# SDKs, parsers) that Bun would otherwise auto-install. Anything this server
|
|
66
78
|
# actually imports belongs in its own `dependencies`, so nothing needed at
|
|
67
|
-
# runtime is lost.
|
|
68
|
-
# install re-resolves the graph and pulls every optional peer back in.
|
|
79
|
+
# runtime is lost.
|
|
69
80
|
# The @duckdb/node-api binding that backs DataCanvas is one of this server's own
|
|
70
|
-
# dependencies, so it survives the flag
|
|
71
|
-
# CANVAS_PROVIDER_TYPE, not at build time, so
|
|
72
|
-
# and a deployment turns the feature on with
|
|
81
|
+
# dependencies, so it survives the flag, and `--cpu` picks the target's binding:
|
|
82
|
+
# the canvas is gated at runtime by CANVAS_PROVIDER_TYPE, not at build time, so
|
|
83
|
+
# the image always carries the binding and a deployment turns the feature on with
|
|
84
|
+
# an env var.
|
|
73
85
|
RUN --mount=type=cache,target=/root/.bun/install/cache \
|
|
74
|
-
bun install --production --omit=peer --frozen-lockfile --ignore-scripts
|
|
86
|
+
bun install --production --omit=peer --frozen-lockfile --ignore-scripts \
|
|
87
|
+
--os="$TARGETOS" --cpu="$(cat .bun-cpu)"
|
|
75
88
|
|
|
76
89
|
# Conditionally install OpenTelemetry optional peer dependencies (Tier 3).
|
|
77
90
|
# Installed by default. Omit them for a leaner image at build time
|
|
78
91
|
# with: docker build --build-arg OTEL_ENABLED=false
|
|
92
|
+
# The script reads the list and each range from the installed framework's
|
|
93
|
+
# `peerDependencies` and passes the target flags on to its `bun install`.
|
|
94
|
+
COPY scripts/install-otel.ts ./scripts/
|
|
79
95
|
ARG OTEL_ENABLED=true
|
|
80
96
|
RUN --mount=type=cache,target=/root/.bun/install/cache \
|
|
81
97
|
if [ "$OTEL_ENABLED" = "true" ]; then \
|
|
82
|
-
bun
|
|
83
|
-
@opentelemetry/instrumentation-http \
|
|
84
|
-
@opentelemetry/exporter-metrics-otlp-http \
|
|
85
|
-
@opentelemetry/exporter-trace-otlp-http \
|
|
86
|
-
@opentelemetry/instrumentation-pino \
|
|
87
|
-
@opentelemetry/resources \
|
|
88
|
-
@opentelemetry/sdk-metrics \
|
|
89
|
-
@opentelemetry/sdk-node \
|
|
90
|
-
@opentelemetry/sdk-trace-node \
|
|
91
|
-
@opentelemetry/semantic-conventions; \
|
|
98
|
+
bun scripts/install-otel.ts --os="$TARGETOS" --cpu="$(cat .bun-cpu)"; \
|
|
92
99
|
fi
|
|
93
100
|
|
|
101
|
+
# `--os`/`--cpu` have no libc counterpart, so a native dependency published in
|
|
102
|
+
# glibc and musl variants (DuckDB's bindings, for one) installs both. The
|
|
103
|
+
# runtime image is Debian (glibc) and never loads the musl copy; the script
|
|
104
|
+
# deletes every package whose own `libc` admits only musl. It follows every
|
|
105
|
+
# install, since a later `bun install` restores what it removes.
|
|
106
|
+
COPY scripts/prune-musl-packages.ts ./scripts/
|
|
107
|
+
RUN bun scripts/prune-musl-packages.ts
|
|
108
|
+
|
|
109
|
+
# The seeded scanner served only the installs above; keep it out of the image.
|
|
110
|
+
RUN rm -rf node_modules/@socketsecurity/bun-security-scanner
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
# ==============================================================================
|
|
114
|
+
# Production Stage
|
|
115
|
+
#
|
|
116
|
+
# This stage creates a minimal, optimized, and secure image for running the
|
|
117
|
+
# application. It uses a slim base image and only includes production
|
|
118
|
+
# dependencies and build artifacts. Its only Bun invocations are HEALTHCHECK
|
|
119
|
+
# and CMD, which run on the real target at container start.
|
|
120
|
+
# ==============================================================================
|
|
121
|
+
FROM oven/bun:1.4.2-slim AS production
|
|
122
|
+
|
|
123
|
+
WORKDIR /usr/src/app
|
|
124
|
+
|
|
125
|
+
# Set the environment to production for performance.
|
|
126
|
+
ENV NODE_ENV=production
|
|
127
|
+
|
|
128
|
+
# OCI image metadata (https://github.com/opencontainers/image-spec/blob/main/annotations.md)
|
|
129
|
+
ARG APP_VERSION
|
|
130
|
+
LABEL org.opencontainers.image.title="@cyanheads/eurostat-mcp-server"
|
|
131
|
+
LABEL org.opencontainers.image.description="Search and query the Eurostat catalogue — EU economy, demography, trade, health, and NUTS regional data via MCP. STDIO or Streamable HTTP."
|
|
132
|
+
LABEL org.opencontainers.image.licenses="Apache-2.0"
|
|
133
|
+
LABEL org.opencontainers.image.version="${APP_VERSION}"
|
|
134
|
+
LABEL org.opencontainers.image.source="https://github.com/cyanheads/eurostat-mcp-server"
|
|
135
|
+
|
|
136
|
+
# The manifest comes from the build context: the deps stage's copy was rewritten
|
|
137
|
+
# by the OTel install, and the runtime reads only its name, version, and type.
|
|
138
|
+
COPY package.json ./
|
|
139
|
+
COPY --from=deps /usr/src/app/node_modules ./node_modules
|
|
140
|
+
|
|
94
141
|
# Copy the compiled application code from the build stage
|
|
95
142
|
COPY --from=build /usr/src/app/dist ./dist
|
|
96
143
|
|
|
@@ -98,11 +145,12 @@ COPY --from=build /usr/src/app/dist ./dist
|
|
|
98
145
|
# We will use this existing user for enhanced security.
|
|
99
146
|
|
|
100
147
|
# Create and set permissions for the log and canvas directories, assigning ownership
|
|
101
|
-
# to the 'bun' user.
|
|
102
|
-
#
|
|
103
|
-
#
|
|
104
|
-
#
|
|
105
|
-
#
|
|
148
|
+
# to the 'bun' user. CANVAS_TEMP_PATH is the parent directory inside which the DuckDB
|
|
149
|
+
# provider creates its private `mcp-canvas-XXXXXX` scratch directory for spill files,
|
|
150
|
+
# and the framework sandboxes path exports to CANVAS_EXPORT_PATH. The export root is
|
|
151
|
+
# the one that breaks by default: it resolves under the working directory /usr/src/app,
|
|
152
|
+
# which this non-root user does not own. Both are pointed at owned directories below
|
|
153
|
+
# so neither depends on the image's writable-by-accident paths.
|
|
106
154
|
RUN mkdir -p /var/log/eurostat-mcp-server \
|
|
107
155
|
/var/lib/eurostat-mcp-server/canvas-tmp \
|
|
108
156
|
/var/lib/eurostat-mcp-server/canvas-exports \
|
|
@@ -123,7 +171,6 @@ ENV MCP_TRANSPORT_TYPE="http"
|
|
|
123
171
|
ENV MCP_SESSION_MODE="stateless"
|
|
124
172
|
ENV MCP_LOG_LEVEL="info"
|
|
125
173
|
ENV LOGS_DIR="/var/log/eurostat-mcp-server"
|
|
126
|
-
ENV MCP_FORCE_CONSOLE_LOGGING="true"
|
|
127
174
|
ENV CANVAS_TEMP_PATH="/var/lib/eurostat-mcp-server/canvas-tmp"
|
|
128
175
|
ENV CANVAS_EXPORT_PATH="/var/lib/eurostat-mcp-server/canvas-exports"
|
|
129
176
|
|