@cyanheads/imf-mcp-server 0.1.1

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.
Files changed (65) hide show
  1. package/AGENTS.md +377 -0
  2. package/CLAUDE.md +377 -0
  3. package/Dockerfile +105 -0
  4. package/LICENSE +201 -0
  5. package/README.md +290 -0
  6. package/changelog/0.1.x/0.1.1.md +33 -0
  7. package/changelog/template.md +127 -0
  8. package/dist/config/server-config.d.ts +13 -0
  9. package/dist/config/server-config.d.ts.map +1 -0
  10. package/dist/config/server-config.js +26 -0
  11. package/dist/config/server-config.js.map +1 -0
  12. package/dist/index.d.ts +7 -0
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +28 -0
  15. package/dist/index.js.map +1 -0
  16. package/dist/mcp-server/prompts/definitions/index.d.ts +7 -0
  17. package/dist/mcp-server/prompts/definitions/index.d.ts.map +1 -0
  18. package/dist/mcp-server/prompts/definitions/index.js +7 -0
  19. package/dist/mcp-server/prompts/definitions/index.js.map +1 -0
  20. package/dist/mcp-server/resources/definitions/imf-database.resource.d.ts +9 -0
  21. package/dist/mcp-server/resources/definitions/imf-database.resource.d.ts.map +1 -0
  22. package/dist/mcp-server/resources/definitions/imf-database.resource.js +61 -0
  23. package/dist/mcp-server/resources/definitions/imf-database.resource.js.map +1 -0
  24. package/dist/mcp-server/resources/definitions/index.d.ts +9 -0
  25. package/dist/mcp-server/resources/definitions/index.d.ts.map +1 -0
  26. package/dist/mcp-server/resources/definitions/index.js +8 -0
  27. package/dist/mcp-server/resources/definitions/index.js.map +1 -0
  28. package/dist/mcp-server/tools/definitions/imf-dataframe-describe.tool.d.ts +26 -0
  29. package/dist/mcp-server/tools/definitions/imf-dataframe-describe.tool.d.ts.map +1 -0
  30. package/dist/mcp-server/tools/definitions/imf-dataframe-describe.tool.js +96 -0
  31. package/dist/mcp-server/tools/definitions/imf-dataframe-describe.tool.js.map +1 -0
  32. package/dist/mcp-server/tools/definitions/imf-dataframe-query.tool.d.ts +24 -0
  33. package/dist/mcp-server/tools/definitions/imf-dataframe-query.tool.d.ts.map +1 -0
  34. package/dist/mcp-server/tools/definitions/imf-dataframe-query.tool.js +96 -0
  35. package/dist/mcp-server/tools/definitions/imf-dataframe-query.tool.js.map +1 -0
  36. package/dist/mcp-server/tools/definitions/imf-get-database.tool.d.ts +39 -0
  37. package/dist/mcp-server/tools/definitions/imf-get-database.tool.d.ts.map +1 -0
  38. package/dist/mcp-server/tools/definitions/imf-get-database.tool.js +155 -0
  39. package/dist/mcp-server/tools/definitions/imf-get-database.tool.js.map +1 -0
  40. package/dist/mcp-server/tools/definitions/imf-list-databases.tool.d.ts +19 -0
  41. package/dist/mcp-server/tools/definitions/imf-list-databases.tool.d.ts.map +1 -0
  42. package/dist/mcp-server/tools/definitions/imf-list-databases.tool.js +88 -0
  43. package/dist/mcp-server/tools/definitions/imf-list-databases.tool.js.map +1 -0
  44. package/dist/mcp-server/tools/definitions/imf-query-dataset.tool.d.ts +57 -0
  45. package/dist/mcp-server/tools/definitions/imf-query-dataset.tool.d.ts.map +1 -0
  46. package/dist/mcp-server/tools/definitions/imf-query-dataset.tool.js +277 -0
  47. package/dist/mcp-server/tools/definitions/imf-query-dataset.tool.js.map +1 -0
  48. package/dist/mcp-server/tools/definitions/index.d.ts +136 -0
  49. package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -0
  50. package/dist/mcp-server/tools/definitions/index.js +22 -0
  51. package/dist/mcp-server/tools/definitions/index.js.map +1 -0
  52. package/dist/services/canvas/canvas-accessor.d.ts +11 -0
  53. package/dist/services/canvas/canvas-accessor.d.ts.map +1 -0
  54. package/dist/services/canvas/canvas-accessor.js +13 -0
  55. package/dist/services/canvas/canvas-accessor.js.map +1 -0
  56. package/dist/services/imf-sdmx/imf-sdmx-service.d.ts +38 -0
  57. package/dist/services/imf-sdmx/imf-sdmx-service.d.ts.map +1 -0
  58. package/dist/services/imf-sdmx/imf-sdmx-service.js +415 -0
  59. package/dist/services/imf-sdmx/imf-sdmx-service.js.map +1 -0
  60. package/dist/services/imf-sdmx/types.d.ts +157 -0
  61. package/dist/services/imf-sdmx/types.d.ts.map +1 -0
  62. package/dist/services/imf-sdmx/types.js +6 -0
  63. package/dist/services/imf-sdmx/types.js.map +1 -0
  64. package/package.json +106 -0
  65. package/server.json +99 -0
package/AGENTS.md ADDED
@@ -0,0 +1,377 @@
1
+ # Developer Protocol
2
+
3
+ **Server:** imf-mcp-server
4
+ **Version:** 0.1.1
5
+ **Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core) `^0.9.21`
6
+ **Engines:** Bun ≥1.3.0, Node ≥24.0.0
7
+ **MCP SDK:** `@modelcontextprotocol/sdk` ^1.29.0
8
+ **Zod:** ^4.4.3
9
+
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.
11
+
12
+ ---
13
+
14
+ ## Server Overview
15
+
16
+ **imf-mcp-server** wraps the IMF SDMX 3.0 public portal. No API key required.
17
+
18
+ **Surface area:** 5 tools, 1 resource, 0 prompts.
19
+
20
+ **Workflow:** `imf_list_databases` → `imf_get_database` → `imf_query_dataset`. Large result sets spill to DataCanvas — `imf_dataframe_describe` then `imf_dataframe_query` for SQL access.
21
+
22
+ **Key constraints:**
23
+ - Country codes are ISO 3-letter (USA, GBR, DEU — not US, GB, DE)
24
+ - Key format is dot-separated DSD dimension order (e.g. `USA.NGDP_RPCH.A` for WEO)
25
+ - Canvas spill requires `CANVAS_PROVIDER_TYPE=duckdb`
26
+
27
+ ---
28
+
29
+ ## Core Rules
30
+
31
+ - **Logic throws, framework catches.** Tool/resource handlers are pure — throw on failure, no `try/catch`. Plain `Error` is fine; the framework catches, classifies, and formats. Use error factories (`notFound()`, `validationError()`, etc.) when the error code matters.
32
+ - **Use `ctx.log`** for request-scoped logging. No `console` calls.
33
+ - **Use `ctx.state`** for tenant-scoped storage. Never access persistence directly.
34
+ - **Check `ctx.elicit` / `ctx.sample`** for presence before calling.
35
+ - **Secrets in env vars only** — never hardcoded.
36
+ - **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.
37
+
38
+ ---
39
+
40
+ ## Patterns
41
+
42
+ ### Tool (with canvas spill)
43
+
44
+ ```ts
45
+ import { tool, z } from '@cyanheads/mcp-ts-core';
46
+ import { spillover } from '@cyanheads/mcp-ts-core/canvas';
47
+ import { getCanvas } from '@/services/canvas/canvas-accessor.js';
48
+ import { getImfSdmxService } from '@/services/imf-sdmx/imf-sdmx-service.js';
49
+
50
+ export const imfQueryDataset = tool('imf_query_dataset', {
51
+ description: 'Query an IMF SDMX dataflow by dimension key over a time range. ...',
52
+ annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: true },
53
+ input: z.object({
54
+ dataflow_id: z.string().describe('Dataflow ID from imf_list_databases, e.g. WEO.'),
55
+ key: z.string().describe('Dot-separated codes in DSD keyPosition order, e.g. USA.NGDP_RPCH.A.'),
56
+ canvas_id: z.string().optional().describe('Existing canvas to accumulate into.'),
57
+ }),
58
+ output: z.object({
59
+ observations: z.array(z.object({
60
+ series_key: z.string().describe('Dimension codes for this series.'),
61
+ time_period: z.string().describe('Period label, e.g. 2023 or 2023-Q1.'),
62
+ value: z.number().nullable().describe('Observation value; null when missing.'),
63
+ })).describe('Inline rows — empty when results spilled to canvas.'),
64
+ truncated: z.boolean().describe('True when results spilled to DataCanvas.'),
65
+ canvas_id: z.string().optional().describe('DataCanvas session ID when truncated=true.'),
66
+ }),
67
+ errors: [
68
+ { reason: 'dataflow_not_found', code: JsonRpcErrorCode.NotFound,
69
+ when: 'dataflow_id does not match any known dataflow',
70
+ recovery: 'Call imf_list_databases to browse available dataflow IDs.' },
71
+ ],
72
+ async handler(input, ctx) {
73
+ const svc = getImfSdmxService();
74
+ const queryResult = await svc.fetchData(/* ... */);
75
+ const canvas = getCanvas();
76
+ if (canvas) {
77
+ const instance = await canvas.acquire(input.canvas_id, ctx);
78
+ const result = await spillover({ canvas: instance, source: rows, previewChars: 100_000 });
79
+ if (result.spilled) return { observations: result.previewRows, truncated: true, canvas_id: instance.canvasId };
80
+ }
81
+ return { observations: queryResult.observations, truncated: false };
82
+ },
83
+ format: (result) => [{ type: 'text', text: result.observations.map(o => `${o.time_period}: ${o.value}`).join('\n') }],
84
+ });
85
+ ```
86
+
87
+ ### Resource
88
+
89
+ ```ts
90
+ import { resource, z } from '@cyanheads/mcp-ts-core';
91
+ import { notFound, serviceUnavailable } from '@cyanheads/mcp-ts-core/errors';
92
+ import { getImfSdmxService } from '@/services/imf-sdmx/imf-sdmx-service.js';
93
+
94
+ export const imfDatabaseResource = resource('imf://database/{dataflow_id}', {
95
+ name: 'imf-database',
96
+ title: 'IMF Dataflow Metadata',
97
+ description: 'Metadata for a single IMF SDMX dataflow — dimensions with full codelists, key_format, name, and description.',
98
+ mimeType: 'application/json',
99
+ params: z.object({
100
+ dataflow_id: z.string().describe('Dataflow identifier, e.g. WEO, BOP, CPI.'),
101
+ }),
102
+ async handler(params, ctx) {
103
+ const svc = getImfSdmxService();
104
+ const dataflow = await svc.findDataflow(params.dataflow_id, undefined, undefined, ctx);
105
+ if (!dataflow) throw notFound(`Dataflow '${params.dataflow_id}' not found`);
106
+ const structure = await svc.fetchDataflowStructure(params.dataflow_id, dataflow.agencyId, dataflow.version, ctx);
107
+ return { dataflow_id: structure.dataflowId, key_format: structure.keyFormat, dimensions: structure.dimensions };
108
+ },
109
+ });
110
+ ```
111
+
112
+ ### Server config
113
+
114
+ ```ts
115
+ // src/config/server-config.ts — actual schema
116
+ import { z } from '@cyanheads/mcp-ts-core';
117
+ import { parseEnvConfig } from '@cyanheads/mcp-ts-core/config';
118
+
119
+ const ServerConfigSchema = z.object({
120
+ baseUrl: z.string().default('https://api.imf.org/external/sdmx/3.0').describe('IMF SDMX 3.0 base URL'),
121
+ requestTimeoutMs: z.coerce.number().default(30_000).describe('Per-request timeout in milliseconds'),
122
+ });
123
+
124
+ let _config: z.infer<typeof ServerConfigSchema> | undefined;
125
+ export function getServerConfig() {
126
+ _config ??= parseEnvConfig(ServerConfigSchema, {
127
+ baseUrl: 'IMF_BASE_URL',
128
+ requestTimeoutMs: 'IMF_REQUEST_TIMEOUT_MS',
129
+ });
130
+ return _config;
131
+ }
132
+ ```
133
+
134
+ `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.
135
+
136
+ ### Server instructions
137
+
138
+ `createApp({ instructions })` — optional server-level orientation, sent to clients on every `initialize` as session-level context. Use it for deployment guidance (connection aliases, regional notes, scope hints) instead of repeating the same context across tool descriptions. Client adoption is uneven, but there's no downside when set.
139
+
140
+ ---
141
+
142
+ ## Context
143
+
144
+ Handlers receive a unified `ctx` object. Key properties:
145
+
146
+ | Property | Description |
147
+ |:---------|:------------|
148
+ | `ctx.log` | Request-scoped logger — `.debug()`, `.info()`, `.notice()`, `.warning()`, `.error()`. Auto-correlates requestId, traceId, tenantId. |
149
+ | `ctx.state` | Tenant-scoped KV — `.get(key)`, `.set(key, value, { ttl? })`, `.delete(key)`, `.list(prefix, { cursor, limit })`. Accepts any serializable value. |
150
+ | `ctx.elicit` | Ask user for structured input. **Check for presence first:** `if (ctx.elicit) { ... }` |
151
+ | `ctx.sample` | Request LLM completion from the client. **Check for presence first:** `if (ctx.sample) { ... }` |
152
+ | `ctx.signal` | `AbortSignal` for cancellation. |
153
+ | `ctx.progress` | Task progress (present when `task: true`) — `.setTotal(n)`, `.increment()`, `.update(message)`. |
154
+ | `ctx.requestId` | Unique request ID. |
155
+ | `ctx.tenantId` | Tenant ID from JWT or `'default'` for stdio. |
156
+
157
+ ---
158
+
159
+ ## Errors
160
+
161
+ Handlers throw — the framework catches, classifies, and formats.
162
+
163
+ **Recommended: typed error contract.** Declare `errors: [{ reason, code, when, recovery, retryable? }]` 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 descriptive metadata for the agent's next move (≥ 5 words, lint-validated); for the wire `data.recovery.hint` (mirrored into `content[]` text), pass explicitly at the throw site when dynamic context matters: `ctx.fail('reason', msg, { recovery: { hint: '...' } })`. Baseline codes (`InternalError`, `ServiceUnavailable`, `Timeout`, `ValidationError`, `SerializationError`) bubble freely and don't need declaring.
164
+
165
+ ```ts
166
+ import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
167
+
168
+ errors: [
169
+ { reason: 'no_match', code: JsonRpcErrorCode.NotFound,
170
+ when: 'No item matched the query',
171
+ recovery: 'Broaden the query or check the spelling and try again.' },
172
+ ],
173
+ async handler(input, ctx) {
174
+ const item = await db.find(input.id);
175
+ if (!item) throw ctx.fail('no_match', `No item ${input.id}`);
176
+ return item;
177
+ }
178
+ ```
179
+
180
+ **Declare contracts inline on each tool.** The contract is part of the tool's public surface — one file should give the full picture. Don't extract a shared `errors[]` constant; per-tool repetition is the intended cost of locality.
181
+
182
+ **Fallback (no contract entry fits):** throw via factories or plain `Error`.
183
+
184
+ ```ts
185
+ // Error factories — explicit code
186
+ import { notFound, serviceUnavailable } from '@cyanheads/mcp-ts-core/errors';
187
+ throw notFound('Item not found', { itemId });
188
+ throw serviceUnavailable('API unavailable', { url }, { cause: err });
189
+
190
+ // Plain Error — framework auto-classifies from message patterns
191
+ throw new Error('Item not found'); // → NotFound
192
+ throw new Error('Invalid query format'); // → ValidationError
193
+
194
+ // McpError — when no factory exists for the code
195
+ import { McpError, JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
196
+ throw new McpError(JsonRpcErrorCode.DatabaseError, 'Connection failed', { pool: 'primary' });
197
+ ```
198
+
199
+ See framework CLAUDE.md and the `api-errors` skill for the full auto-classification table, all available factories, and the contract reference.
200
+
201
+ ---
202
+
203
+ ## Structure
204
+
205
+ ```text
206
+ src/
207
+ index.ts # createApp() entry point — registers tools/resources, inits services
208
+ config/
209
+ server-config.ts # IMF_BASE_URL, IMF_REQUEST_TIMEOUT_MS (Zod schema)
210
+ services/
211
+ canvas/
212
+ canvas-accessor.ts # DataCanvas instance accessor (setCanvas / getCanvas)
213
+ imf-sdmx/
214
+ imf-sdmx-service.ts # IMF SDMX 3.0 API client — dataflows, DSD, data fetch
215
+ types.ts # Domain types for dataflows and observations
216
+ mcp-server/
217
+ tools/definitions/
218
+ imf-list-databases.tool.ts # List all 193 dataflows with optional filter
219
+ imf-get-database.tool.ts # Fetch DSD — dimension list and codelists
220
+ imf-query-dataset.tool.ts # Query by key + time range; spills to canvas
221
+ imf-dataframe-describe.tool.ts # List canvas tables and schema
222
+ imf-dataframe-query.tool.ts # SQL SELECT on staged canvas tables
223
+ resources/definitions/
224
+ imf-database.resource.ts # imf://database/{dataflow_id} — full codelist resource
225
+ ```
226
+
227
+ ---
228
+
229
+ ## Naming
230
+
231
+ | What | Convention | Example |
232
+ |:-----|:-----------|:--------|
233
+ | Files | kebab-case with suffix | `search-docs.tool.ts` |
234
+ | Tool/resource/prompt names | snake_case | `search_docs` |
235
+ | Directories | kebab-case | `src/services/doc-search/` |
236
+ | Descriptions | Single string or template literal, no `+` concatenation | `'Search items by query and filter.'` |
237
+
238
+ ---
239
+
240
+ ## Skills
241
+
242
+ Skills are modular instructions in `skills/` at the project root. Read them directly when a task matches — e.g., `skills/add-tool/SKILL.md` when adding a tool.
243
+
244
+ **Agent skill directory:** Copy skills into the directory your agent discovers (Claude Code: `.claude/skills/`, others: equivalent). Skills then load as context without referencing `skills/` paths. After framework updates, run the `maintenance` skill — Phase B re-syncs the agent directory.
245
+
246
+ Available skills:
247
+
248
+ | Skill | Purpose |
249
+ |:------|:--------|
250
+ | `setup` | Post-init project orientation |
251
+ | `design-mcp-server` | Design tool surface, resources, and services for a new server |
252
+ | `add-tool` | Scaffold a new tool definition |
253
+ | `add-app-tool` | Scaffold an MCP App tool + paired UI resource |
254
+ | `add-resource` | Scaffold a new resource definition |
255
+ | `add-prompt` | Scaffold a new prompt definition |
256
+ | `add-service` | Scaffold a new service integration |
257
+ | `add-test` | Scaffold test file for a tool, resource, or service |
258
+ | `field-test` | Exercise tools/resources/prompts with real inputs, verify behavior, report issues |
259
+ | `tool-defs-analysis` | Read-only audit of MCP definition language across the surface — voice, leaks, defaults, recovery hints, output descriptions |
260
+ | `security-pass` | Audit server for MCP-flavored security gaps: output injection, scope blast radius, input sinks, tenant isolation |
261
+ | `code-simplifier` | Post-session cleanup against `git diff` — modernize syntax, consolidate duplication, align with the codebase |
262
+ | `devcheck` | Lint, format, typecheck, audit |
263
+ | `polish-docs-meta` | Finalize docs, README, metadata, and agent protocol for shipping |
264
+ | `git-wrapup` | Land working-tree changes as a versioned commit + annotated tag — version bump, changelog, verify, tag. Local only. |
265
+ | `release-and-publish` | Push + npm + MCP Registry + GH Release + Docker. Picks up from `git-wrapup` |
266
+ | `maintenance` | Investigate changelogs, adopt upstream changes, sync skills to agent dirs |
267
+ | `orchestrations` | Chain task skills into a gated multi-phase pipeline — build-out, QA-fix, update-ship — when you can spawn sub-agents |
268
+ | `report-issue-framework` | File a bug or feature request against `@cyanheads/mcp-ts-core` via `gh` CLI |
269
+ | `report-issue-local` | File a bug or feature request against this server's own repo via `gh` CLI |
270
+ | `api-auth` | Auth modes, scopes, JWT/OAuth |
271
+ | `api-canvas` | DataCanvas: register tabular data, run SQL, export, plus the `spillover()` helper for big result sets — Tier 3 opt-in |
272
+ | `api-config` | AppConfig, parseConfig, env vars |
273
+ | `api-context` | Context interface, logger, state, progress |
274
+ | `api-errors` | McpError, JsonRpcErrorCode, error patterns |
275
+ | `api-linter` | Definition linter rule catalog — invoked by `bun run lint:mcp` and `devcheck` |
276
+ | `api-services` | LLM, Speech, Graph services |
277
+ | `api-testing` | createMockContext, test patterns |
278
+ | `api-utils` | Formatting, parsing, security, pagination, scheduling, telemetry helpers |
279
+ | `api-telemetry` | OTel catalog: spans, metrics, completion logs, env config, cardinality rules |
280
+ | `api-workers` | Cloudflare Workers runtime |
281
+
282
+ **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*, `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.
283
+
284
+ When you complete a skill's checklist, check the boxes and add a completion timestamp at the end (e.g., `Completed: 2026-03-11`).
285
+
286
+ ---
287
+
288
+ ## Commands
289
+
290
+ **Runtime:** Scripts use `tsx` — both `npm run <cmd>` and `bun run <cmd>` work. `bun` is slightly faster for script invocation but not required.
291
+
292
+ | Command | Purpose |
293
+ |:--------|:--------|
294
+ | `npm run build` | Compile TypeScript |
295
+ | `npm run rebuild` | Clean + build |
296
+ | `npm run clean` | Remove build artifacts |
297
+ | `npm run devcheck` | Lint + format + typecheck + security + changelog sync |
298
+ | `bun run audit:refresh` | Delete `bun.lock`, reinstall, and re-run `bun audit`. Use when `devcheck` flags a transitive advisory — Bun's `update` is sticky on transitive resolutions, so the advisory may be a stale-lockfile false positive. If it survives the refresh, it's real. |
299
+ | `npm run tree` | Generate directory structure doc |
300
+ | `npm run format` | Auto-fix formatting (safe fixes only) |
301
+ | `npm run format:unsafe` | Also apply Biome's unsafe autofixes — review the diff; they can change behavior |
302
+ | `npm test` | Run tests |
303
+ | `npm run start:stdio` | Production mode (stdio) |
304
+ | `npm run start:http` | Production mode (HTTP) |
305
+ | `npm run changelog:build` | Regenerate `CHANGELOG.md` from `changelog/*.md` |
306
+ | `npm run changelog:check` | Verify `CHANGELOG.md` is in sync (used by devcheck) |
307
+ | `npm run bundle` | Build and pack as `.mcpb` for one-click Claude Desktop install |
308
+
309
+ ---
310
+
311
+ ## Bundling
312
+
313
+ `npm run bundle` produces a `.mcpb` extension bundle for one-click install in Claude Desktop. MCPB is stdio-only — HTTP and Cloudflare Workers deployments are unaffected. Consumers who don't need it can delete `manifest.json` and `.mcpbignore`; `lint:packaging` skips cleanly.
314
+
315
+ **Adding an env var requires both files:** `server.json` (registry discovery, `environmentVariables[]`) and `manifest.json` (bundle install UX, `mcp_config.env` + `user_config`). `lint:packaging` (run by `devcheck`) verifies the env var names match.
316
+
317
+ **README install badges** (Claude Desktop `.mcpb`, Cursor, VS Code) and the `base64` / `encodeURIComponent` config-generation commands are ship-time concerns — run the `polish-docs-meta` skill, which carries the badge format, layout, and generation snippets in `skills/polish-docs-meta/references/readme.md`.
318
+
319
+ ---
320
+
321
+ ## Changelog
322
+
323
+ Directory-based, grouped by minor series via the `.x` semver-wildcard convention. Source of truth: `changelog/<major.minor>.x/<version>.md` (e.g. `changelog/0.1.x/0.1.0.md`) — one file per release, shipped in the npm package. At release, author the per-version file with a concrete version and date, then run `npm run changelog:build` to regenerate the rollup. `changelog/template.md` is a **pristine format reference** — never edited or moved; read it for the frontmatter + section layout when scaffolding. `CHANGELOG.md` is a **navigation index** (header + link + summary per version), regenerated by `npm run changelog:build` — devcheck hard-fails on drift; never hand-edit it.
324
+
325
+ Each per-version file opens with YAML frontmatter:
326
+
327
+ ```markdown
328
+ ---
329
+ summary: "One-line headline, ≤350 chars" # required — powers the rollup index
330
+ breaking: false # optional — true flags breaking changes
331
+ security: false # optional — true flags security fixes
332
+ ---
333
+
334
+ # 0.1.0 — YYYY-MM-DD
335
+ ...
336
+ ```
337
+
338
+ `breaking: true` renders a `· ⚠️ Breaking` badge — use it when consumers must update code on upgrade (signature changes, removed APIs, config renames). `security: true` renders a `· 🛡️ Security` badge and pairs with a `## Security` body section. When both are set, badges render `· ⚠️ Breaking · 🛡️ Security`.
339
+
340
+ `agent-notes` is an optional free-form field for maintenance agents processing the release downstream. Content here won't appear in the rendered CHANGELOG — it's consumed by agents running the `maintenance` skill. Use it for adoption instructions that don't fit the human-facing sections: new files to create, fields to populate, one-time migration steps. Omit entirely when there's nothing to say.
341
+
342
+ **Section order** (Keep a Changelog): Added, Changed, Deprecated, Removed, Fixed, Security. Include only sections with entries — don't ship empty headers.
343
+
344
+ **Tag annotations** render as GitHub Release bodies via `--notes-from-tag`. They must be structured markdown — never a flat comma-separated string. Subject omits the version number (GitHub prepends it). See `changelog/template.md` for the full format reference.
345
+
346
+ ---
347
+
348
+ ## Imports
349
+
350
+ ```ts
351
+ // Framework — z is re-exported, no separate zod import needed
352
+ import { tool, z } from '@cyanheads/mcp-ts-core';
353
+ import { McpError, JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
354
+
355
+ // Server's own code — via path alias
356
+ import { getMyService } from '@/services/my-domain/my-service.js';
357
+ ```
358
+
359
+ ---
360
+
361
+ ## Checklist
362
+
363
+ - [ ] Zod schemas: all fields have `.describe()`, only JSON-Schema-serializable types (no `z.custom()`, `z.date()`, `z.transform()`, `z.bigint()`, `z.symbol()`, `z.void()`, `z.map()`, `z.set()`, `z.function()`, `z.nan()`)
364
+ - [ ] Optional nested objects: handler guards for empty inner values from form-based clients (`if (input.obj?.field && ...)`, not just `if (input.obj)`). When regex/length constraints matter, use `z.union([z.literal(''), z.string().regex(...).describe(...)])` — literal variants are exempt from `describe-on-fields`.
365
+ - [ ] JSDoc `@fileoverview` + `@module` on every file
366
+ - [ ] `ctx.log` for logging, `ctx.state` for storage
367
+ - [ ] Handlers throw on failure — error factories or plain `Error`, no try/catch
368
+ - [ ] `format()` renders all data the LLM needs — different clients forward different surfaces (Claude Code → `structuredContent`, Claude Desktop → `content[]`); both must carry the same data
369
+ - [ ] If wrapping external API: raw/domain/output schemas reviewed against real upstream sparsity/nullability before finalizing required vs optional fields
370
+ - [ ] If wrapping external API: normalization and `format()` preserve uncertainty; do not fabricate facts from missing upstream data
371
+ - [ ] If wrapping external API: tests include at least one sparse payload case with omitted upstream fields
372
+ - [ ] Registered in `createApp()` arrays (directly or via barrel exports)
373
+ - [ ] Tests use `createMockContext()` from `@cyanheads/mcp-ts-core/testing`
374
+ - [ ] `.codex-plugin/plugin.json` populated — `name`, `version`, `description`, `repository`, `license` from `package.json`; `interface.displayName` = package name; `interface.shortDescription` from `package.json` description
375
+ - [ ] `.codex-plugin/mcp.json` updated — server name key matches `package.json` name; env vars added for any required API keys
376
+ - [ ] `.claude-plugin/plugin.json` populated — `name`, `version`, `description`, `repository`, `license` from `package.json`; inline `mcpServers` entry with server name key, env vars for any required API keys
377
+ - [ ] `npm run devcheck` passes