@cyanheads/mcp-ts-core 0.9.12 → 0.9.14

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 (72) hide show
  1. package/CLAUDE.md +6 -3
  2. package/README.md +30 -41
  3. package/changelog/0.9.x/0.9.13.md +33 -0
  4. package/changelog/0.9.x/0.9.14.md +31 -0
  5. package/dist/config/index.d.ts +3 -0
  6. package/dist/config/index.d.ts.map +1 -1
  7. package/dist/config/index.js +20 -0
  8. package/dist/config/index.js.map +1 -1
  9. package/dist/core/context.d.ts +103 -14
  10. package/dist/core/context.d.ts.map +1 -1
  11. package/dist/core/context.js +66 -1
  12. package/dist/core/context.js.map +1 -1
  13. package/dist/core/index.d.ts +1 -1
  14. package/dist/core/index.d.ts.map +1 -1
  15. package/dist/core/index.js.map +1 -1
  16. package/dist/core/serverManifest.d.ts +12 -1
  17. package/dist/core/serverManifest.d.ts.map +1 -1
  18. package/dist/core/serverManifest.js +4 -1
  19. package/dist/core/serverManifest.js.map +1 -1
  20. package/dist/linter/rules/enrichment-rules.d.ts +32 -0
  21. package/dist/linter/rules/enrichment-rules.d.ts.map +1 -0
  22. package/dist/linter/rules/enrichment-rules.js +116 -0
  23. package/dist/linter/rules/enrichment-rules.js.map +1 -0
  24. package/dist/linter/rules/index.d.ts +1 -0
  25. package/dist/linter/rules/index.d.ts.map +1 -1
  26. package/dist/linter/rules/index.js +1 -0
  27. package/dist/linter/rules/index.js.map +1 -1
  28. package/dist/linter/rules/tool-rules.d.ts.map +1 -1
  29. package/dist/linter/rules/tool-rules.js +4 -0
  30. package/dist/linter/rules/tool-rules.js.map +1 -1
  31. package/dist/mcp-server/tools/tool-registration.d.ts.map +1 -1
  32. package/dist/mcp-server/tools/tool-registration.js +7 -7
  33. package/dist/mcp-server/tools/tool-registration.js.map +1 -1
  34. package/dist/mcp-server/tools/utils/toolDefinition.d.ts +41 -7
  35. package/dist/mcp-server/tools/utils/toolDefinition.d.ts.map +1 -1
  36. package/dist/mcp-server/tools/utils/toolDefinition.js.map +1 -1
  37. package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts +23 -1
  38. package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts.map +1 -1
  39. package/dist/mcp-server/tools/utils/toolHandlerFactory.js +90 -9
  40. package/dist/mcp-server/tools/utils/toolHandlerFactory.js.map +1 -1
  41. package/dist/mcp-server/transports/http/httpTransport.d.ts.map +1 -1
  42. package/dist/mcp-server/transports/http/httpTransport.js +40 -0
  43. package/dist/mcp-server/transports/http/httpTransport.js.map +1 -1
  44. package/dist/testing/index.d.ts +13 -0
  45. package/dist/testing/index.d.ts.map +1 -1
  46. package/dist/testing/index.js +21 -1
  47. package/dist/testing/index.js.map +1 -1
  48. package/dist/utils/internal/performance.d.ts +5 -1
  49. package/dist/utils/internal/performance.d.ts.map +1 -1
  50. package/dist/utils/internal/performance.js +10 -1
  51. package/dist/utils/internal/performance.js.map +1 -1
  52. package/dist/utils/telemetry/attributes.d.ts +2 -0
  53. package/dist/utils/telemetry/attributes.d.ts.map +1 -1
  54. package/dist/utils/telemetry/attributes.js +2 -0
  55. package/dist/utils/telemetry/attributes.js.map +1 -1
  56. package/package.json +2 -2
  57. package/scripts/check-docs-sync.ts +50 -32
  58. package/skills/add-tool/SKILL.md +57 -32
  59. package/skills/api-canvas/SKILL.md +106 -1
  60. package/skills/api-config/SKILL.md +2 -1
  61. package/skills/api-context/SKILL.md +65 -2
  62. package/skills/api-linter/SKILL.md +48 -1
  63. package/skills/design-mcp-server/SKILL.md +2 -1
  64. package/skills/orchestrations/SKILL.md +9 -5
  65. package/skills/polish-docs-meta/SKILL.md +1 -2
  66. package/skills/polish-docs-meta/references/readme.md +15 -1
  67. package/skills/report-issue-framework/SKILL.md +8 -3
  68. package/skills/report-issue-local/SKILL.md +8 -3
  69. package/templates/.env.example +1 -0
  70. package/templates/AGENTS.md +8 -35
  71. package/templates/CLAUDE.md +8 -36
  72. package/templates/src/mcp-server/tools/definitions/echo.tool.ts +10 -0
@@ -152,6 +152,10 @@ export function getServerConfig() {
152
152
 
153
153
  `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.
154
154
 
155
+ ### Server instructions
156
+
157
+ `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.
158
+
155
159
  ---
156
160
 
157
161
  ## Context
@@ -178,6 +182,8 @@ Handlers throw — the framework catches, classifies, and formats.
178
182
  **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.
179
183
 
180
184
  ```ts
185
+ import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
186
+
181
187
  errors: [
182
188
  { reason: 'no_match', code: JsonRpcErrorCode.NotFound,
183
189
  when: 'No item matched the query',
@@ -272,7 +278,6 @@ Available skills:
272
278
  | `polish-docs-meta` | Finalize docs, README, metadata, and agent protocol for shipping |
273
279
  | `git-wrapup` | Land working-tree changes as a versioned commit + annotated tag — version bump, changelog, verify, tag. Local only. |
274
280
  | `release-and-publish` | Push + npm + MCP Registry + GH Release + Docker. Picks up from `git-wrapup` |
275
- | `migrate-mcp-ts-template` | One-time migration of an existing project to the current framework template |
276
281
  | `maintenance` | Investigate changelogs, adopt upstream changes, sync skills to agent dirs |
277
282
  | `report-issue-framework` | File a bug or feature request against `@cyanheads/mcp-ts-core` via `gh` CLI |
278
283
  | `report-issue-local` | File a bug or feature request against this server's own repo via `gh` CLI |
@@ -302,7 +307,7 @@ When you complete a skill's checklist, check the boxes and add a completion time
302
307
  | `npm run rebuild` | Clean + build |
303
308
  | `npm run clean` | Remove build artifacts |
304
309
  | `npm run devcheck` | Lint + format + typecheck + security + changelog sync |
305
- | `bun run audit:refresh` | Delete `bun.lock`, reinstall, re-audit. Use when `devcheck` flags a transitive advisory — stale lockfile can mask already-patched deps. If advisory survives, it's real. |
310
+ | `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. |
306
311
  | `npm run tree` | Generate directory structure doc |
307
312
  | `npm run format` | Auto-fix formatting |
308
313
  | `npm test` | Run tests |
@@ -320,40 +325,7 @@ When you complete a skill's checklist, check the boxes and add a completion time
320
325
 
321
326
  **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.
322
327
 
323
- **README install badges.** Drop these into the project README to give users one-click install paths. Fill in `<OWNER>` / `<REPO>` / `<PACKAGE_NAME>` and encode the per-server config. Cursor + VS Code badges assume the server is published to npm; Claude Desktop downloads the `.mcpb` directly so npm publishing isn't required.
324
-
325
- | Client | Mechanism |
326
- |:-------|:----------|
327
- | Claude Desktop | Browser downloads the `.mcpb` from the latest GitHub Release; OS file handler routes it to Claude Desktop, which opens the install dialog. No deep-link URL scheme yet — this is the canonical path. |
328
- | Cursor | Official `https://cursor.com/en/install-mcp` endpoint with base64 JSON config. |
329
- | VS Code / Insiders | Official `vscode:mcp/install?...` deep link, wrapped in `https://vscode.dev/redirect?url=` so GitHub-rendered markdown doesn't strip the non-HTTP scheme. |
330
- | Claude Code / Codex | CLI only (`claude mcp add` / `codex mcp add`); no URL scheme. |
331
-
332
- ```markdown
333
- [![Install in Claude Desktop](https://img.shields.io/badge/Install_in-Claude_Desktop-D97757?style=for-the-badge&logo=anthropic&logoColor=white)](https://github.com/<OWNER>/<REPO>/releases/latest/download/<PACKAGE_NAME>.mcpb)
334
- [![Install in Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en/install-mcp?name=<PACKAGE_NAME>&config=<BASE64_CONFIG>)
335
- [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install_Server-0098FF?style=for-the-badge&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode:mcp/install?<URLENCODED_JSON>)
336
- ```
337
-
338
- Both install links route through HTTPS endpoints (`cursor.com/en/install-mcp` and `vscode.dev/redirect`) — GitHub-rendered markdown strips non-HTTP URL schemes from anchors, so a raw `cursor://` or `vscode:` link won't click through from github.com.
339
-
340
- Generate the encoded configs (replace `<PACKAGE_NAME>` and add env vars for any required API keys):
341
-
342
- ```bash
343
- # Cursor: base64-encoded JSON. Split command/args, add env when keys are needed.
344
- echo -n '{"command":"npx","args":["-y","<PACKAGE_NAME>"],"env":{"API_KEY":"your-api-key"}}' | base64
345
- # Without env (no required keys):
346
- echo -n '{"command":"npx","args":["-y","<PACKAGE_NAME>"]}' | base64
347
-
348
- # VS Code: URL-encoded JSON. Same shape plus a `name` field.
349
- node -p 'encodeURIComponent(JSON.stringify({name:"<SHORT_NAME>",command:"npx",args:["-y","<PACKAGE_NAME>"],env:{API_KEY:"your-api-key"}}))'
350
- # Without env:
351
- node -p 'encodeURIComponent(JSON.stringify({name:"<SHORT_NAME>",command:"npx",args:["-y","<PACKAGE_NAME>"]}))'
352
- ```
353
-
354
- Both clients use the same `{command, args, env}` shape (matching `mcp.json` schema). VS Code adds a top-level `name` field. Omit `env` entirely when no API keys are needed — don't include empty objects or framework-only vars like `MCP_TRANSPORT_TYPE`.
355
-
356
- The Claude Desktop badge requires the bundle to ship with a stable filename — `bun run bundle` outputs `dist/<PACKAGE_NAME>.mcpb`, and `release-and-publish` attaches that file to the GitHub Release. `releases/latest/download/<PACKAGE_NAME>.mcpb` then redirects to the most recent release.
328
+ **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`.
357
329
 
358
330
  ---
359
331
 
@@ -18,6 +18,14 @@ export const echoTool = tool('template_echo_message', {
18
18
  message: z.string().describe('The echoed message.'),
19
19
  }),
20
20
 
21
+ // Agent-facing context on the success path — the counterpart to errors[]. Merged
22
+ // into structuredContent AND mirrored into content[] automatically (no format()
23
+ // entry needed). Declare the fields here; populate via ctx.enrich(...) in the
24
+ // handler or service layer. Delete this block if your tool has no such context.
25
+ enrichment: {
26
+ characterCount: z.number().describe('Length of the echoed message.'),
27
+ },
28
+
21
29
  // Declare each domain failure mode the agent should plan around. The framework
22
30
  // types `ctx.fail(reason, …)` against the declared union. Baseline codes
23
31
  // (InternalError, ServiceUnavailable, Timeout, ValidationError,
@@ -36,6 +44,8 @@ export const echoTool = tool('template_echo_message', {
36
44
  if (input.message.trim().length === 0) {
37
45
  throw ctx.fail('empty_message', 'Message must contain at least one non-whitespace character.');
38
46
  }
47
+ // Reaches both client surfaces with no format() plumbing.
48
+ ctx.enrich({ characterCount: input.message.length });
39
49
  return { message: input.message };
40
50
  },
41
51