@cyanheads/ris-austria-mcp-server 0.1.5

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 (154) hide show
  1. package/AGENTS.md +401 -0
  2. package/CLAUDE.md +401 -0
  3. package/Dockerfile +125 -0
  4. package/LICENSE +201 -0
  5. package/README.md +309 -0
  6. package/changelog/0.1.x/0.1.0.md +25 -0
  7. package/changelog/0.1.x/0.1.1.md +24 -0
  8. package/changelog/0.1.x/0.1.2.md +16 -0
  9. package/changelog/0.1.x/0.1.3.md +11 -0
  10. package/changelog/0.1.x/0.1.4.md +11 -0
  11. package/changelog/0.1.x/0.1.5.md +18 -0
  12. package/changelog/template.md +129 -0
  13. package/dist/config/server-config.d.ts +19 -0
  14. package/dist/config/server-config.d.ts.map +1 -0
  15. package/dist/config/server-config.js +35 -0
  16. package/dist/config/server-config.js.map +1 -0
  17. package/dist/index.d.ts +7 -0
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/index.js +37 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/mcp-server/resources/definitions/ris-document.resource.d.ts +30 -0
  22. package/dist/mcp-server/resources/definitions/ris-document.resource.d.ts.map +1 -0
  23. package/dist/mcp-server/resources/definitions/ris-document.resource.js +75 -0
  24. package/dist/mcp-server/resources/definitions/ris-document.resource.js.map +1 -0
  25. package/dist/mcp-server/tools/definitions/_shared.d.ts +8 -0
  26. package/dist/mcp-server/tools/definitions/_shared.d.ts.map +1 -0
  27. package/dist/mcp-server/tools/definitions/_shared.js +10 -0
  28. package/dist/mcp-server/tools/definitions/_shared.js.map +1 -0
  29. package/dist/mcp-server/tools/definitions/ris-get-document.tool.d.ts +189 -0
  30. package/dist/mcp-server/tools/definitions/ris-get-document.tool.d.ts.map +1 -0
  31. package/dist/mcp-server/tools/definitions/ris-get-document.tool.js +504 -0
  32. package/dist/mcp-server/tools/definitions/ris-get-document.tool.js.map +1 -0
  33. package/dist/mcp-server/tools/definitions/ris-list-reference.tool.d.ts +42 -0
  34. package/dist/mcp-server/tools/definitions/ris-list-reference.tool.d.ts.map +1 -0
  35. package/dist/mcp-server/tools/definitions/ris-list-reference.tool.js +316 -0
  36. package/dist/mcp-server/tools/definitions/ris-list-reference.tool.js.map +1 -0
  37. package/dist/mcp-server/tools/definitions/ris-lookup-citation.tool.d.ts +80 -0
  38. package/dist/mcp-server/tools/definitions/ris-lookup-citation.tool.d.ts.map +1 -0
  39. package/dist/mcp-server/tools/definitions/ris-lookup-citation.tool.js +529 -0
  40. package/dist/mcp-server/tools/definitions/ris-lookup-citation.tool.js.map +1 -0
  41. package/dist/mcp-server/tools/definitions/ris-search-announcements.tool.d.ts +118 -0
  42. package/dist/mcp-server/tools/definitions/ris-search-announcements.tool.d.ts.map +1 -0
  43. package/dist/mcp-server/tools/definitions/ris-search-announcements.tool.js +389 -0
  44. package/dist/mcp-server/tools/definitions/ris-search-announcements.tool.js.map +1 -0
  45. package/dist/mcp-server/tools/definitions/ris-search-case-law.tool.d.ts +178 -0
  46. package/dist/mcp-server/tools/definitions/ris-search-case-law.tool.d.ts.map +1 -0
  47. package/dist/mcp-server/tools/definitions/ris-search-case-law.tool.js +495 -0
  48. package/dist/mcp-server/tools/definitions/ris-search-case-law.tool.js.map +1 -0
  49. package/dist/mcp-server/tools/definitions/ris-search-drafts.tool.d.ts +80 -0
  50. package/dist/mcp-server/tools/definitions/ris-search-drafts.tool.d.ts.map +1 -0
  51. package/dist/mcp-server/tools/definitions/ris-search-drafts.tool.js +264 -0
  52. package/dist/mcp-server/tools/definitions/ris-search-drafts.tool.js.map +1 -0
  53. package/dist/mcp-server/tools/definitions/ris-search-gazette.tool.d.ts +147 -0
  54. package/dist/mcp-server/tools/definitions/ris-search-gazette.tool.d.ts.map +1 -0
  55. package/dist/mcp-server/tools/definitions/ris-search-gazette.tool.js +509 -0
  56. package/dist/mcp-server/tools/definitions/ris-search-gazette.tool.js.map +1 -0
  57. package/dist/mcp-server/tools/definitions/ris-search-legislation.tool.d.ts +145 -0
  58. package/dist/mcp-server/tools/definitions/ris-search-legislation.tool.d.ts.map +1 -0
  59. package/dist/mcp-server/tools/definitions/ris-search-legislation.tool.js +466 -0
  60. package/dist/mcp-server/tools/definitions/ris-search-legislation.tool.js.map +1 -0
  61. package/dist/mcp-server/tools/definitions/ris-track-changes.tool.d.ts +73 -0
  62. package/dist/mcp-server/tools/definitions/ris-track-changes.tool.d.ts.map +1 -0
  63. package/dist/mcp-server/tools/definitions/ris-track-changes.tool.js +265 -0
  64. package/dist/mcp-server/tools/definitions/ris-track-changes.tool.js.map +1 -0
  65. package/dist/services/ris/normalizer.d.ts +40 -0
  66. package/dist/services/ris/normalizer.d.ts.map +1 -0
  67. package/dist/services/ris/normalizer.js +480 -0
  68. package/dist/services/ris/normalizer.js.map +1 -0
  69. package/dist/services/ris/reference/applications.d.ts +529 -0
  70. package/dist/services/ris/reference/applications.d.ts.map +1 -0
  71. package/dist/services/ris/reference/applications.js +520 -0
  72. package/dist/services/ris/reference/applications.js.map +1 -0
  73. package/dist/services/ris/reference/changed-since-intervals.d.ts +42 -0
  74. package/dist/services/ris/reference/changed-since-intervals.d.ts.map +1 -0
  75. package/dist/services/ris/reference/changed-since-intervals.js +16 -0
  76. package/dist/services/ris/reference/changed-since-intervals.js.map +1 -0
  77. package/dist/services/ris/reference/citation-formats.d.ts +39 -0
  78. package/dist/services/ris/reference/citation-formats.d.ts.map +1 -0
  79. package/dist/services/ris/reference/citation-formats.js +39 -0
  80. package/dist/services/ris/reference/citation-formats.js.map +1 -0
  81. package/dist/services/ris/reference/collections.d.ts +82 -0
  82. package/dist/services/ris/reference/collections.d.ts.map +1 -0
  83. package/dist/services/ris/reference/collections.js +102 -0
  84. package/dist/services/ris/reference/collections.js.map +1 -0
  85. package/dist/services/ris/reference/courts.d.ts +201 -0
  86. package/dist/services/ris/reference/courts.d.ts.map +1 -0
  87. package/dist/services/ris/reference/courts.js +198 -0
  88. package/dist/services/ris/reference/courts.js.map +1 -0
  89. package/dist/services/ris/reference/decision-kinds.d.ts +78 -0
  90. package/dist/services/ris/reference/decision-kinds.d.ts.map +1 -0
  91. package/dist/services/ris/reference/decision-kinds.js +117 -0
  92. package/dist/services/ris/reference/decision-kinds.js.map +1 -0
  93. package/dist/services/ris/reference/decision-types.d.ts +36 -0
  94. package/dist/services/ris/reference/decision-types.d.ts.map +1 -0
  95. package/dist/services/ris/reference/decision-types.js +29 -0
  96. package/dist/services/ris/reference/decision-types.js.map +1 -0
  97. package/dist/services/ris/reference/district-authorities.d.ts +314 -0
  98. package/dist/services/ris/reference/district-authorities.d.ts.map +1 -0
  99. package/dist/services/ris/reference/district-authorities.js +212 -0
  100. package/dist/services/ris/reference/district-authorities.js.map +1 -0
  101. package/dist/services/ris/reference/gazette-parts.d.ts +73 -0
  102. package/dist/services/ris/reference/gazette-parts.d.ts.map +1 -0
  103. package/dist/services/ris/reference/gazette-parts.js +58 -0
  104. package/dist/services/ris/reference/gazette-parts.js.map +1 -0
  105. package/dist/services/ris/reference/index.d.ts +23 -0
  106. package/dist/services/ris/reference/index.d.ts.map +1 -0
  107. package/dist/services/ris/reference/index.js +23 -0
  108. package/dist/services/ris/reference/index.js.map +1 -0
  109. package/dist/services/ris/reference/issuing-bodies.d.ts +642 -0
  110. package/dist/services/ris/reference/issuing-bodies.d.ts.map +1 -0
  111. package/dist/services/ris/reference/issuing-bodies.js +616 -0
  112. package/dist/services/ris/reference/issuing-bodies.js.map +1 -0
  113. package/dist/services/ris/reference/justiz-subject-areas.d.ts +133 -0
  114. package/dist/services/ris/reference/justiz-subject-areas.d.ts.map +1 -0
  115. package/dist/services/ris/reference/justiz-subject-areas.js +67 -0
  116. package/dist/services/ris/reference/justiz-subject-areas.js.map +1 -0
  117. package/dist/services/ris/reference/law-types.d.ts +46 -0
  118. package/dist/services/ris/reference/law-types.d.ts.map +1 -0
  119. package/dist/services/ris/reference/law-types.js +41 -0
  120. package/dist/services/ris/reference/law-types.js.map +1 -0
  121. package/dist/services/ris/reference/ministries.d.ts +360 -0
  122. package/dist/services/ris/reference/ministries.d.ts.map +1 -0
  123. package/dist/services/ris/reference/ministries.js +408 -0
  124. package/dist/services/ris/reference/ministries.js.map +1 -0
  125. package/dist/services/ris/reference/search-syntax.d.ts +66 -0
  126. package/dist/services/ris/reference/search-syntax.d.ts.map +1 -0
  127. package/dist/services/ris/reference/search-syntax.js +65 -0
  128. package/dist/services/ris/reference/search-syntax.js.map +1 -0
  129. package/dist/services/ris/reference/section-types.d.ts +33 -0
  130. package/dist/services/ris/reference/section-types.d.ts.map +1 -0
  131. package/dist/services/ris/reference/section-types.js +29 -0
  132. package/dist/services/ris/reference/section-types.js.map +1 -0
  133. package/dist/services/ris/reference/stages.d.ts +41 -0
  134. package/dist/services/ris/reference/stages.d.ts.map +1 -0
  135. package/dist/services/ris/reference/stages.js +27 -0
  136. package/dist/services/ris/reference/stages.js.map +1 -0
  137. package/dist/services/ris/reference/states.d.ts +90 -0
  138. package/dist/services/ris/reference/states.d.ts.map +1 -0
  139. package/dist/services/ris/reference/states.js +85 -0
  140. package/dist/services/ris/reference/states.js.map +1 -0
  141. package/dist/services/ris/request-builder.d.ts +195 -0
  142. package/dist/services/ris/request-builder.d.ts.map +1 -0
  143. package/dist/services/ris/request-builder.js +673 -0
  144. package/dist/services/ris/request-builder.js.map +1 -0
  145. package/dist/services/ris/ris-service.d.ts +65 -0
  146. package/dist/services/ris/ris-service.d.ts.map +1 -0
  147. package/dist/services/ris/ris-service.js +200 -0
  148. package/dist/services/ris/ris-service.js.map +1 -0
  149. package/dist/services/ris/types.d.ts +651 -0
  150. package/dist/services/ris/types.d.ts.map +1 -0
  151. package/dist/services/ris/types.js +11 -0
  152. package/dist/services/ris/types.js.map +1 -0
  153. package/package.json +108 -0
  154. package/server.json +111 -0
package/AGENTS.md ADDED
@@ -0,0 +1,401 @@
1
+ # Developer Protocol
2
+
3
+ **Server:** ris-austria-mcp-server
4
+ **Version:** 0.1.5
5
+ **Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core) `^0.10.14`
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
+ ## What's Next?
15
+
16
+ When the user asks what's next or needs direction, suggest options based on the current project state. Common next steps:
17
+
18
+ 1. **Re-run the `setup` skill** — ensures CLAUDE.md, skills, structure, and metadata are populated and up to date with the current codebase
19
+ 2. **Run the `design-mcp-server` skill** — if the tool/resource surface hasn't been mapped yet, work through domain design
20
+ 3. **Add tools/resources/prompts** — scaffold new definitions using the `add-tool`, `add-app-tool`, `add-resource`, `add-prompt` skills
21
+ 4. **Add services** — scaffold domain service integrations using the `add-service` skill
22
+ 5. **Add tests** — scaffold tests for existing definitions using the `add-test` skill
23
+ 6. **Field-test definitions** — exercise tools/resources/prompts with real inputs using the `field-test` skill, get a report of issues and pain points
24
+ 7. **Run `devcheck`** — lint, format, typecheck, and security audit
25
+ 8. **Run the `security-pass` skill** — audit handlers for MCP-specific security gaps: output injection, scope blast radius, input sinks, tenant isolation
26
+ 9. **Run the `polish-docs-meta` skill** — finalize README, CHANGELOG, metadata, and agent protocol for shipping
27
+ 10. **Run the `maintenance` skill** — investigate changelogs, adopt upstream changes, and sync skills after `bun update --latest`
28
+
29
+ Tailor suggestions to what's actually missing or stale — don't recite the full list every time.
30
+
31
+ ---
32
+
33
+ ## Core Rules
34
+
35
+ - **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.
36
+ - **Use `ctx.log`** for request-scoped logging. No `console` calls.
37
+ - **Use `ctx.state`** for tenant-scoped storage. Never access persistence directly.
38
+ - **Check `ctx.elicit`** for presence before calling.
39
+ - **Secrets in env vars only** — never hardcoded.
40
+ - **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
+ ---
43
+
44
+ ## Patterns
45
+
46
+ ### Tool
47
+
48
+ ```ts
49
+ import { tool, z } from '@cyanheads/mcp-ts-core';
50
+
51
+ export const searchItems = tool('search_items', {
52
+ description: 'Search inventory items by query.',
53
+ annotations: { readOnlyHint: true },
54
+ input: z.object({
55
+ query: z.string().describe('Search terms'),
56
+ limit: z.number().default(10).describe('Max results'),
57
+ }),
58
+ output: z.object({
59
+ items: z.array(z.object({
60
+ id: z.string().describe('Item ID'),
61
+ name: z.string().describe('Item name'),
62
+ })).describe('Matching items'),
63
+ }),
64
+ auth: ['inventory:read'],
65
+
66
+ async handler(input, ctx) {
67
+ const items = await findItems(input.query, input.limit);
68
+ ctx.log.info('Search completed', { query: input.query, count: items.length });
69
+ return { items };
70
+ },
71
+
72
+ // format() populates content[] — the markdown twin of structuredContent.
73
+ // Different clients read different surfaces (Claude Code → structuredContent,
74
+ // Claude Desktop → content[]); both must carry the same data.
75
+ // Enforced at lint time: every field in `output` must appear in the rendered text.
76
+ format: (result) => [{
77
+ type: 'text',
78
+ text: result.items.map(i => `**${i.id}**: ${i.name}`).join('\n'),
79
+ }],
80
+ });
81
+ ```
82
+
83
+ ### Resource
84
+
85
+ ```ts
86
+ import { resource, z } from '@cyanheads/mcp-ts-core';
87
+ import { notFound } from '@cyanheads/mcp-ts-core/errors';
88
+
89
+ export const itemData = resource('inventory://{itemId}', {
90
+ description: 'Fetch an inventory item by ID.',
91
+ params: z.object({ itemId: z.string().describe('Item identifier') }),
92
+ auth: ['inventory:read'],
93
+ async handler(params, ctx) {
94
+ const item = await ctx.state.get(`item:${params.itemId}`);
95
+ if (!item) throw notFound(`Item ${params.itemId} not found`, { itemId: params.itemId });
96
+ return item;
97
+ },
98
+ });
99
+ ```
100
+
101
+ ### Prompt
102
+
103
+ ```ts
104
+ import { prompt, z } from '@cyanheads/mcp-ts-core';
105
+
106
+ export const reviewCode = prompt('review_code', {
107
+ description: 'Review code for issues and best practices.',
108
+ args: z.object({
109
+ code: z.string().describe('Code to review'),
110
+ language: z.string().optional().describe('Programming language'),
111
+ }),
112
+ generate: (args) => [
113
+ { role: 'user', content: { type: 'text', text: `Review this ${args.language ?? ''} code:\n${args.code}` } },
114
+ ],
115
+ });
116
+ ```
117
+
118
+ ### Server config
119
+
120
+ ```ts
121
+ // src/config/server-config.ts — lazy-parsed, separate from framework config
122
+ import { z } from '@cyanheads/mcp-ts-core';
123
+ import { parseEnvConfig } from '@cyanheads/mcp-ts-core/config';
124
+
125
+ const ServerConfigSchema = z.object({
126
+ apiKey: z.string().describe('External API key'),
127
+ maxResults: z.coerce.number().default(100),
128
+ verboseLogging: z.stringbool().default(false).describe('Enable verbose logging'),
129
+ });
130
+
131
+ let _config: z.infer<typeof ServerConfigSchema> | undefined;
132
+ export function getServerConfig() {
133
+ _config ??= parseEnvConfig(ServerConfigSchema, {
134
+ apiKey: 'MY_API_KEY',
135
+ maxResults: 'MY_MAX_RESULTS',
136
+ verboseLogging: 'MY_VERBOSE_LOGGING',
137
+ });
138
+ return _config;
139
+ }
140
+ ```
141
+
142
+ `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
+ 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
+ ### Server identity and instructions
147
+
148
+ `createApp()` accepts optional identity fields forwarded to the SDK's `initialize` response and the server manifest (`/.well-known/mcp.json`):
149
+
150
+ ```ts
151
+ await createApp({
152
+ name: 'my-mcp-server',
153
+ title: 'My Server', // human-readable display name
154
+ websiteUrl: 'https://github.com/owner/repo', // canonical homepage URL
155
+ description: 'One-line description.', // wins over MCP_SERVER_DESCRIPTION
156
+ icons: [{ src: 'https://example.com/icon.png', sizes: ['48x48'], mimeType: 'image/png' }],
157
+ instructions: 'Use shortcut alpha for the most common case.', // session-level context
158
+ });
159
+ ```
160
+
161
+ `instructions` is optional server-level orientation, sent 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.
162
+
163
+ ---
164
+
165
+ ## Context
166
+
167
+ Handlers receive a unified `ctx` object. Key properties:
168
+
169
+ | Property | Description |
170
+ |:---------|:------------|
171
+ | `ctx.log` | Request-scoped logger — `.debug()`, `.info()`, `.notice()`, `.warning()`, `.error()`. Auto-correlates requestId, traceId, tenantId. |
172
+ | `ctx.state` | Tenant-scoped KV — `.get(key)`, `.set(key, value, { ttl? })`, `.delete(key)`, `.getMany(keys)`, `.list(prefix, { cursor, limit })`. Accepts any serializable value. |
173
+ | `ctx.elicit` | Ask user for structured input — form call `(message, schema)` or `.url(message, url)` for an external link. **Check for presence first:** `if (ctx.elicit) { ... }` |
174
+ | `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). |
175
+ | `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`. |
176
+ | `ctx.signal` | `AbortSignal` for cancellation. |
177
+ | `ctx.progress` | Task progress (present when `task: true`) — `.setTotal(n)`, `.increment()`, `.update(message)`. |
178
+ | `ctx.requestId` | Unique request ID. |
179
+ | `ctx.tenantId` | Tenant ID from JWT; `'default'` for stdio or HTTP with auth off. |
180
+
181
+ ---
182
+
183
+ ## Errors
184
+
185
+ Handlers throw — the framework catches, classifies, and formats.
186
+
187
+ **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 (≥ 5 words, lint-validated) — the single source of truth for the agent's next move. Pass `ctx.recoveryFor('reason')` as the throw's data to put it on the wire (`data.recovery.hint`, mirrored into `content[]` text); override with an explicit `{ recovery: { hint: '...' } }` when dynamic runtime context matters. Baseline codes (`InternalError`, `ServiceUnavailable`, `Timeout`, `ValidationError`, `SerializationError`) bubble freely and don't need declaring.
188
+
189
+ ```ts
190
+ import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
191
+
192
+ errors: [
193
+ { reason: 'no_match', code: JsonRpcErrorCode.NotFound,
194
+ when: 'No item matched the query',
195
+ recovery: 'Broaden the query or check the spelling and try again.' },
196
+ ],
197
+ async handler(input, ctx) {
198
+ const item = await db.find(input.id);
199
+ if (!item) throw ctx.fail('no_match', `No item ${input.id}`, ctx.recoveryFor('no_match'));
200
+ return item;
201
+ }
202
+ ```
203
+
204
+ **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.
205
+
206
+ **Fallback (no contract entry fits):** throw via factories or plain `Error`.
207
+
208
+ ```ts
209
+ // Error factories — explicit code
210
+ import { notFound, serviceUnavailable } from '@cyanheads/mcp-ts-core/errors';
211
+ throw notFound('Item not found', { itemId });
212
+ throw serviceUnavailable('API unavailable', { url }, { cause: err });
213
+
214
+ // Plain Error — framework auto-classifies from message patterns
215
+ throw new Error('Item not found'); // → NotFound
216
+ throw new Error('Invalid query format'); // → ValidationError
217
+
218
+ // McpError — when no factory exists for the code
219
+ import { McpError, JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
220
+ throw new McpError(JsonRpcErrorCode.DatabaseError, 'Connection failed', { pool: 'primary' });
221
+ ```
222
+
223
+ See framework CLAUDE.md and the `api-errors` skill for the full auto-classification table, all available factories, and the contract reference.
224
+
225
+ ---
226
+
227
+ ## Structure
228
+
229
+ ```text
230
+ src/
231
+ index.ts # createApp() entry point
232
+ config/
233
+ server-config.ts # Server-specific env vars (Zod schema)
234
+ services/
235
+ [domain]/
236
+ [domain]-service.ts # Domain service (init/accessor pattern)
237
+ types.ts # Domain types
238
+ mcp-server/
239
+ tools/definitions/
240
+ [tool-name].tool.ts # Tool definitions
241
+ resources/definitions/
242
+ [resource-name].resource.ts # Resource definitions
243
+ prompts/definitions/
244
+ [prompt-name].prompt.ts # Prompt definitions
245
+ ```
246
+
247
+ ---
248
+
249
+ ## Naming
250
+
251
+ | What | Convention | Example |
252
+ |:-----|:-----------|:--------|
253
+ | Files | kebab-case with suffix | `search-docs.tool.ts` |
254
+ | Tool/resource/prompt names | snake_case | `search_docs` |
255
+ | Directories | kebab-case | `src/services/doc-search/` |
256
+ | Descriptions | Single string or template literal, no `+` concatenation | `'Search items by query and filter.'` |
257
+
258
+ ---
259
+
260
+ ## Skills
261
+
262
+ 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. `bun run list-skills` prints the full registry.
263
+
264
+ **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.
265
+
266
+ Available skills:
267
+
268
+ | Skill | Purpose |
269
+ |:------|:--------|
270
+ | `setup` | Post-init project orientation |
271
+ | `design-mcp-server` | Design tool surface, resources, and services for a new server |
272
+ | `add-tool` | Scaffold a new tool definition |
273
+ | `add-app-tool` | Scaffold an MCP App tool + paired UI resource |
274
+ | `add-resource` | Scaffold a new resource definition |
275
+ | `add-prompt` | Scaffold a new prompt definition |
276
+ | `add-service` | Scaffold a new service integration |
277
+ | `add-test` | Scaffold test file for a tool, resource, or service |
278
+ | `field-test` | Exercise tools/resources/prompts with real inputs, verify behavior, report issues |
279
+ | `tool-defs-analysis` | Read-only audit of MCP definition language across the surface — voice, leaks, defaults, recovery hints, output descriptions |
280
+ | `security-pass` | Audit server for MCP-flavored security gaps: output injection, scope blast radius, input sinks, tenant isolation |
281
+ | `code-simplifier` | Post-session cleanup against `git diff` — modernize syntax, consolidate duplication, align with the codebase |
282
+ | `polish-docs-meta` | Finalize docs, README, metadata, and agent protocol for shipping |
283
+ | `git-wrapup` | Land working-tree changes as a versioned commit + annotated tag — version bump, changelog, verify, tag. Local only. |
284
+ | `release-and-publish` | Push + npm + MCP Registry + GH Release + Docker. Picks up from `git-wrapup` |
285
+ | `maintenance` | Investigate changelogs, adopt upstream changes, sync skills to agent dirs |
286
+ | `orchestrations` | Chain task skills into a gated multi-phase pipeline — build-out, QA-fix, update-ship — when you can spawn sub-agents |
287
+ | `report-issue-framework` | File a bug or feature request against `@cyanheads/mcp-ts-core` via `gh` CLI |
288
+ | `report-issue-local` | File a bug or feature request against this server's own repo via `gh` CLI |
289
+ | `techniques` | Catalog of response/data-shaping techniques — overflow handling, payload shaping, retrieval patterns |
290
+ | `api-auth` | Auth modes, scopes, JWT/OAuth |
291
+ | `api-canvas` | DataCanvas: register tabular data, run SQL, export, plus the `spillover()` helper for big result sets — Tier 3 opt-in |
292
+ | `api-config` | AppConfig, parseConfig, env vars |
293
+ | `api-context` | Context interface, logger, state, progress |
294
+ | `api-errors` | McpError, JsonRpcErrorCode, error patterns |
295
+ | `api-linter` | Definition linter rule catalog — invoked by `bun run lint:mcp` and `devcheck` |
296
+ | `api-mirror` | MirrorService: persistent self-refreshing local mirror (embedded SQLite + FTS5) of a bulk upstream dataset — Tier 3 opt-in |
297
+ | `api-services` | LLM, Speech, Graph services |
298
+ | `api-testing` | createMockContext, test patterns |
299
+ | `api-utils` | Formatting, parsing, security, pagination, scheduling, telemetry helpers |
300
+ | `api-telemetry` | OTel catalog: spans, metrics, completion logs, env config, cardinality rules |
301
+ | `api-workers` | Cloudflare Workers runtime |
302
+
303
+ **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.
304
+
305
+ When you complete a skill's checklist, check the boxes and add a completion timestamp at the end (e.g., `Completed: 2026-03-11`).
306
+
307
+ ---
308
+
309
+ ## Commands
310
+
311
+ **Runtime:** Scripts use Bun's native TypeScript execution — `bun run <cmd>` is the standard invocation. `npm run <cmd>` also works (npm delegates to bun).
312
+
313
+ | Command | Purpose |
314
+ |:--------|:--------|
315
+ | `bun run build` | Compile TypeScript |
316
+ | `bun run rebuild` | Clean + build |
317
+ | `bun run clean` | Remove build artifacts |
318
+ | `bun run devcheck` | Lint + format + typecheck + security + changelog sync |
319
+ | `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. |
320
+ | `bun run lint:mcp` | Run the MCP definition linter standalone (rule catalog: `api-linter` skill) |
321
+ | `bun run lint:packaging` | Packaging surface checks — `server.json`/`manifest.json` env-var parity (run by devcheck) |
322
+ | `bun run list-skills` | Print the skill registry |
323
+ | `bun run tree` | Generate directory structure doc |
324
+ | `bun run format` | Auto-fix formatting (safe fixes only) |
325
+ | `bun run format:unsafe` | Also apply Biome's unsafe autofixes — review the diff; they can change behavior |
326
+ | `bun run test` | Run tests (Vitest — use `bun run test`, not `bun test`) |
327
+ | `bun run start:stdio` | Production mode (stdio) |
328
+ | `bun run start:http` | Production mode (HTTP) |
329
+ | `bun run changelog:build` | Regenerate `CHANGELOG.md` from `changelog/*.md` |
330
+ | `bun run changelog:check` | Verify `CHANGELOG.md` is in sync (used by devcheck) |
331
+ | `bun run bundle` | Build, pack, and clean a `.mcpb` for one-click Claude Desktop install |
332
+
333
+ ---
334
+
335
+ ## Bundling
336
+
337
+ `npm run bundle` produces a `.mcpb` extension bundle for one-click install in Claude Desktop. The pack step is followed by `scripts/clean-mcpb.ts`, which prunes dev dependencies (`mcpb clean`) and strips dependency-shipped agent docs (`node_modules/**` `skills/`, `.claude/`, `.agents/`, `SKILL.md`) that root-anchored `.mcpbignore` patterns cannot reach. 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.
338
+
339
+ **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.
340
+
341
+ **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`.
342
+
343
+ ---
344
+
345
+ ## Changelog
346
+
347
+ 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.
348
+
349
+ Each per-version file opens with YAML frontmatter:
350
+
351
+ ```markdown
352
+ ---
353
+ summary: "One-line headline, ≤350 chars" # required — powers the rollup index
354
+ breaking: false # optional — true flags breaking changes
355
+ security: false # optional — true ONLY for a source-code security fix, never a dependency CVE bump
356
+ ---
357
+
358
+ # 0.1.0 — YYYY-MM-DD
359
+ ...
360
+ ```
361
+
362
+ `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 — set it only for a security fix in this server's *own source code*, never for a routine dependency or transitive CVE bump (record those under `## Dependencies`). When both are set, badges render `· ⚠️ Breaking · 🛡️ Security`.
363
+
364
+ `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.
365
+
366
+ **Section order** (Keep a Changelog): Added, Changed, Deprecated, Removed, Fixed, Security. Include only sections with entries — don't ship empty headers.
367
+
368
+ **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.
369
+
370
+ ---
371
+
372
+ ## Imports
373
+
374
+ ```ts
375
+ // Framework — z is re-exported, no separate zod import needed
376
+ import { tool, z } from '@cyanheads/mcp-ts-core';
377
+ import { McpError, JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
378
+
379
+ // Server's own code — via path alias
380
+ import { getMyService } from '@/services/my-domain/my-service.js';
381
+ ```
382
+
383
+ ---
384
+
385
+ ## Checklist
386
+
387
+ - [ ] 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()`)
388
+ - [ ] 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`.
389
+ - [ ] JSDoc `@fileoverview` + `@module` on every file
390
+ - [ ] `ctx.log` for logging, `ctx.state` for storage
391
+ - [ ] Handlers throw on failure — error factories or plain `Error`, no try/catch
392
+ - [ ] `format()` renders all data the LLM needs — different clients forward different surfaces (Claude Code → `structuredContent`, Claude Desktop → `content[]`); both must carry the same data
393
+ - [ ] If wrapping external API: raw/domain/output schemas reviewed against real upstream sparsity/nullability before finalizing required vs optional fields
394
+ - [ ] If wrapping external API: normalization and `format()` preserve uncertainty; do not fabricate facts from missing upstream data
395
+ - [ ] If wrapping external API: tests include at least one sparse payload case with omitted upstream fields
396
+ - [ ] Registered in `createApp()` arrays (directly or via barrel exports)
397
+ - [ ] Tests use `createMockContext()` from `@cyanheads/mcp-ts-core/testing`
398
+ - [ ] `.codex-plugin/plugin.json` populated — `name`, `version`, `description`, `repository`, `license` from `package.json`; `interface.displayName` = package name; `interface.shortDescription` from `package.json` description
399
+ - [ ] `.codex-plugin/mcp.json` updated — server name key matches `package.json` name; env vars added for any required API keys
400
+ - [ ] `.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
401
+ - [ ] `npm run devcheck` passes