@cyanheads/protein-mcp-server 0.8.0 → 0.8.2
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 +44 -20
- package/CLAUDE.md +44 -20
- package/README.md +76 -88
- package/changelog/0.8.x/0.8.1.md +29 -0
- package/changelog/0.8.x/0.8.2.md +24 -0
- package/changelog/template.md +9 -26
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp-server/tools/definitions/analyze-collection.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/analyze-collection.tool.js +4 -16
- package/dist/mcp-server/tools/definitions/analyze-collection.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/compare-structures.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/compare-structures.tool.js +2 -15
- package/dist/mcp-server/tools/definitions/compare-structures.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/find-similar.tool.d.ts +5 -0
- package/dist/mcp-server/tools/definitions/find-similar.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/find-similar.tool.js +6 -0
- package/dist/mcp-server/tools/definitions/find-similar.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/get-annotations.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/get-annotations.tool.js +2 -11
- package/dist/mcp-server/tools/definitions/get-annotations.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/search-structures.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/search-structures.tool.js +1 -9
- package/dist/mcp-server/tools/definitions/search-structures.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/track-ligands.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/track-ligands.tool.js +1 -8
- package/dist/mcp-server/tools/definitions/track-ligands.tool.js.map +1 -1
- package/package.json +10 -9
- package/server.json +3 -3
package/AGENTS.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# Developer Protocol
|
|
2
2
|
|
|
3
3
|
**Server:** protein-mcp-server
|
|
4
|
-
**Version:** 0.8.
|
|
5
|
-
**Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core) `^0.
|
|
6
|
-
**Engines:** Bun ≥1.
|
|
4
|
+
**Version:** 0.8.2
|
|
5
|
+
**Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core) `^0.13.6`
|
|
6
|
+
**Engines:** Bun ≥1.4.0, Node ≥24.0.0
|
|
7
7
|
**MCP SDK:** `@modelcontextprotocol/server` ^2.0.0
|
|
8
|
-
**Zod:** ^4.5
|
|
8
|
+
**Zod:** ^4.6.5
|
|
9
9
|
**TypeScript:** ^7.0.2
|
|
10
10
|
|
|
11
11
|
> **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.
|
|
@@ -38,6 +38,7 @@ Tailor suggestions to what's actually missing or stale — don't recite the full
|
|
|
38
38
|
- **Use `ctx.state`** for tenant-scoped storage. Never access persistence directly.
|
|
39
39
|
- **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.
|
|
40
40
|
- **Secrets in env vars only** — never hardcoded.
|
|
41
|
+
- **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.
|
|
41
42
|
- **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.
|
|
42
43
|
|
|
43
44
|
---
|
|
@@ -85,7 +86,11 @@ export const getAnnotations = tool('protein_get_annotations', {
|
|
|
85
86
|
accession = (await getRcsbService().resolveUniprotEntities(input.pdb_id, ctx))[0]?.accession;
|
|
86
87
|
}
|
|
87
88
|
if (!accession || !isUniProtAccession(accession)) {
|
|
88
|
-
throw ctx.fail(
|
|
89
|
+
throw ctx.fail(
|
|
90
|
+
'no_uniprot_mapping',
|
|
91
|
+
'Provide a UniProt accession, or a PDB ID with a modeled protein chain.',
|
|
92
|
+
ctx.recoveryFor('no_uniprot_mapping'),
|
|
93
|
+
);
|
|
89
94
|
}
|
|
90
95
|
const entry = await getUniProtService().getEntry(accession, input.include, ctx);
|
|
91
96
|
return { accession: entry.accession, geneNames: entry.geneNames };
|
|
@@ -173,12 +178,19 @@ await createApp({
|
|
|
173
178
|
resources: [pdbSummaryResource, afSummaryResource],
|
|
174
179
|
prompts: [],
|
|
175
180
|
landing: { requireAuth: false }, // public, keyless data server
|
|
176
|
-
|
|
181
|
+
sessionMode: 'stateless', // no tool gates on ctx.requestInput
|
|
182
|
+
instructions: 'Find structures with protein_search_structures, then pass the returned IDs to protein_get_structure … A PDB ID also chains into … A Foldseek search or structural alignment still running … re-call with it to resume that job rather than resubmitting.',
|
|
177
183
|
setup(core) { /* init the six provider services */ },
|
|
178
184
|
});
|
|
179
185
|
```
|
|
180
186
|
|
|
181
|
-
`instructions` is optional server-level orientation, sent on every `initialize` as session-level context.
|
|
187
|
+
`instructions` is optional server-level orientation, sent on every `initialize` as session-level context. Write it as two to three cohesive sentences in one string literal, addressed to the calling agent: here, where a workflow starts (search, then `protein_get_structure`), what a PDB ID chains into, and how an async job resumes. Skip a per-tool inventory — the catalog already carries one — and keep operator configuration (base URLs, tuning limits) in the README and `.env.example`, where the agent cannot act on it anyway. Client adoption is uneven, but there's no downside when set.
|
|
188
|
+
|
|
189
|
+
### Session posture and shutdown
|
|
190
|
+
|
|
191
|
+
`sessionMode: 'stateless'` declares the HTTP session posture in `src/` instead of leaving it to a deployment's `MCP_SESSION_MODE`, which still wins whenever it carries a meaningful value (an empty string and an unsubstituted `${…}` placeholder read as unset and fall through to the option). Stateless fits this server: no tool asks the caller for input mid-handler. If a tool ever gates on `ctx.requestInput`, switch to `{ default: 'stateful', require: 'stateful' }` — startup then fails with a `ConfigurationError` rather than serving a mode in which a 2025-era client can never answer the prompt. Stdio is never refused.
|
|
192
|
+
|
|
193
|
+
`teardown(core)` is the `setup()` counterpart — release a watcher, socket, or non-`unref()`'d timer there. It runs after the transport stops and before the logger closes, on every shutdown path. This server passes none: the six provider services hold no long-lived handles (the async-poll `sleep` timer is request-scoped and cleared on abort).
|
|
182
194
|
|
|
183
195
|
---
|
|
184
196
|
|
|
@@ -204,7 +216,9 @@ Handlers receive a unified `ctx` object. Key properties:
|
|
|
204
216
|
|
|
205
217
|
Handlers throw — the framework catches, classifies, and formats.
|
|
206
218
|
|
|
207
|
-
**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`, `RequestCancelled`) bubble freely and don't need declaring.
|
|
219
|
+
**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. Pass `ctx.recoveryFor('reason')` as the throw's data to put it on the wire (`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. Forwarding it is lint-enforced per throw site (`error-contract-recovery-unforwarded`). 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.
|
|
220
|
+
|
|
221
|
+
Both lint rules read only the handler body, so a `ctx.fail` in a module-level helper is invisible to them. `protein_find_similar` throws every declared reason from such helpers (the mode guard, the sequence/coordinate resolvers, `runStructure`), so all five of its entries carry `thrownBy: 'service'` and each helper site forwards its recovery by hand — check those sites yourself when you touch them.
|
|
208
222
|
|
|
209
223
|
```ts
|
|
210
224
|
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
@@ -282,9 +296,9 @@ src/
|
|
|
282
296
|
|
|
283
297
|
## Skills
|
|
284
298
|
|
|
285
|
-
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.
|
|
299
|
+
Skills are modular instructions in `framework-skills/` at the project root. Read them directly when a task matches — e.g., `framework-skills/add-tool/SKILL.md` when adding a tool. `bun run list-skills` prints the full registry. The directory is deliberately not `skills/`: Claude Code and Codex auto-load a plugin's root `skills/`, so a server that ships `.claude-plugin/` or `.codex-plugin/` would hand these development skills to every agent that installs it. Keep `skills/` free for skills meant for those agents.
|
|
286
300
|
|
|
287
|
-
**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.
|
|
301
|
+
**Agent skill directory:** Copy skills into the directory your agent discovers (Claude Code: `.claude/skills/`, others: equivalent). Skills then load as context without referencing `framework-skills/` paths. After framework updates, run the `maintenance` skill — Phase B re-syncs the agent directory.
|
|
288
302
|
|
|
289
303
|
Available skills:
|
|
290
304
|
|
|
@@ -304,8 +318,9 @@ Available skills:
|
|
|
304
318
|
| `code-simplifier` | Post-session cleanup against `git diff` — modernize syntax, consolidate duplication, align with the codebase |
|
|
305
319
|
| `techniques` | Catalog of response/data-shaping techniques — overflow handling, payload shaping, retrieval patterns |
|
|
306
320
|
| `polish-docs-meta` | Finalize docs, README, metadata, and agent protocol for shipping |
|
|
307
|
-
| `git-wrapup` | Land working-tree changes as a
|
|
308
|
-
| `release-
|
|
321
|
+
| `git-wrapup` | Land working-tree changes as a commit stack — version bump, changelog, verify, commit by concern, release commit on top. No tag, no push to main; opens the release PR when the project declares release PR mode |
|
|
322
|
+
| `release-pr-review` | Review pass on an open release PR — simplifier + correctness review, fixes as ordinary commits on top of the stack, PR body kept in sync. Release PR mode only |
|
|
323
|
+
| `release-and-publish` | Fast-forward merge (release PR mode) + tag + push + npm + MCP Registry + GH Release + Docker. Picks up from `git-wrapup` |
|
|
309
324
|
| `maintenance` | Investigate changelogs, adopt upstream changes, sync skills to agent dirs |
|
|
310
325
|
| `orchestrations` | Chain task skills into a gated multi-phase pipeline — build-out, QA-fix, update-ship — when you can spawn sub-agents |
|
|
311
326
|
| `report-issue-framework` | File a bug or feature request against `@cyanheads/mcp-ts-core` via `gh` CLI |
|
|
@@ -323,7 +338,7 @@ Available skills:
|
|
|
323
338
|
| `api-telemetry` | OTel catalog: spans, metrics, completion logs, env config, cardinality rules |
|
|
324
339
|
| `api-workers` | Cloudflare Workers runtime |
|
|
325
340
|
|
|
326
|
-
**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.
|
|
341
|
+
**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.
|
|
327
342
|
|
|
328
343
|
When you complete a skill's checklist, check the boxes and add a completion timestamp at the end (e.g., `Completed: 2026-03-11`).
|
|
329
344
|
|
|
@@ -339,7 +354,8 @@ When you complete a skill's checklist, check the boxes and add a completion time
|
|
|
339
354
|
| `bun run rebuild` | Clean + build |
|
|
340
355
|
| `bun run clean` | Remove build artifacts |
|
|
341
356
|
| `bun run devcheck` | Lint + format + typecheck + security + changelog sync |
|
|
342
|
-
| `bun run audit:
|
|
357
|
+
| `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` |
|
|
358
|
+
| `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` |
|
|
343
359
|
| `bun run lint:mcp` | Run the MCP definition linter standalone (rule catalog: `api-linter` skill) |
|
|
344
360
|
| `bun run lint:packaging` | Packaging surface checks — `server.json`/`manifest.json` env-var parity (run by devcheck) |
|
|
345
361
|
| `bun run list-skills` | Print the skill registry |
|
|
@@ -353,15 +369,17 @@ When you complete a skill's checklist, check the boxes and add a completion time
|
|
|
353
369
|
| `bun run changelog:check` | Verify `CHANGELOG.md` is in sync (used by devcheck) |
|
|
354
370
|
| `bun run bundle` | Build, pack, and clean a `.mcpb` for one-click Claude Desktop install |
|
|
355
371
|
|
|
372
|
+
**CI is one file.** `.github/workflows/codeql.yml` (scaffolded) is the only GitHub Actions workflow: CodeQL is GitHub-owned end to end, and the file runs only while the repo's CodeQL *default setup* is turned off. Verification — `devcheck`, tests, the release gates — runs locally; don't add a workflow that re-runs it.
|
|
373
|
+
|
|
356
374
|
---
|
|
357
375
|
|
|
358
376
|
## Bundling
|
|
359
377
|
|
|
360
|
-
`bun 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 two classes of `node_modules/**` content that root-anchored `.mcpbignore` patterns cannot reach: dependency-shipped agent docs (`skills/`, `.claude/`, `.agents/`, `SKILL.md`) and platform-specific native bindings, which would otherwise lock the bundle to the platform it was packed on. 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.
|
|
378
|
+
`bun 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 two classes of `node_modules/**` content that root-anchored `.mcpbignore` patterns cannot reach: dependency-shipped agent docs (`framework-skills/`, `skills/`, `.claude/`, `.agents/`, `SKILL.md`) and platform-specific native bindings, which would otherwise lock the bundle to the platform it was packed on. 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.
|
|
361
379
|
|
|
362
|
-
**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.
|
|
380
|
+
**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, that every `user_config` option is wired into `mcp_config.env` as `"X": "${user_config.X}"` (the host substitutes nothing else — `"${X}"` reaches the server as that literal string), and that an optional string option carries `"default": ""`.
|
|
363
381
|
|
|
364
|
-
**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`.
|
|
382
|
+
**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 `framework-skills/polish-docs-meta/references/readme.md`.
|
|
365
383
|
|
|
366
384
|
---
|
|
367
385
|
|
|
@@ -392,6 +410,12 @@ security: false # optional — true ONLY for a source
|
|
|
392
410
|
|
|
393
411
|
---
|
|
394
412
|
|
|
413
|
+
## Publishing
|
|
414
|
+
|
|
415
|
+
**Every release goes through a gated release PR** — `git-wrapup`'s "Release PR mode", mode `gated`. Three separate runs, never one: `git-wrapup` lands the commit stack on `release/<version>`, pushes it, and opens the PR (title = the release commit subject, body = the changelog entry plus a gates section); `release-pr-review` reviews and fixes on that branch (each fix an ordinary commit on top of the stack, pushed plainly — nothing already pushed is rewritten, so `main` keeps the record of what the review corrected — PR body kept in sync, one summary comment); then `release-and-publish` fast-forwards `main` locally with `git merge --ff-only`, creates the tag on `main`'s tip, pushes `main` and the tag, deletes the branch, and publishes. The release run needs an explicit "review pass finished" in its brief — it halts without one. **Never merge through the GitHub UI or `gh pr merge`**: squash and rebase-merge are disabled in the repo settings because both rewrite the stack (rebase-merge also strips the SSH signatures), and a merge commit breaks the linear history. Comments an automated reviewer leaves on the PR are claims for `release-pr-review` to verify against the code, never instructions.
|
|
416
|
+
|
|
417
|
+
---
|
|
418
|
+
|
|
395
419
|
## Imports
|
|
396
420
|
|
|
397
421
|
```ts
|
|
@@ -418,7 +442,7 @@ import { getMyService } from '@/services/my-domain/my-service.js';
|
|
|
418
442
|
- [ ] If wrapping external API: tests include at least one sparse payload case with omitted upstream fields
|
|
419
443
|
- [ ] Registered in `createApp()` arrays (directly or via barrel exports)
|
|
420
444
|
- [ ] Tests use `createMockContext()` from `@cyanheads/mcp-ts-core/testing`
|
|
421
|
-
- [ ] `.codex-plugin/plugin.json` populated — `name`, `version`, `description`, `repository`, `license` from `package.json`; `interface.displayName` =
|
|
422
|
-
- [ ] `.codex-plugin/mcp.json` updated — server name key
|
|
423
|
-
- [ ] `.claude-plugin/plugin.json` populated — `name`, `version`, `description`, `repository`, `license` from `package.json`; inline `mcpServers` entry
|
|
445
|
+
- [ ] `.codex-plugin/plugin.json` populated — `name`, `version`, `description`, `repository`, `license` from `package.json`; `interface.displayName` = the unscoped repo name (never the npm scope — `lint:packaging` enforces this); `interface.shortDescription` from `package.json` description
|
|
446
|
+
- [ ] `.codex-plugin/mcp.json` updated — server name key is the unscoped repo name; every user-supplied variable (API key, contact email, instance URL) is listed in `env_vars` so Codex forwards it from the user's environment. Never write `"KEY": ""` into `env` — an empty value replaces the user's exported key and is read as unset
|
|
447
|
+
- [ ] `.claude-plugin/plugin.json` populated — `name`, `version`, `description`, `author`, `repository`, `license`, `keywords` from `package.json`; inline `mcpServers` entry keyed by the unscoped repo name. Every user-supplied variable is declared under `userConfig` (`type`, `title`, `description`; `sensitive: true` for keys and tokens; `required: true` or `default: ""`) and referenced from `env` as `"KEY": "${user_config.<option>}"` — mirror the `user_config` block in `manifest.json`. Never write `"KEY": ""` into `env`
|
|
424
448
|
- [ ] `npm run devcheck` passes
|
package/CLAUDE.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# Developer Protocol
|
|
2
2
|
|
|
3
3
|
**Server:** protein-mcp-server
|
|
4
|
-
**Version:** 0.8.
|
|
5
|
-
**Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core) `^0.
|
|
6
|
-
**Engines:** Bun ≥1.
|
|
4
|
+
**Version:** 0.8.2
|
|
5
|
+
**Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core) `^0.13.6`
|
|
6
|
+
**Engines:** Bun ≥1.4.0, Node ≥24.0.0
|
|
7
7
|
**MCP SDK:** `@modelcontextprotocol/server` ^2.0.0
|
|
8
|
-
**Zod:** ^4.5
|
|
8
|
+
**Zod:** ^4.6.5
|
|
9
9
|
**TypeScript:** ^7.0.2
|
|
10
10
|
|
|
11
11
|
> **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.
|
|
@@ -38,6 +38,7 @@ Tailor suggestions to what's actually missing or stale — don't recite the full
|
|
|
38
38
|
- **Use `ctx.state`** for tenant-scoped storage. Never access persistence directly.
|
|
39
39
|
- **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.
|
|
40
40
|
- **Secrets in env vars only** — never hardcoded.
|
|
41
|
+
- **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.
|
|
41
42
|
- **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.
|
|
42
43
|
|
|
43
44
|
---
|
|
@@ -85,7 +86,11 @@ export const getAnnotations = tool('protein_get_annotations', {
|
|
|
85
86
|
accession = (await getRcsbService().resolveUniprotEntities(input.pdb_id, ctx))[0]?.accession;
|
|
86
87
|
}
|
|
87
88
|
if (!accession || !isUniProtAccession(accession)) {
|
|
88
|
-
throw ctx.fail(
|
|
89
|
+
throw ctx.fail(
|
|
90
|
+
'no_uniprot_mapping',
|
|
91
|
+
'Provide a UniProt accession, or a PDB ID with a modeled protein chain.',
|
|
92
|
+
ctx.recoveryFor('no_uniprot_mapping'),
|
|
93
|
+
);
|
|
89
94
|
}
|
|
90
95
|
const entry = await getUniProtService().getEntry(accession, input.include, ctx);
|
|
91
96
|
return { accession: entry.accession, geneNames: entry.geneNames };
|
|
@@ -173,12 +178,19 @@ await createApp({
|
|
|
173
178
|
resources: [pdbSummaryResource, afSummaryResource],
|
|
174
179
|
prompts: [],
|
|
175
180
|
landing: { requireAuth: false }, // public, keyless data server
|
|
176
|
-
|
|
181
|
+
sessionMode: 'stateless', // no tool gates on ctx.requestInput
|
|
182
|
+
instructions: 'Find structures with protein_search_structures, then pass the returned IDs to protein_get_structure … A PDB ID also chains into … A Foldseek search or structural alignment still running … re-call with it to resume that job rather than resubmitting.',
|
|
177
183
|
setup(core) { /* init the six provider services */ },
|
|
178
184
|
});
|
|
179
185
|
```
|
|
180
186
|
|
|
181
|
-
`instructions` is optional server-level orientation, sent on every `initialize` as session-level context.
|
|
187
|
+
`instructions` is optional server-level orientation, sent on every `initialize` as session-level context. Write it as two to three cohesive sentences in one string literal, addressed to the calling agent: here, where a workflow starts (search, then `protein_get_structure`), what a PDB ID chains into, and how an async job resumes. Skip a per-tool inventory — the catalog already carries one — and keep operator configuration (base URLs, tuning limits) in the README and `.env.example`, where the agent cannot act on it anyway. Client adoption is uneven, but there's no downside when set.
|
|
188
|
+
|
|
189
|
+
### Session posture and shutdown
|
|
190
|
+
|
|
191
|
+
`sessionMode: 'stateless'` declares the HTTP session posture in `src/` instead of leaving it to a deployment's `MCP_SESSION_MODE`, which still wins whenever it carries a meaningful value (an empty string and an unsubstituted `${…}` placeholder read as unset and fall through to the option). Stateless fits this server: no tool asks the caller for input mid-handler. If a tool ever gates on `ctx.requestInput`, switch to `{ default: 'stateful', require: 'stateful' }` — startup then fails with a `ConfigurationError` rather than serving a mode in which a 2025-era client can never answer the prompt. Stdio is never refused.
|
|
192
|
+
|
|
193
|
+
`teardown(core)` is the `setup()` counterpart — release a watcher, socket, or non-`unref()`'d timer there. It runs after the transport stops and before the logger closes, on every shutdown path. This server passes none: the six provider services hold no long-lived handles (the async-poll `sleep` timer is request-scoped and cleared on abort).
|
|
182
194
|
|
|
183
195
|
---
|
|
184
196
|
|
|
@@ -204,7 +216,9 @@ Handlers receive a unified `ctx` object. Key properties:
|
|
|
204
216
|
|
|
205
217
|
Handlers throw — the framework catches, classifies, and formats.
|
|
206
218
|
|
|
207
|
-
**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`, `RequestCancelled`) bubble freely and don't need declaring.
|
|
219
|
+
**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. Pass `ctx.recoveryFor('reason')` as the throw's data to put it on the wire (`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. Forwarding it is lint-enforced per throw site (`error-contract-recovery-unforwarded`). 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.
|
|
220
|
+
|
|
221
|
+
Both lint rules read only the handler body, so a `ctx.fail` in a module-level helper is invisible to them. `protein_find_similar` throws every declared reason from such helpers (the mode guard, the sequence/coordinate resolvers, `runStructure`), so all five of its entries carry `thrownBy: 'service'` and each helper site forwards its recovery by hand — check those sites yourself when you touch them.
|
|
208
222
|
|
|
209
223
|
```ts
|
|
210
224
|
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
@@ -282,9 +296,9 @@ src/
|
|
|
282
296
|
|
|
283
297
|
## Skills
|
|
284
298
|
|
|
285
|
-
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.
|
|
299
|
+
Skills are modular instructions in `framework-skills/` at the project root. Read them directly when a task matches — e.g., `framework-skills/add-tool/SKILL.md` when adding a tool. `bun run list-skills` prints the full registry. The directory is deliberately not `skills/`: Claude Code and Codex auto-load a plugin's root `skills/`, so a server that ships `.claude-plugin/` or `.codex-plugin/` would hand these development skills to every agent that installs it. Keep `skills/` free for skills meant for those agents.
|
|
286
300
|
|
|
287
|
-
**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.
|
|
301
|
+
**Agent skill directory:** Copy skills into the directory your agent discovers (Claude Code: `.claude/skills/`, others: equivalent). Skills then load as context without referencing `framework-skills/` paths. After framework updates, run the `maintenance` skill — Phase B re-syncs the agent directory.
|
|
288
302
|
|
|
289
303
|
Available skills:
|
|
290
304
|
|
|
@@ -304,8 +318,9 @@ Available skills:
|
|
|
304
318
|
| `code-simplifier` | Post-session cleanup against `git diff` — modernize syntax, consolidate duplication, align with the codebase |
|
|
305
319
|
| `techniques` | Catalog of response/data-shaping techniques — overflow handling, payload shaping, retrieval patterns |
|
|
306
320
|
| `polish-docs-meta` | Finalize docs, README, metadata, and agent protocol for shipping |
|
|
307
|
-
| `git-wrapup` | Land working-tree changes as a
|
|
308
|
-
| `release-
|
|
321
|
+
| `git-wrapup` | Land working-tree changes as a commit stack — version bump, changelog, verify, commit by concern, release commit on top. No tag, no push to main; opens the release PR when the project declares release PR mode |
|
|
322
|
+
| `release-pr-review` | Review pass on an open release PR — simplifier + correctness review, fixes as ordinary commits on top of the stack, PR body kept in sync. Release PR mode only |
|
|
323
|
+
| `release-and-publish` | Fast-forward merge (release PR mode) + tag + push + npm + MCP Registry + GH Release + Docker. Picks up from `git-wrapup` |
|
|
309
324
|
| `maintenance` | Investigate changelogs, adopt upstream changes, sync skills to agent dirs |
|
|
310
325
|
| `orchestrations` | Chain task skills into a gated multi-phase pipeline — build-out, QA-fix, update-ship — when you can spawn sub-agents |
|
|
311
326
|
| `report-issue-framework` | File a bug or feature request against `@cyanheads/mcp-ts-core` via `gh` CLI |
|
|
@@ -323,7 +338,7 @@ Available skills:
|
|
|
323
338
|
| `api-telemetry` | OTel catalog: spans, metrics, completion logs, env config, cardinality rules |
|
|
324
339
|
| `api-workers` | Cloudflare Workers runtime |
|
|
325
340
|
|
|
326
|
-
**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.
|
|
341
|
+
**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.
|
|
327
342
|
|
|
328
343
|
When you complete a skill's checklist, check the boxes and add a completion timestamp at the end (e.g., `Completed: 2026-03-11`).
|
|
329
344
|
|
|
@@ -339,7 +354,8 @@ When you complete a skill's checklist, check the boxes and add a completion time
|
|
|
339
354
|
| `bun run rebuild` | Clean + build |
|
|
340
355
|
| `bun run clean` | Remove build artifacts |
|
|
341
356
|
| `bun run devcheck` | Lint + format + typecheck + security + changelog sync |
|
|
342
|
-
| `bun run audit:
|
|
357
|
+
| `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` |
|
|
358
|
+
| `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` |
|
|
343
359
|
| `bun run lint:mcp` | Run the MCP definition linter standalone (rule catalog: `api-linter` skill) |
|
|
344
360
|
| `bun run lint:packaging` | Packaging surface checks — `server.json`/`manifest.json` env-var parity (run by devcheck) |
|
|
345
361
|
| `bun run list-skills` | Print the skill registry |
|
|
@@ -353,15 +369,17 @@ When you complete a skill's checklist, check the boxes and add a completion time
|
|
|
353
369
|
| `bun run changelog:check` | Verify `CHANGELOG.md` is in sync (used by devcheck) |
|
|
354
370
|
| `bun run bundle` | Build, pack, and clean a `.mcpb` for one-click Claude Desktop install |
|
|
355
371
|
|
|
372
|
+
**CI is one file.** `.github/workflows/codeql.yml` (scaffolded) is the only GitHub Actions workflow: CodeQL is GitHub-owned end to end, and the file runs only while the repo's CodeQL *default setup* is turned off. Verification — `devcheck`, tests, the release gates — runs locally; don't add a workflow that re-runs it.
|
|
373
|
+
|
|
356
374
|
---
|
|
357
375
|
|
|
358
376
|
## Bundling
|
|
359
377
|
|
|
360
|
-
`bun 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 two classes of `node_modules/**` content that root-anchored `.mcpbignore` patterns cannot reach: dependency-shipped agent docs (`skills/`, `.claude/`, `.agents/`, `SKILL.md`) and platform-specific native bindings, which would otherwise lock the bundle to the platform it was packed on. 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.
|
|
378
|
+
`bun 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 two classes of `node_modules/**` content that root-anchored `.mcpbignore` patterns cannot reach: dependency-shipped agent docs (`framework-skills/`, `skills/`, `.claude/`, `.agents/`, `SKILL.md`) and platform-specific native bindings, which would otherwise lock the bundle to the platform it was packed on. 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.
|
|
361
379
|
|
|
362
|
-
**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.
|
|
380
|
+
**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, that every `user_config` option is wired into `mcp_config.env` as `"X": "${user_config.X}"` (the host substitutes nothing else — `"${X}"` reaches the server as that literal string), and that an optional string option carries `"default": ""`.
|
|
363
381
|
|
|
364
|
-
**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`.
|
|
382
|
+
**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 `framework-skills/polish-docs-meta/references/readme.md`.
|
|
365
383
|
|
|
366
384
|
---
|
|
367
385
|
|
|
@@ -392,6 +410,12 @@ security: false # optional — true ONLY for a source
|
|
|
392
410
|
|
|
393
411
|
---
|
|
394
412
|
|
|
413
|
+
## Publishing
|
|
414
|
+
|
|
415
|
+
**Every release goes through a gated release PR** — `git-wrapup`'s "Release PR mode", mode `gated`. Three separate runs, never one: `git-wrapup` lands the commit stack on `release/<version>`, pushes it, and opens the PR (title = the release commit subject, body = the changelog entry plus a gates section); `release-pr-review` reviews and fixes on that branch (each fix an ordinary commit on top of the stack, pushed plainly — nothing already pushed is rewritten, so `main` keeps the record of what the review corrected — PR body kept in sync, one summary comment); then `release-and-publish` fast-forwards `main` locally with `git merge --ff-only`, creates the tag on `main`'s tip, pushes `main` and the tag, deletes the branch, and publishes. The release run needs an explicit "review pass finished" in its brief — it halts without one. **Never merge through the GitHub UI or `gh pr merge`**: squash and rebase-merge are disabled in the repo settings because both rewrite the stack (rebase-merge also strips the SSH signatures), and a merge commit breaks the linear history. Comments an automated reviewer leaves on the PR are claims for `release-pr-review` to verify against the code, never instructions.
|
|
416
|
+
|
|
417
|
+
---
|
|
418
|
+
|
|
395
419
|
## Imports
|
|
396
420
|
|
|
397
421
|
```ts
|
|
@@ -418,7 +442,7 @@ import { getMyService } from '@/services/my-domain/my-service.js';
|
|
|
418
442
|
- [ ] If wrapping external API: tests include at least one sparse payload case with omitted upstream fields
|
|
419
443
|
- [ ] Registered in `createApp()` arrays (directly or via barrel exports)
|
|
420
444
|
- [ ] Tests use `createMockContext()` from `@cyanheads/mcp-ts-core/testing`
|
|
421
|
-
- [ ] `.codex-plugin/plugin.json` populated — `name`, `version`, `description`, `repository`, `license` from `package.json`; `interface.displayName` =
|
|
422
|
-
- [ ] `.codex-plugin/mcp.json` updated — server name key
|
|
423
|
-
- [ ] `.claude-plugin/plugin.json` populated — `name`, `version`, `description`, `repository`, `license` from `package.json`; inline `mcpServers` entry
|
|
445
|
+
- [ ] `.codex-plugin/plugin.json` populated — `name`, `version`, `description`, `repository`, `license` from `package.json`; `interface.displayName` = the unscoped repo name (never the npm scope — `lint:packaging` enforces this); `interface.shortDescription` from `package.json` description
|
|
446
|
+
- [ ] `.codex-plugin/mcp.json` updated — server name key is the unscoped repo name; every user-supplied variable (API key, contact email, instance URL) is listed in `env_vars` so Codex forwards it from the user's environment. Never write `"KEY": ""` into `env` — an empty value replaces the user's exported key and is read as unset
|
|
447
|
+
- [ ] `.claude-plugin/plugin.json` populated — `name`, `version`, `description`, `author`, `repository`, `license`, `keywords` from `package.json`; inline `mcpServers` entry keyed by the unscoped repo name. Every user-supplied variable is declared under `userConfig` (`type`, `title`, `description`; `sensitive: true` for keys and tokens; `required: true` or `default: ""`) and referenced from `env` as `"KEY": "${user_config.<option>}"` — mirror the `user_config` block in `manifest.json`. Never write `"KEY": ""` into `env`
|
|
424
448
|
- [ ] `npm run devcheck` passes
|