wsdot-mcp-server 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/CLAUDE.md +343 -0
  2. package/Dockerfile +99 -0
  3. package/LICENSE +201 -0
  4. package/README.md +364 -0
  5. package/changelog/0.1.x/0.1.0.md +24 -0
  6. package/changelog/0.1.x/0.1.1.md +26 -0
  7. package/changelog/template.md +119 -0
  8. package/dist/config/server-config.d.ts +12 -0
  9. package/dist/config/server-config.d.ts.map +1 -0
  10. package/dist/config/server-config.js +19 -0
  11. package/dist/config/server-config.js.map +1 -0
  12. package/dist/index.d.ts +7 -0
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +33 -0
  15. package/dist/index.js.map +1 -0
  16. package/dist/mcp-server/tools/definitions/get-border-waits.tool.d.ts +28 -0
  17. package/dist/mcp-server/tools/definitions/get-border-waits.tool.d.ts.map +1 -0
  18. package/dist/mcp-server/tools/definitions/get-border-waits.tool.js +83 -0
  19. package/dist/mcp-server/tools/definitions/get-border-waits.tool.js.map +1 -0
  20. package/dist/mcp-server/tools/definitions/get-ferry-alerts.tool.d.ts +22 -0
  21. package/dist/mcp-server/tools/definitions/get-ferry-alerts.tool.d.ts.map +1 -0
  22. package/dist/mcp-server/tools/definitions/get-ferry-alerts.tool.js +67 -0
  23. package/dist/mcp-server/tools/definitions/get-ferry-alerts.tool.js.map +1 -0
  24. package/dist/mcp-server/tools/definitions/get-ferry-routes.tool.d.ts +33 -0
  25. package/dist/mcp-server/tools/definitions/get-ferry-routes.tool.d.ts.map +1 -0
  26. package/dist/mcp-server/tools/definitions/get-ferry-routes.tool.js +95 -0
  27. package/dist/mcp-server/tools/definitions/get-ferry-routes.tool.js.map +1 -0
  28. package/dist/mcp-server/tools/definitions/get-ferry-schedule.tool.d.ts +41 -0
  29. package/dist/mcp-server/tools/definitions/get-ferry-schedule.tool.d.ts.map +1 -0
  30. package/dist/mcp-server/tools/definitions/get-ferry-schedule.tool.js +117 -0
  31. package/dist/mcp-server/tools/definitions/get-ferry-schedule.tool.js.map +1 -0
  32. package/dist/mcp-server/tools/definitions/get-ferry-terminals.tool.d.ts +23 -0
  33. package/dist/mcp-server/tools/definitions/get-ferry-terminals.tool.d.ts.map +1 -0
  34. package/dist/mcp-server/tools/definitions/get-ferry-terminals.tool.js +56 -0
  35. package/dist/mcp-server/tools/definitions/get-ferry-terminals.tool.js.map +1 -0
  36. package/dist/mcp-server/tools/definitions/get-mountain-passes.tool.d.ts +35 -0
  37. package/dist/mcp-server/tools/definitions/get-mountain-passes.tool.d.ts.map +1 -0
  38. package/dist/mcp-server/tools/definitions/get-mountain-passes.tool.js +116 -0
  39. package/dist/mcp-server/tools/definitions/get-mountain-passes.tool.js.map +1 -0
  40. package/dist/mcp-server/tools/definitions/get-terminal-space.tool.d.ts +32 -0
  41. package/dist/mcp-server/tools/definitions/get-terminal-space.tool.d.ts.map +1 -0
  42. package/dist/mcp-server/tools/definitions/get-terminal-space.tool.js +118 -0
  43. package/dist/mcp-server/tools/definitions/get-terminal-space.tool.js.map +1 -0
  44. package/dist/mcp-server/tools/definitions/get-toll-rates.tool.d.ts +29 -0
  45. package/dist/mcp-server/tools/definitions/get-toll-rates.tool.d.ts.map +1 -0
  46. package/dist/mcp-server/tools/definitions/get-toll-rates.tool.js +85 -0
  47. package/dist/mcp-server/tools/definitions/get-toll-rates.tool.js.map +1 -0
  48. package/dist/mcp-server/tools/definitions/get-travel-times.tool.d.ts +38 -0
  49. package/dist/mcp-server/tools/definitions/get-travel-times.tool.d.ts.map +1 -0
  50. package/dist/mcp-server/tools/definitions/get-travel-times.tool.js +141 -0
  51. package/dist/mcp-server/tools/definitions/get-travel-times.tool.js.map +1 -0
  52. package/dist/mcp-server/tools/definitions/get-vessel-locations.tool.d.ts +35 -0
  53. package/dist/mcp-server/tools/definitions/get-vessel-locations.tool.d.ts.map +1 -0
  54. package/dist/mcp-server/tools/definitions/get-vessel-locations.tool.js +120 -0
  55. package/dist/mcp-server/tools/definitions/get-vessel-locations.tool.js.map +1 -0
  56. package/dist/mcp-server/tools/definitions/index.d.ts +17 -0
  57. package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -0
  58. package/dist/mcp-server/tools/definitions/index.js +17 -0
  59. package/dist/mcp-server/tools/definitions/index.js.map +1 -0
  60. package/dist/mcp-server/tools/definitions/search-alerts.tool.d.ts +48 -0
  61. package/dist/mcp-server/tools/definitions/search-alerts.tool.d.ts.map +1 -0
  62. package/dist/mcp-server/tools/definitions/search-alerts.tool.js +155 -0
  63. package/dist/mcp-server/tools/definitions/search-alerts.tool.js.map +1 -0
  64. package/dist/mcp-server/tools/definitions/search-cameras.tool.d.ts +36 -0
  65. package/dist/mcp-server/tools/definitions/search-cameras.tool.d.ts.map +1 -0
  66. package/dist/mcp-server/tools/definitions/search-cameras.tool.js +116 -0
  67. package/dist/mcp-server/tools/definitions/search-cameras.tool.js.map +1 -0
  68. package/dist/services/ferry/ferry-service.d.ts +28 -0
  69. package/dist/services/ferry/ferry-service.d.ts.map +1 -0
  70. package/dist/services/ferry/ferry-service.js +222 -0
  71. package/dist/services/ferry/ferry-service.js.map +1 -0
  72. package/dist/services/ferry/types.d.ts +183 -0
  73. package/dist/services/ferry/types.d.ts.map +1 -0
  74. package/dist/services/ferry/types.js +6 -0
  75. package/dist/services/ferry/types.js.map +1 -0
  76. package/dist/services/traffic/traffic-service.d.ts +37 -0
  77. package/dist/services/traffic/traffic-service.d.ts.map +1 -0
  78. package/dist/services/traffic/traffic-service.js +290 -0
  79. package/dist/services/traffic/traffic-service.js.map +1 -0
  80. package/dist/services/traffic/types.d.ts +247 -0
  81. package/dist/services/traffic/types.d.ts.map +1 -0
  82. package/dist/services/traffic/types.js +6 -0
  83. package/dist/services/traffic/types.js.map +1 -0
  84. package/package.json +89 -0
  85. package/server.json +111 -0
package/CLAUDE.md ADDED
@@ -0,0 +1,343 @@
1
+ # Developer Protocol
2
+
3
+ **Server:** wsdot-mcp-server
4
+ **Version:** 0.1.1
5
+ **Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core) `^0.9.7`
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
+ ## Core Rules
15
+
16
+ - **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.
17
+ - **Use `ctx.log`** for request-scoped logging. No `console` calls.
18
+ - **Use `ctx.state`** for tenant-scoped storage. Never access persistence directly.
19
+ - **Check `ctx.elicit` / `ctx.sample`** for presence before calling.
20
+ - **Secrets in env vars only** — never hardcoded.
21
+
22
+ ---
23
+
24
+ ## Patterns
25
+
26
+ ### Tool
27
+
28
+ ```ts
29
+ import { tool, z } from '@cyanheads/mcp-ts-core';
30
+ import { getTrafficApiService } from '@/services/traffic/traffic-service.js';
31
+
32
+ export const getMountainPasses = tool('wsdot_get_mountain_passes', {
33
+ description: 'Returns current road conditions for all Washington State mountain passes.',
34
+ annotations: { readOnlyHint: true },
35
+ input: z.object({}),
36
+ output: z.object({
37
+ passes: z.array(z.object({
38
+ passName: z.string().optional().describe('Name of the mountain pass.'),
39
+ roadCondition: z.string().optional().describe('Current road condition.'),
40
+ })).describe('Current conditions for all WA mountain passes.'),
41
+ }),
42
+
43
+ async handler(input, ctx) {
44
+ const svc = getTrafficApiService();
45
+ const passes = await svc.getMountainPassConditions();
46
+ ctx.log.info('Mountain passes fetched', { count: passes.length });
47
+ return { passes };
48
+ },
49
+
50
+ // format() populates content[] — the markdown twin of structuredContent.
51
+ // Different clients read different surfaces (Claude Code → structuredContent,
52
+ // Claude Desktop → content[]); both must carry the same data.
53
+ // Enforced at lint time: every field in `output` must appear in the rendered text.
54
+ format: (result) => [{
55
+ type: 'text',
56
+ text: result.passes.map(p => `**${p.passName}**: ${p.roadCondition}`).join('\n'),
57
+ }],
58
+ });
59
+ ```
60
+
61
+ ### Server config
62
+
63
+ ```ts
64
+ // src/config/server-config.ts — lazy-parsed, separate from framework config
65
+ import { z } from '@cyanheads/mcp-ts-core';
66
+ import { parseEnvConfig } from '@cyanheads/mcp-ts-core/config';
67
+
68
+ const ServerConfigSchema = z.object({
69
+ accessCode: z.string().describe('WSDOT Traveler API access code.'),
70
+ });
71
+
72
+ let _config: z.infer<typeof ServerConfigSchema> | undefined;
73
+ export function getServerConfig() {
74
+ _config ??= parseEnvConfig(ServerConfigSchema, {
75
+ accessCode: 'WSDOT_ACCESS_CODE',
76
+ });
77
+ return _config;
78
+ }
79
+ ```
80
+
81
+ `parseEnvConfig` maps Zod schema paths → env var names so errors name the variable (`WSDOT_ACCESS_CODE`) not the path (`accessCode`). Throws `ConfigurationError`, which the framework prints as a clean startup banner.
82
+
83
+ ---
84
+
85
+ ## Context
86
+
87
+ Handlers receive a unified `ctx` object. Key properties:
88
+
89
+ | Property | Description |
90
+ |:---------|:------------|
91
+ | `ctx.log` | Request-scoped logger — `.debug()`, `.info()`, `.notice()`, `.warning()`, `.error()`. Auto-correlates requestId, traceId, tenantId. |
92
+ | `ctx.state` | Tenant-scoped KV — `.get(key)`, `.set(key, value, { ttl? })`, `.delete(key)`, `.list(prefix, { cursor, limit })`. Accepts any serializable value. |
93
+ | `ctx.elicit` | Ask user for structured input. **Check for presence first:** `if (ctx.elicit) { ... }` |
94
+ | `ctx.sample` | Request LLM completion from the client. **Check for presence first:** `if (ctx.sample) { ... }` |
95
+ | `ctx.signal` | `AbortSignal` for cancellation. |
96
+ | `ctx.progress` | Task progress (present when `task: true`) — `.setTotal(n)`, `.increment()`, `.update(message)`. |
97
+ | `ctx.requestId` | Unique request ID. |
98
+ | `ctx.tenantId` | Tenant ID from JWT or `'default'` for stdio. |
99
+
100
+ ---
101
+
102
+ ## Errors
103
+
104
+ Handlers throw — the framework catches, classifies, and formats.
105
+
106
+ **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.
107
+
108
+ ```ts
109
+ errors: [
110
+ { reason: 'no_match', code: JsonRpcErrorCode.NotFound,
111
+ when: 'No item matched the query',
112
+ recovery: 'Broaden the query or check the spelling and try again.' },
113
+ ],
114
+ async handler(input, ctx) {
115
+ const item = await db.find(input.id);
116
+ if (!item) throw ctx.fail('no_match', `No item ${input.id}`);
117
+ return item;
118
+ }
119
+ ```
120
+
121
+ **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.
122
+
123
+ **Fallback (no contract entry fits):** throw via factories or plain `Error`.
124
+
125
+ ```ts
126
+ // Error factories — explicit code
127
+ import { notFound, serviceUnavailable } from '@cyanheads/mcp-ts-core/errors';
128
+ throw notFound('Item not found', { itemId });
129
+ throw serviceUnavailable('API unavailable', { url }, { cause: err });
130
+
131
+ // Plain Error — framework auto-classifies from message patterns
132
+ throw new Error('Item not found'); // → NotFound
133
+ throw new Error('Invalid query format'); // → ValidationError
134
+
135
+ // McpError — when no factory exists for the code
136
+ import { McpError, JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
137
+ throw new McpError(JsonRpcErrorCode.DatabaseError, 'Connection failed', { pool: 'primary' });
138
+ ```
139
+
140
+ See framework CLAUDE.md and the `api-errors` skill for the full auto-classification table, all available factories, and the contract reference.
141
+
142
+ ---
143
+
144
+ ## Structure
145
+
146
+ ```text
147
+ src/
148
+ index.ts # createApp() entry point — 12 tools, 2 services
149
+ config/
150
+ server-config.ts # WSDOT_ACCESS_CODE env var (Zod schema)
151
+ services/
152
+ traffic/
153
+ traffic-service.ts # WSDOT Traffic API — mountain passes, alerts, travel times, toll rates, border waits, cameras
154
+ types.ts # Traffic domain types
155
+ ferry/
156
+ ferry-service.ts # WSF Ferry API — terminals, routes, schedule, vessel locations, space, alerts
157
+ types.ts # Ferry domain types
158
+ mcp-server/
159
+ tools/definitions/
160
+ get-mountain-passes.tool.ts # wsdot_get_mountain_passes
161
+ search-alerts.tool.ts # wsdot_search_alerts
162
+ get-travel-times.tool.ts # wsdot_get_travel_times
163
+ get-toll-rates.tool.ts # wsdot_get_toll_rates
164
+ get-border-waits.tool.ts # wsdot_get_border_waits
165
+ search-cameras.tool.ts # wsdot_search_cameras
166
+ get-ferry-terminals.tool.ts # wsdot_get_ferry_terminals
167
+ get-ferry-routes.tool.ts # wsdot_get_ferry_routes
168
+ get-ferry-schedule.tool.ts # wsdot_get_ferry_schedule
169
+ get-vessel-locations.tool.ts # wsdot_get_vessel_locations
170
+ get-terminal-space.tool.ts # wsdot_get_terminal_space
171
+ get-ferry-alerts.tool.ts # wsdot_get_ferry_alerts
172
+ ```
173
+
174
+ ---
175
+
176
+ ## Naming
177
+
178
+ | What | Convention | Example |
179
+ |:-----|:-----------|:--------|
180
+ | Files | kebab-case with suffix | `search-docs.tool.ts` |
181
+ | Tool/resource/prompt names | snake_case | `search_docs` |
182
+ | Directories | kebab-case | `src/services/doc-search/` |
183
+ | Descriptions | Single string or template literal, no `+` concatenation | `'Search items by query and filter.'` |
184
+
185
+ ---
186
+
187
+ ## Skills
188
+
189
+ 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.
190
+
191
+ **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.
192
+
193
+ Available skills:
194
+
195
+ | Skill | Purpose |
196
+ |:------|:--------|
197
+ | `setup` | Post-init project orientation |
198
+ | `design-mcp-server` | Design tool surface, resources, and services for a new server |
199
+ | `add-tool` | Scaffold a new tool definition |
200
+ | `add-app-tool` | Scaffold an MCP App tool + paired UI resource |
201
+ | `add-resource` | Scaffold a new resource definition |
202
+ | `add-prompt` | Scaffold a new prompt definition |
203
+ | `add-service` | Scaffold a new service integration |
204
+ | `add-test` | Scaffold test file for a tool, resource, or service |
205
+ | `field-test` | Exercise tools/resources/prompts with real inputs, verify behavior, report issues |
206
+ | `security-pass` | Audit server for MCP-flavored security gaps: output injection, scope blast radius, input sinks, tenant isolation |
207
+ | `devcheck` | Lint, format, typecheck, audit |
208
+ | `polish-docs-meta` | Finalize docs, README, metadata, and agent protocol for shipping |
209
+ | `maintenance` | Investigate changelogs, adopt upstream changes, sync skills to agent dirs |
210
+ | `report-issue-framework` | File a bug or feature request against `@cyanheads/mcp-ts-core` via `gh` CLI |
211
+ | `report-issue-local` | File a bug or feature request against this server's own repo via `gh` CLI |
212
+ | `api-auth` | Auth modes, scopes, JWT/OAuth |
213
+ | `api-canvas` | DataCanvas: register tabular data, run SQL, export, plus the `spillover()` helper for big result sets — Tier 3 opt-in |
214
+ | `api-config` | AppConfig, parseConfig, env vars |
215
+ | `api-context` | Context interface, logger, state, progress |
216
+ | `api-errors` | McpError, JsonRpcErrorCode, error patterns |
217
+ | `api-services` | LLM, Speech, Graph services |
218
+ | `api-testing` | createMockContext, test patterns |
219
+ | `api-utils` | Formatting, parsing, security, pagination, scheduling, telemetry helpers |
220
+ | `api-telemetry` | OTel catalog: spans, metrics, completion logs, env config, cardinality rules |
221
+ | `api-workers` | Cloudflare Workers runtime |
222
+
223
+ When you complete a skill's checklist, check the boxes and add a completion timestamp at the end (e.g., `Completed: 2026-03-11`).
224
+
225
+ ---
226
+
227
+ ## Commands
228
+
229
+ **Runtime:** Scripts use `tsx` — both `npm run <cmd>` and `bun run <cmd>` work. `bun` is slightly faster for script invocation but not required.
230
+
231
+ | Command | Purpose |
232
+ |:--------|:--------|
233
+ | `npm run build` | Compile TypeScript |
234
+ | `npm run rebuild` | Clean + build |
235
+ | `npm run clean` | Remove build artifacts |
236
+ | `npm run devcheck` | Lint + format + typecheck + security + changelog sync |
237
+ | `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. |
238
+ | `npm run tree` | Generate directory structure doc |
239
+ | `npm run format` | Auto-fix formatting |
240
+ | `npm test` | Run tests |
241
+ | `npm run start:stdio` | Production mode (stdio) |
242
+ | `npm run start:http` | Production mode (HTTP) |
243
+ | `npm run changelog:build` | Regenerate `CHANGELOG.md` from `changelog/*.md` |
244
+ | `npm run changelog:check` | Verify `CHANGELOG.md` is in sync (used by devcheck) |
245
+ | `npm run bundle` | Build and pack as `.mcpb` for one-click Claude Desktop install |
246
+
247
+ ---
248
+
249
+ ## Bundling
250
+
251
+ `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.
252
+
253
+ **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.
254
+
255
+ **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.
256
+
257
+ | Client | Mechanism |
258
+ |:-------|:----------|
259
+ | 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. |
260
+ | Cursor | Official `https://cursor.com/en/install-mcp` endpoint with base64 JSON config. |
261
+ | 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. |
262
+ | Claude Code / Codex | CLI only (`claude mcp add` / `codex mcp add`); no URL scheme. |
263
+
264
+ ```markdown
265
+ [![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)
266
+ [![Install in Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en/install-mcp?name=<PACKAGE_NAME>&config=<BASE64_CONFIG>)
267
+ [![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>)
268
+ ```
269
+
270
+ 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.
271
+
272
+ Generate the encoded configs (replace `<PACKAGE_NAME>` and add env vars for any required API keys):
273
+
274
+ ```bash
275
+ # Cursor: base64-encoded JSON. Split command/args, add env when keys are needed.
276
+ echo -n '{"command":"npx","args":["-y","<PACKAGE_NAME>"],"env":{"API_KEY":"your-api-key"}}' | base64
277
+ # Without env (no required keys):
278
+ echo -n '{"command":"npx","args":["-y","<PACKAGE_NAME>"]}' | base64
279
+
280
+ # VS Code: URL-encoded JSON. Same shape plus a `name` field.
281
+ node -p 'encodeURIComponent(JSON.stringify({name:"<SHORT_NAME>",command:"npx",args:["-y","<PACKAGE_NAME>"],env:{API_KEY:"your-api-key"}}))'
282
+ # Without env:
283
+ node -p 'encodeURIComponent(JSON.stringify({name:"<SHORT_NAME>",command:"npx",args:["-y","<PACKAGE_NAME>"]}))'
284
+ ```
285
+
286
+ 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`.
287
+
288
+ 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.
289
+
290
+ ---
291
+
292
+ ## Changelog
293
+
294
+ 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.
295
+
296
+ Each per-version file opens with YAML frontmatter:
297
+
298
+ ```markdown
299
+ ---
300
+ summary: "One-line headline, ≤350 chars" # required — powers the rollup index
301
+ breaking: false # optional — true flags breaking changes
302
+ security: false # optional — true flags security fixes
303
+ ---
304
+
305
+ # 0.1.0 — YYYY-MM-DD
306
+ ...
307
+ ```
308
+
309
+ `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`.
310
+
311
+ **Section order** (Keep a Changelog): Added, Changed, Deprecated, Removed, Fixed, Security. Include only sections with entries — don't ship empty headers.
312
+
313
+ **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.
314
+
315
+ ---
316
+
317
+ ## Imports
318
+
319
+ ```ts
320
+ // Framework — z is re-exported, no separate zod import needed
321
+ import { tool, z } from '@cyanheads/mcp-ts-core';
322
+ import { McpError, JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
323
+
324
+ // Server's own code — via path alias
325
+ import { getMyService } from '@/services/my-domain/my-service.js';
326
+ ```
327
+
328
+ ---
329
+
330
+ ## Checklist
331
+
332
+ - [ ] 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()`)
333
+ - [ ] 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`.
334
+ - [ ] JSDoc `@fileoverview` + `@module` on every file
335
+ - [ ] `ctx.log` for logging, `ctx.state` for storage
336
+ - [ ] Handlers throw on failure — error factories or plain `Error`, no try/catch
337
+ - [ ] `format()` renders all data the LLM needs — different clients forward different surfaces (Claude Code → `structuredContent`, Claude Desktop → `content[]`); both must carry the same data
338
+ - [ ] If wrapping external API: raw/domain/output schemas reviewed against real upstream sparsity/nullability before finalizing required vs optional fields
339
+ - [ ] If wrapping external API: normalization and `format()` preserve uncertainty; do not fabricate facts from missing upstream data
340
+ - [ ] If wrapping external API: tests include at least one sparse payload case with omitted upstream fields
341
+ - [ ] Registered in `createApp()` arrays (directly or via barrel exports)
342
+ - [ ] Tests use `createMockContext()` from `@cyanheads/mcp-ts-core/testing`
343
+ - [ ] `npm run devcheck` passes
package/Dockerfile ADDED
@@ -0,0 +1,99 @@
1
+ # ==============================================================================
2
+ # Build Stage
3
+ #
4
+ # This stage installs all dependencies (including dev), builds the TypeScript
5
+ # source code into JavaScript, and prepares the production assets.
6
+ # ==============================================================================
7
+ FROM oven/bun:1.3 AS build
8
+
9
+ WORKDIR /usr/src/app
10
+
11
+ # Copy dependency manifests for optimized layer caching
12
+ COPY package.json bun.lock ./
13
+
14
+ # Install all dependencies (including dev dependencies for building)
15
+ RUN bun install --frozen-lockfile
16
+
17
+ # Copy the rest of the source code
18
+ COPY . .
19
+
20
+ # Build the application
21
+ RUN bun run build
22
+
23
+
24
+ # ==============================================================================
25
+ # Production Stage
26
+ #
27
+ # This stage creates a minimal, optimized, and secure image for running the
28
+ # application. It uses a slim base image and only includes production
29
+ # dependencies and build artifacts.
30
+ # ==============================================================================
31
+ FROM oven/bun:1.3-slim AS production
32
+
33
+ WORKDIR /usr/src/app
34
+
35
+ # Set the environment to production for performance and to ensure only
36
+ # production dependencies are installed.
37
+ ENV NODE_ENV=production
38
+
39
+ # OCI image metadata (https://github.com/opencontainers/image-spec/blob/main/annotations.md)
40
+ LABEL org.opencontainers.image.title="wsdot-mcp-server"
41
+ LABEL org.opencontainers.image.description="Query WA highway conditions, ferry schedules, vessel locations, toll rates, border waits, and alerts via MCP."
42
+ LABEL org.opencontainers.image.source="https://github.com/cyanheads/wsdot-mcp-server"
43
+ LABEL org.opencontainers.image.licenses="Apache-2.0"
44
+
45
+ # Copy dependency manifests
46
+ COPY package.json bun.lock ./
47
+
48
+ # Install only production dependencies, ignoring any lifecycle scripts (like 'prepare')
49
+ # that are not needed in the final production image.
50
+ RUN bun install --production --frozen-lockfile --ignore-scripts
51
+
52
+ # Conditionally install OpenTelemetry optional peer dependencies (Tier 3).
53
+ # These are not bundled by default to keep the base image lean. Enable at build time
54
+ # with: docker build --build-arg OTEL_ENABLED=true
55
+ ARG OTEL_ENABLED=true
56
+ RUN if [ "$OTEL_ENABLED" = "true" ]; then \
57
+ bun add @hono/otel \
58
+ @opentelemetry/instrumentation-http \
59
+ @opentelemetry/exporter-metrics-otlp-http \
60
+ @opentelemetry/exporter-trace-otlp-http \
61
+ @opentelemetry/instrumentation-pino \
62
+ @opentelemetry/resources \
63
+ @opentelemetry/sdk-metrics \
64
+ @opentelemetry/sdk-node \
65
+ @opentelemetry/sdk-trace-node \
66
+ @opentelemetry/semantic-conventions; \
67
+ fi
68
+
69
+ # Copy the compiled application code from the build stage
70
+ COPY --from=build /usr/src/app/dist ./dist
71
+
72
+ # The 'oven/bun' image already provides a non-root user named 'bun'.
73
+ # We will use this existing user for enhanced security.
74
+
75
+ # Create and set permissions for the log directory, assigning ownership to the 'bun' user.
76
+ RUN mkdir -p /var/log/wsdot-mcp-server && chown -R bun:bun /var/log/wsdot-mcp-server
77
+
78
+ # Switch to the non-root user
79
+ USER bun
80
+
81
+ # Define an argument for the port, allowing it to be overridden at build time.
82
+ # The `PORT` variable is often injected by cloud environments at runtime.
83
+ ARG PORT
84
+
85
+ # Set runtime environment variables
86
+ # Note: PORT is an automatic variable in many cloud environments (e.g., Cloud Run)
87
+ ENV MCP_HTTP_PORT=${PORT:-3010}
88
+ ENV MCP_HTTP_HOST="0.0.0.0"
89
+ ENV MCP_TRANSPORT_TYPE="http"
90
+ ENV MCP_SESSION_MODE="stateless"
91
+ ENV MCP_LOG_LEVEL="info"
92
+ ENV LOGS_DIR="/var/log/wsdot-mcp-server"
93
+ ENV MCP_FORCE_CONSOLE_LOGGING="true"
94
+
95
+ # Expose the port the server listens on
96
+ EXPOSE ${MCP_HTTP_PORT}
97
+
98
+ # The command to start the server
99
+ CMD ["bun", "run", "dist/index.js"]
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025 Casey Hand @cyanheads
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.