@cyanheads/cpsc-recalls-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.
- package/AGENTS.md +372 -0
- package/CLAUDE.md +372 -0
- package/Dockerfile +99 -0
- package/LICENSE +201 -0
- package/README.md +266 -0
- package/changelog/0.1.x/0.1.0.md +11 -0
- package/changelog/0.1.x/0.1.1.md +26 -0
- package/changelog/template.md +127 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-server/tools/definitions/cpsc-get-recall.tool.d.ts +51 -0
- package/dist/mcp-server/tools/definitions/cpsc-get-recall.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/cpsc-get-recall.tool.js +239 -0
- package/dist/mcp-server/tools/definitions/cpsc-get-recall.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/cpsc-get-recent.tool.d.ts +36 -0
- package/dist/mcp-server/tools/definitions/cpsc-get-recent.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/cpsc-get-recent.tool.js +147 -0
- package/dist/mcp-server/tools/definitions/cpsc-get-recent.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/cpsc-search-recalls.tool.d.ts +54 -0
- package/dist/mcp-server/tools/definitions/cpsc-search-recalls.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/cpsc-search-recalls.tool.js +245 -0
- package/dist/mcp-server/tools/definitions/cpsc-search-recalls.tool.js.map +1 -0
- package/dist/services/cpsc-recall/cpsc-recall-service.d.ts +29 -0
- package/dist/services/cpsc-recall/cpsc-recall-service.d.ts.map +1 -0
- package/dist/services/cpsc-recall/cpsc-recall-service.js +97 -0
- package/dist/services/cpsc-recall/cpsc-recall-service.js.map +1 -0
- package/dist/services/cpsc-recall/types.d.ts +86 -0
- package/dist/services/cpsc-recall/types.d.ts.map +1 -0
- package/dist/services/cpsc-recall/types.js +6 -0
- package/dist/services/cpsc-recall/types.js.map +1 -0
- package/package.json +101 -0
- package/server.json +99 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
# Developer Protocol
|
|
2
|
+
|
|
3
|
+
**Server:** cpsc-recalls-mcp-server
|
|
4
|
+
**Version:** 0.1.1
|
|
5
|
+
**Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core) `^0.9.19`
|
|
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` / `ctx.sample`** 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
|
+
});
|
|
129
|
+
|
|
130
|
+
let _config: z.infer<typeof ServerConfigSchema> | undefined;
|
|
131
|
+
export function getServerConfig() {
|
|
132
|
+
_config ??= parseEnvConfig(ServerConfigSchema, {
|
|
133
|
+
apiKey: 'MY_API_KEY',
|
|
134
|
+
maxResults: 'MY_MAX_RESULTS',
|
|
135
|
+
});
|
|
136
|
+
return _config;
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
`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.
|
|
141
|
+
|
|
142
|
+
### Server instructions
|
|
143
|
+
|
|
144
|
+
`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.
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Context
|
|
149
|
+
|
|
150
|
+
Handlers receive a unified `ctx` object. Key properties:
|
|
151
|
+
|
|
152
|
+
| Property | Description |
|
|
153
|
+
|:---------|:------------|
|
|
154
|
+
| `ctx.log` | Request-scoped logger — `.debug()`, `.info()`, `.notice()`, `.warning()`, `.error()`. Auto-correlates requestId, traceId, tenantId. |
|
|
155
|
+
| `ctx.state` | Tenant-scoped KV — `.get(key)`, `.set(key, value, { ttl? })`, `.delete(key)`, `.list(prefix, { cursor, limit })`. Accepts any serializable value. |
|
|
156
|
+
| `ctx.elicit` | Ask user for structured input. **Check for presence first:** `if (ctx.elicit) { ... }` |
|
|
157
|
+
| `ctx.sample` | Request LLM completion from the client. **Check for presence first:** `if (ctx.sample) { ... }` |
|
|
158
|
+
| `ctx.signal` | `AbortSignal` for cancellation. |
|
|
159
|
+
| `ctx.progress` | Task progress (present when `task: true`) — `.setTotal(n)`, `.increment()`, `.update(message)`. |
|
|
160
|
+
| `ctx.requestId` | Unique request ID. |
|
|
161
|
+
| `ctx.tenantId` | Tenant ID from JWT or `'default'` for stdio. |
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## Errors
|
|
166
|
+
|
|
167
|
+
Handlers throw — the framework catches, classifies, and formats.
|
|
168
|
+
|
|
169
|
+
**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.
|
|
170
|
+
|
|
171
|
+
```ts
|
|
172
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
173
|
+
|
|
174
|
+
errors: [
|
|
175
|
+
{ reason: 'no_match', code: JsonRpcErrorCode.NotFound,
|
|
176
|
+
when: 'No item matched the query',
|
|
177
|
+
recovery: 'Broaden the query or check the spelling and try again.' },
|
|
178
|
+
],
|
|
179
|
+
async handler(input, ctx) {
|
|
180
|
+
const item = await db.find(input.id);
|
|
181
|
+
if (!item) throw ctx.fail('no_match', `No item ${input.id}`);
|
|
182
|
+
return item;
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
**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.
|
|
187
|
+
|
|
188
|
+
**Fallback (no contract entry fits):** throw via factories or plain `Error`.
|
|
189
|
+
|
|
190
|
+
```ts
|
|
191
|
+
// Error factories — explicit code
|
|
192
|
+
import { notFound, serviceUnavailable } from '@cyanheads/mcp-ts-core/errors';
|
|
193
|
+
throw notFound('Item not found', { itemId });
|
|
194
|
+
throw serviceUnavailable('API unavailable', { url }, { cause: err });
|
|
195
|
+
|
|
196
|
+
// Plain Error — framework auto-classifies from message patterns
|
|
197
|
+
throw new Error('Item not found'); // → NotFound
|
|
198
|
+
throw new Error('Invalid query format'); // → ValidationError
|
|
199
|
+
|
|
200
|
+
// McpError — when no factory exists for the code
|
|
201
|
+
import { McpError, JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
202
|
+
throw new McpError(JsonRpcErrorCode.DatabaseError, 'Connection failed', { pool: 'primary' });
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
See framework CLAUDE.md and the `api-errors` skill for the full auto-classification table, all available factories, and the contract reference.
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## Structure
|
|
210
|
+
|
|
211
|
+
```text
|
|
212
|
+
src/
|
|
213
|
+
index.ts # createApp() entry point — registers tools, inits service
|
|
214
|
+
mcp-server/
|
|
215
|
+
tools/definitions/
|
|
216
|
+
cpsc-search-recalls.tool.ts # Search recalls by product, org, date
|
|
217
|
+
cpsc-get-recall.tool.ts # Full detail for a single recall by number
|
|
218
|
+
cpsc-get-recent.tool.ts # Recent recalls feed (date window)
|
|
219
|
+
services/
|
|
220
|
+
cpsc-recall/
|
|
221
|
+
cpsc-recall-service.ts # CPSC API client, init/accessor pattern
|
|
222
|
+
types.ts # Raw API and domain types
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## Naming
|
|
228
|
+
|
|
229
|
+
| What | Convention | Example |
|
|
230
|
+
|:-----|:-----------|:--------|
|
|
231
|
+
| Files | kebab-case with suffix | `search-docs.tool.ts` |
|
|
232
|
+
| Tool/resource/prompt names | snake_case | `search_docs` |
|
|
233
|
+
| Directories | kebab-case | `src/services/doc-search/` |
|
|
234
|
+
| Descriptions | Single string or template literal, no `+` concatenation | `'Search items by query and filter.'` |
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## Skills
|
|
239
|
+
|
|
240
|
+
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.
|
|
241
|
+
|
|
242
|
+
**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.
|
|
243
|
+
|
|
244
|
+
Available skills:
|
|
245
|
+
|
|
246
|
+
| Skill | Purpose |
|
|
247
|
+
|:------|:--------|
|
|
248
|
+
| `setup` | Post-init project orientation |
|
|
249
|
+
| `design-mcp-server` | Design tool surface, resources, and services for a new server |
|
|
250
|
+
| `add-tool` | Scaffold a new tool definition |
|
|
251
|
+
| `add-app-tool` | Scaffold an MCP App tool + paired UI resource |
|
|
252
|
+
| `add-resource` | Scaffold a new resource definition |
|
|
253
|
+
| `add-prompt` | Scaffold a new prompt definition |
|
|
254
|
+
| `add-service` | Scaffold a new service integration |
|
|
255
|
+
| `add-test` | Scaffold test file for a tool, resource, or service |
|
|
256
|
+
| `field-test` | Exercise tools/resources/prompts with real inputs, verify behavior, report issues |
|
|
257
|
+
| `tool-defs-analysis` | Read-only audit of MCP definition language across the surface — voice, leaks, defaults, recovery hints, output descriptions |
|
|
258
|
+
| `security-pass` | Audit server for MCP-flavored security gaps: output injection, scope blast radius, input sinks, tenant isolation |
|
|
259
|
+
| `code-simplifier` | Post-session cleanup against `git diff` — modernize syntax, consolidate duplication, align with the codebase |
|
|
260
|
+
| `devcheck` | Lint, format, typecheck, audit |
|
|
261
|
+
| `polish-docs-meta` | Finalize docs, README, metadata, and agent protocol for shipping |
|
|
262
|
+
| `git-wrapup` | Land working-tree changes as a versioned commit + annotated tag — version bump, changelog, verify, tag. Local only. |
|
|
263
|
+
| `release-and-publish` | Push + npm + MCP Registry + GH Release + Docker. Picks up from `git-wrapup` |
|
|
264
|
+
| `maintenance` | Investigate changelogs, adopt upstream changes, sync skills to agent dirs |
|
|
265
|
+
| `report-issue-framework` | File a bug or feature request against `@cyanheads/mcp-ts-core` via `gh` CLI |
|
|
266
|
+
| `report-issue-local` | File a bug or feature request against this server's own repo via `gh` CLI |
|
|
267
|
+
| `api-auth` | Auth modes, scopes, JWT/OAuth |
|
|
268
|
+
| `api-canvas` | DataCanvas: register tabular data, run SQL, export, plus the `spillover()` helper for big result sets — Tier 3 opt-in |
|
|
269
|
+
| `api-config` | AppConfig, parseConfig, env vars |
|
|
270
|
+
| `api-context` | Context interface, logger, state, progress |
|
|
271
|
+
| `api-errors` | McpError, JsonRpcErrorCode, error patterns |
|
|
272
|
+
| `api-linter` | Definition linter rule catalog — invoked by `bun run lint:mcp` and `devcheck` |
|
|
273
|
+
| `api-services` | LLM, Speech, Graph services |
|
|
274
|
+
| `api-testing` | createMockContext, test patterns |
|
|
275
|
+
| `api-utils` | Formatting, parsing, security, pagination, scheduling, telemetry helpers |
|
|
276
|
+
| `api-telemetry` | OTel catalog: spans, metrics, completion logs, env config, cardinality rules |
|
|
277
|
+
| `api-workers` | Cloudflare Workers runtime |
|
|
278
|
+
|
|
279
|
+
When you complete a skill's checklist, check the boxes and add a completion timestamp at the end (e.g., `Completed: 2026-03-11`).
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
## Commands
|
|
284
|
+
|
|
285
|
+
**Runtime:** Scripts use `bun run scripts/X.ts`. All commands use `bun run <cmd>`.
|
|
286
|
+
|
|
287
|
+
| Command | Purpose |
|
|
288
|
+
|:--------|:--------|
|
|
289
|
+
| `bun run build` | Compile TypeScript |
|
|
290
|
+
| `bun run rebuild` | Clean + build |
|
|
291
|
+
| `bun run clean` | Remove build artifacts |
|
|
292
|
+
| `bun run devcheck` | Lint + format + typecheck + security + changelog sync |
|
|
293
|
+
| `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. |
|
|
294
|
+
| `bun run tree` | Generate directory structure doc |
|
|
295
|
+
| `bun run format` | Auto-fix formatting (safe fixes only) |
|
|
296
|
+
| `bun run format:unsafe` | Also apply Biome's unsafe autofixes — review the diff; they can change behavior |
|
|
297
|
+
| `bun run test` | Run tests |
|
|
298
|
+
| `bun run start:stdio` | Production mode (stdio) |
|
|
299
|
+
| `bun run start:http` | Production mode (HTTP) |
|
|
300
|
+
| `bun run changelog:build` | Regenerate `CHANGELOG.md` from `changelog/*.md` |
|
|
301
|
+
| `bun run changelog:check` | Verify `CHANGELOG.md` is in sync (used by devcheck) |
|
|
302
|
+
| `bun run bundle` | Build and pack as `.mcpb` for one-click Claude Desktop install |
|
|
303
|
+
|
|
304
|
+
---
|
|
305
|
+
|
|
306
|
+
## Bundling
|
|
307
|
+
|
|
308
|
+
`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.
|
|
309
|
+
|
|
310
|
+
**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.
|
|
311
|
+
|
|
312
|
+
**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`.
|
|
313
|
+
|
|
314
|
+
---
|
|
315
|
+
|
|
316
|
+
## Changelog
|
|
317
|
+
|
|
318
|
+
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 `bun 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 `bun run changelog:build` — devcheck hard-fails on drift; never hand-edit it.
|
|
319
|
+
|
|
320
|
+
Each per-version file opens with YAML frontmatter:
|
|
321
|
+
|
|
322
|
+
```markdown
|
|
323
|
+
---
|
|
324
|
+
summary: "One-line headline, ≤350 chars" # required — powers the rollup index
|
|
325
|
+
breaking: false # optional — true flags breaking changes
|
|
326
|
+
security: false # optional — true flags security fixes
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
# 0.1.0 — YYYY-MM-DD
|
|
330
|
+
...
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
`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`.
|
|
334
|
+
|
|
335
|
+
`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.
|
|
336
|
+
|
|
337
|
+
**Section order** (Keep a Changelog): Added, Changed, Deprecated, Removed, Fixed, Security. Include only sections with entries — don't ship empty headers.
|
|
338
|
+
|
|
339
|
+
**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.
|
|
340
|
+
|
|
341
|
+
---
|
|
342
|
+
|
|
343
|
+
## Imports
|
|
344
|
+
|
|
345
|
+
```ts
|
|
346
|
+
// Framework — z is re-exported, no separate zod import needed
|
|
347
|
+
import { tool, z } from '@cyanheads/mcp-ts-core';
|
|
348
|
+
import { McpError, JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
349
|
+
|
|
350
|
+
// Server's own code — via path alias
|
|
351
|
+
import { getMyService } from '@/services/my-domain/my-service.js';
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
---
|
|
355
|
+
|
|
356
|
+
## Checklist
|
|
357
|
+
|
|
358
|
+
- [ ] 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()`)
|
|
359
|
+
- [ ] 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`.
|
|
360
|
+
- [ ] JSDoc `@fileoverview` + `@module` on every file
|
|
361
|
+
- [ ] `ctx.log` for logging, `ctx.state` for storage
|
|
362
|
+
- [ ] Handlers throw on failure — error factories or plain `Error`, no try/catch
|
|
363
|
+
- [ ] `format()` renders all data the LLM needs — different clients forward different surfaces (Claude Code → `structuredContent`, Claude Desktop → `content[]`); both must carry the same data
|
|
364
|
+
- [ ] If wrapping external API: raw/domain/output schemas reviewed against real upstream sparsity/nullability before finalizing required vs optional fields
|
|
365
|
+
- [ ] If wrapping external API: normalization and `format()` preserve uncertainty; do not fabricate facts from missing upstream data
|
|
366
|
+
- [ ] If wrapping external API: tests include at least one sparse payload case with omitted upstream fields
|
|
367
|
+
- [ ] Registered in `createApp()` arrays (directly or via barrel exports)
|
|
368
|
+
- [ ] Tests use `createMockContext()` from `@cyanheads/mcp-ts-core/testing`
|
|
369
|
+
- [ ] `.codex-plugin/plugin.json` populated — `name`, `version`, `description`, `repository`, `license` from `package.json`; `interface.displayName` = package name; `interface.shortDescription` from `package.json` description
|
|
370
|
+
- [ ] `.codex-plugin/mcp.json` updated — server name key matches `package.json` name; env vars added for any required API keys
|
|
371
|
+
- [ ] `.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
|
|
372
|
+
- [ ] `bun run devcheck` passes
|