@cyanheads/finnhub-mcp-server 0.1.1 → 0.1.3

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 CHANGED
@@ -1,10 +1,10 @@
1
1
  # Developer Protocol
2
2
 
3
3
  **Server:** finnhub-mcp-server
4
- **Version:** 0.1.1
5
- **Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core) `^0.10.6`
4
+ **Version:** 0.1.3
5
+ **Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core) `^0.12.3`
6
6
  **Engines:** Bun ≥1.3.0, Node ≥24.0.0
7
- **MCP SDK:** `@modelcontextprotocol/sdk` ^1.29.0
7
+ **MCP SDK:** `@modelcontextprotocol/server` 2.0.0
8
8
  **Zod:** ^4.4.3
9
9
 
10
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.
@@ -16,7 +16,7 @@
16
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
17
  - **Use `ctx.log`** for request-scoped logging. No `console` calls.
18
18
  - **Use `ctx.state`** for tenant-scoped storage. Never access persistence directly.
19
- - **Check `ctx.elicit`** for presence before calling.
19
+ - **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.
20
20
  - **Secrets in env vars only** — never hardcoded.
21
21
  - **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.
22
22
 
@@ -72,7 +72,7 @@ export const itemData = resource('inventory://{itemId}', {
72
72
  params: z.object({ itemId: z.string().describe('Item identifier') }),
73
73
  auth: ['inventory:read'],
74
74
  async handler(params, ctx) {
75
- const item = await ctx.state.get(`item:${params.itemId}`);
75
+ const item = await ctx.state.get(`item/${params.itemId}`);
76
76
  if (!item) throw notFound(`Item ${params.itemId} not found`, { itemId: params.itemId });
77
77
  return item;
78
78
  },
@@ -149,13 +149,15 @@ Handlers receive a unified `ctx` object. Key properties:
149
149
 
150
150
  | Property | Description |
151
151
  |:---------|:------------|
152
- | `ctx.log` | Request-scoped logger — `.debug()`, `.info()`, `.notice()`, `.warning()`, `.error()`. Auto-correlates requestId, traceId, tenantId. |
153
- | `ctx.state` | Tenant-scoped KV — `.get(key)`, `.set(key, value, { ttl? })`, `.delete(key)`, `.list(prefix, { cursor, limit })`. Accepts any serializable value. |
154
- | `ctx.elicit` | Ask user for structured input — form call `(message, schema)` or `.url(message, url)` for an external link. **Check for presence first:** `if (ctx.elicit) { ... }` |
152
+ | `ctx.log` | Request-scoped logger — `.debug()`, `.info()`, `.notice()`, `.warning()`, `.error()`. Auto-correlates requestId, traceId, tenantId. Dual-sink: Pino **and** `notifications/message` to the client, so treat it as client-visible. |
153
+ | `ctx.state` | Tenant-scoped KV — `.get(key)`, `.set(key, value, { ttl? })`, `.delete(key)`, `.getMany(keys)`, `.list(prefix, { cursor, limit })`. Accepts any serializable value. |
154
+ | `ctx.requestInput` | Suspend and ask the caller for more input — `return ctx.requestInput({ inputRequests: { key: inputRequired.elicit({ message, requestedSchema }) } })`. Never returns; the handler is re-entered with the answers. Always present. |
155
+ | `ctx.inputs` | Reader over a retried request's responses — `.accepted(key, schema)`, `.view(key)`, `.state()`, `.dropped`. Empty on the first round. |
156
+ | `ctx.enrich` | Success-path agent context (empty-result notices, query echo, pagination totals) — `ctx.enrich(...)` or `.notice()` / `.total()` / `.echo()` / `.truncated()`. Reaches `structuredContent` and `content[]`; lands only when the definition declares an `enrichment` block (no-op otherwise). |
157
+ | `ctx.content` | Non-text content blocks — `.image(data, mimeType)`, `.audio(data, mimeType)`, or `ctx.content(block)` for a raw block. Prepended to `content[]` after `format()`; never enters `structuredContent`. |
155
158
  | `ctx.signal` | `AbortSignal` for cancellation. |
156
- | `ctx.progress` | Task progress (present when `task: true`) — `.setTotal(n)`, `.increment()`, `.update(message)`. |
157
159
  | `ctx.requestId` | Unique request ID. |
158
- | `ctx.tenantId` | Tenant ID from JWT or `'default'` for stdio. |
160
+ | `ctx.tenantId` | Tenant ID from JWT; `'default'` for stdio or HTTP with auth off. |
159
161
 
160
162
  ---
161
163
 
@@ -163,7 +165,7 @@ Handlers receive a unified `ctx` object. Key properties:
163
165
 
164
166
  Handlers throw — the framework catches, classifies, and formats.
165
167
 
166
- **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.
168
+ **Recommended: typed error contract.** Declare `errors: [{ reason, code, when, recovery, retryable? }]` on `tool()` / `resource()` to receive `ctx.fail(reason, …)` typed against the reason union. TypeScript catches typos at compile time, `data.reason` is auto-populated for observability, linter enforces conformance against the handler body. `recovery` is required (≥ 5 words, lint-validated) — the single source of truth for the agent's next move. Pass `ctx.recoveryFor('reason')` as the throw's data to put it on the wire (`data.recovery.hint`, mirrored into `content[]` text); override with an explicit `{ recovery: { hint: '...' } }` when dynamic runtime context matters. Baseline codes (`InternalError`, `ServiceUnavailable`, `Timeout`, `ValidationError`, `SerializationError`) bubble freely and don't need declaring.
167
169
 
168
170
  ```ts
169
171
  import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
@@ -175,7 +177,7 @@ errors: [
175
177
  ],
176
178
  async handler(input, ctx) {
177
179
  const item = await db.find(input.id);
178
- if (!item) throw ctx.fail('no_match', `No item ${input.id}`);
180
+ if (!item) throw ctx.fail('no_match', `No item ${input.id}`, ctx.recoveryFor('no_match'));
179
181
  return item;
180
182
  }
181
183
  ```
@@ -238,7 +240,7 @@ src/
238
240
 
239
241
  ## Skills
240
242
 
241
- 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.
243
+ 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.
242
244
 
243
245
  **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.
244
246
 
@@ -258,7 +260,6 @@ Available skills:
258
260
  | `tool-defs-analysis` | Read-only audit of MCP definition language across the surface — voice, leaks, defaults, recovery hints, output descriptions |
259
261
  | `security-pass` | Audit server for MCP-flavored security gaps: output injection, scope blast radius, input sinks, tenant isolation |
260
262
  | `code-simplifier` | Post-session cleanup against `git diff` — modernize syntax, consolidate duplication, align with the codebase |
261
- | `devcheck` | Lint, format, typecheck, audit |
262
263
  | `polish-docs-meta` | Finalize docs, README, metadata, and agent protocol for shipping |
263
264
  | `git-wrapup` | Land working-tree changes as a versioned commit + annotated tag — version bump, changelog, verify, tag. Local only. |
264
265
  | `release-and-publish` | Push + npm + MCP Registry + GH Release + Docker. Picks up from `git-wrapup` |
@@ -269,14 +270,16 @@ Available skills:
269
270
  | `api-auth` | Auth modes, scopes, JWT/OAuth |
270
271
  | `api-canvas` | DataCanvas: register tabular data, run SQL, export, plus the `spillover()` helper for big result sets — Tier 3 opt-in |
271
272
  | `api-config` | AppConfig, parseConfig, env vars |
272
- | `api-context` | Context interface, logger, state, progress |
273
+ | `api-context` | Context interface, RequestContext, logger, state, multi-round-trip input |
273
274
  | `api-errors` | McpError, JsonRpcErrorCode, error patterns |
274
275
  | `api-linter` | Definition linter rule catalog — invoked by `bun run lint:mcp` and `devcheck` |
276
+ | `api-mirror` | MirrorService: persistent self-refreshing local mirror (embedded SQLite + FTS5) of a bulk upstream dataset — Tier 3 opt-in |
275
277
  | `api-services` | LLM, Speech, Graph services |
276
278
  | `api-testing` | createMockContext, test patterns |
277
279
  | `api-utils` | Formatting, parsing, security, pagination, scheduling, telemetry helpers |
278
280
  | `api-telemetry` | OTel catalog: spans, metrics, completion logs, env config, cardinality rules |
279
281
  | `api-workers` | Cloudflare Workers runtime |
282
+ | `techniques` | Catalog of response/data-shaping techniques — overflow handling, payload shaping, retrieval patterns |
280
283
 
281
284
  **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.
282
285
 
@@ -290,26 +293,29 @@ When you complete a skill's checklist, check the boxes and add a completion time
290
293
 
291
294
  | Command | Purpose |
292
295
  |:--------|:--------|
293
- | `npm run build` | Compile TypeScript |
294
- | `npm run rebuild` | Clean + build |
295
- | `npm run clean` | Remove build artifacts |
296
- | `npm run devcheck` | Lint + format + typecheck + security + changelog sync |
296
+ | `bun run build` | Compile TypeScript |
297
+ | `bun run rebuild` | Clean + build |
298
+ | `bun run clean` | Remove build artifacts |
299
+ | `bun run devcheck` | Lint + format + typecheck + security + changelog sync |
300
+ | `bun run lint:mcp` | Run the MCP definition linter standalone (rule catalog: `api-linter` skill) |
301
+ | `bun run lint:packaging` | Packaging surface checks — `server.json`/`manifest.json` env-var parity (run by devcheck) |
302
+ | `bun run list-skills` | Print the skill registry |
297
303
  | `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. |
298
- | `npm run tree` | Generate directory structure doc |
299
- | `npm run format` | Auto-fix formatting (safe fixes only) |
300
- | `npm run format:unsafe` | Also apply Biome's unsafe autofixes — review the diff; they can change behavior |
301
- | `npm test` | Run tests |
302
- | `npm run start:stdio` | Production mode (stdio) |
303
- | `npm run start:http` | Production mode (HTTP) |
304
- | `npm run changelog:build` | Regenerate `CHANGELOG.md` from `changelog/*.md` |
305
- | `npm run changelog:check` | Verify `CHANGELOG.md` is in sync (used by devcheck) |
306
- | `npm run bundle` | Build, pack, and clean a `.mcpb` for one-click Claude Desktop install |
304
+ | `bun run tree` | Generate directory structure doc |
305
+ | `bun run format` | Auto-fix formatting (safe fixes only) |
306
+ | `bun run format:unsafe` | Also apply Biome's unsafe autofixes — review the diff; they can change behavior |
307
+ | `bun run test` | Run tests (Vitest — use `bun run test`, not `bun test`) |
308
+ | `bun run start:stdio` | Production mode (stdio) |
309
+ | `bun run start:http` | Production mode (HTTP) |
310
+ | `bun run changelog:build` | Regenerate `CHANGELOG.md` from `changelog/*.md` |
311
+ | `bun run changelog:check` | Verify `CHANGELOG.md` is in sync (used by devcheck) |
312
+ | `bun run bundle` | Build, pack, and clean a `.mcpb` for one-click Claude Desktop install |
307
313
 
308
314
  ---
309
315
 
310
316
  ## Bundling
311
317
 
312
- `npm run bundle` produces a `.mcpb` extension bundle for one-click install in Claude Desktop. The pack step is followed by `scripts/clean-mcpb.ts`, which prunes dev dependencies (`mcpb clean`) and strips dependency-shipped agent docs (`node_modules/**` `skills/`, `.claude/`, `.agents/`, `SKILL.md`) that root-anchored `.mcpbignore` patterns cannot reach. MCPB is stdio-only — HTTP and Cloudflare Workers deployments are unaffected. Consumers who don't need it can delete `manifest.json` and `.mcpbignore`; `lint:packaging` skips cleanly.
318
+ `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.
313
319
 
314
320
  **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.
315
321
 
@@ -327,14 +333,14 @@ Each per-version file opens with YAML frontmatter:
327
333
  ---
328
334
  summary: "One-line headline, ≤350 chars" # required — powers the rollup index
329
335
  breaking: false # optional — true flags breaking changes
330
- security: false # optional — true flags security fixes
336
+ security: false # optional — true ONLY for a source-code security fix, never a dependency CVE bump
331
337
  ---
332
338
 
333
339
  # 0.1.0 — YYYY-MM-DD
334
340
  ...
335
341
  ```
336
342
 
337
- `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`.
343
+ `breaking: true` renders a `· ⚠️ Breaking` badge — use it when consumers must update code on upgrade (signature changes, removed APIs, config renames). `security: true` renders a `· 🛡️ Security` badge and pairs with a `## Security` body section — set it only for a security fix in this server's *own source code*, never for a routine dependency or transitive CVE bump (record those under `## Dependencies`). When both are set, badges render `· ⚠️ Breaking · 🛡️ Security`.
338
344
 
339
345
  `agent-notes` is an optional free-form field for maintenance agents processing the release downstream. Content here won't appear in the rendered CHANGELOG — it's consumed by agents running the `maintenance` skill. Use it for adoption instructions that don't fit the human-facing sections: new files to create, fields to populate, one-time migration steps. Omit entirely when there's nothing to say.
340
346
 
package/CLAUDE.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Developer Protocol
2
2
 
3
3
  **Server:** finnhub-mcp-server
4
- **Version:** 0.1.1
5
- **Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core) `^0.10.6`
4
+ **Version:** 0.1.3
5
+ **Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core) `^0.12.3`
6
6
  **Engines:** Bun ≥1.3.0, Node ≥24.0.0
7
- **MCP SDK:** `@modelcontextprotocol/sdk` ^1.29.0
7
+ **MCP SDK:** `@modelcontextprotocol/server` 2.0.0
8
8
  **Zod:** ^4.4.3
9
9
 
10
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.
@@ -16,7 +16,7 @@
16
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
17
  - **Use `ctx.log`** for request-scoped logging. No `console` calls.
18
18
  - **Use `ctx.state`** for tenant-scoped storage. Never access persistence directly.
19
- - **Check `ctx.elicit`** for presence before calling.
19
+ - **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.
20
20
  - **Secrets in env vars only** — never hardcoded.
21
21
  - **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.
22
22
 
@@ -72,7 +72,7 @@ export const itemData = resource('inventory://{itemId}', {
72
72
  params: z.object({ itemId: z.string().describe('Item identifier') }),
73
73
  auth: ['inventory:read'],
74
74
  async handler(params, ctx) {
75
- const item = await ctx.state.get(`item:${params.itemId}`);
75
+ const item = await ctx.state.get(`item/${params.itemId}`);
76
76
  if (!item) throw notFound(`Item ${params.itemId} not found`, { itemId: params.itemId });
77
77
  return item;
78
78
  },
@@ -149,13 +149,15 @@ Handlers receive a unified `ctx` object. Key properties:
149
149
 
150
150
  | Property | Description |
151
151
  |:---------|:------------|
152
- | `ctx.log` | Request-scoped logger — `.debug()`, `.info()`, `.notice()`, `.warning()`, `.error()`. Auto-correlates requestId, traceId, tenantId. |
153
- | `ctx.state` | Tenant-scoped KV — `.get(key)`, `.set(key, value, { ttl? })`, `.delete(key)`, `.list(prefix, { cursor, limit })`. Accepts any serializable value. |
154
- | `ctx.elicit` | Ask user for structured input — form call `(message, schema)` or `.url(message, url)` for an external link. **Check for presence first:** `if (ctx.elicit) { ... }` |
152
+ | `ctx.log` | Request-scoped logger — `.debug()`, `.info()`, `.notice()`, `.warning()`, `.error()`. Auto-correlates requestId, traceId, tenantId. Dual-sink: Pino **and** `notifications/message` to the client, so treat it as client-visible. |
153
+ | `ctx.state` | Tenant-scoped KV — `.get(key)`, `.set(key, value, { ttl? })`, `.delete(key)`, `.getMany(keys)`, `.list(prefix, { cursor, limit })`. Accepts any serializable value. |
154
+ | `ctx.requestInput` | Suspend and ask the caller for more input — `return ctx.requestInput({ inputRequests: { key: inputRequired.elicit({ message, requestedSchema }) } })`. Never returns; the handler is re-entered with the answers. Always present. |
155
+ | `ctx.inputs` | Reader over a retried request's responses — `.accepted(key, schema)`, `.view(key)`, `.state()`, `.dropped`. Empty on the first round. |
156
+ | `ctx.enrich` | Success-path agent context (empty-result notices, query echo, pagination totals) — `ctx.enrich(...)` or `.notice()` / `.total()` / `.echo()` / `.truncated()`. Reaches `structuredContent` and `content[]`; lands only when the definition declares an `enrichment` block (no-op otherwise). |
157
+ | `ctx.content` | Non-text content blocks — `.image(data, mimeType)`, `.audio(data, mimeType)`, or `ctx.content(block)` for a raw block. Prepended to `content[]` after `format()`; never enters `structuredContent`. |
155
158
  | `ctx.signal` | `AbortSignal` for cancellation. |
156
- | `ctx.progress` | Task progress (present when `task: true`) — `.setTotal(n)`, `.increment()`, `.update(message)`. |
157
159
  | `ctx.requestId` | Unique request ID. |
158
- | `ctx.tenantId` | Tenant ID from JWT or `'default'` for stdio. |
160
+ | `ctx.tenantId` | Tenant ID from JWT; `'default'` for stdio or HTTP with auth off. |
159
161
 
160
162
  ---
161
163
 
@@ -163,7 +165,7 @@ Handlers receive a unified `ctx` object. Key properties:
163
165
 
164
166
  Handlers throw — the framework catches, classifies, and formats.
165
167
 
166
- **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.
168
+ **Recommended: typed error contract.** Declare `errors: [{ reason, code, when, recovery, retryable? }]` on `tool()` / `resource()` to receive `ctx.fail(reason, …)` typed against the reason union. TypeScript catches typos at compile time, `data.reason` is auto-populated for observability, linter enforces conformance against the handler body. `recovery` is required (≥ 5 words, lint-validated) — the single source of truth for the agent's next move. Pass `ctx.recoveryFor('reason')` as the throw's data to put it on the wire (`data.recovery.hint`, mirrored into `content[]` text); override with an explicit `{ recovery: { hint: '...' } }` when dynamic runtime context matters. Baseline codes (`InternalError`, `ServiceUnavailable`, `Timeout`, `ValidationError`, `SerializationError`) bubble freely and don't need declaring.
167
169
 
168
170
  ```ts
169
171
  import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
@@ -175,7 +177,7 @@ errors: [
175
177
  ],
176
178
  async handler(input, ctx) {
177
179
  const item = await db.find(input.id);
178
- if (!item) throw ctx.fail('no_match', `No item ${input.id}`);
180
+ if (!item) throw ctx.fail('no_match', `No item ${input.id}`, ctx.recoveryFor('no_match'));
179
181
  return item;
180
182
  }
181
183
  ```
@@ -238,7 +240,7 @@ src/
238
240
 
239
241
  ## Skills
240
242
 
241
- 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.
243
+ 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.
242
244
 
243
245
  **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.
244
246
 
@@ -258,7 +260,6 @@ Available skills:
258
260
  | `tool-defs-analysis` | Read-only audit of MCP definition language across the surface — voice, leaks, defaults, recovery hints, output descriptions |
259
261
  | `security-pass` | Audit server for MCP-flavored security gaps: output injection, scope blast radius, input sinks, tenant isolation |
260
262
  | `code-simplifier` | Post-session cleanup against `git diff` — modernize syntax, consolidate duplication, align with the codebase |
261
- | `devcheck` | Lint, format, typecheck, audit |
262
263
  | `polish-docs-meta` | Finalize docs, README, metadata, and agent protocol for shipping |
263
264
  | `git-wrapup` | Land working-tree changes as a versioned commit + annotated tag — version bump, changelog, verify, tag. Local only. |
264
265
  | `release-and-publish` | Push + npm + MCP Registry + GH Release + Docker. Picks up from `git-wrapup` |
@@ -269,14 +270,16 @@ Available skills:
269
270
  | `api-auth` | Auth modes, scopes, JWT/OAuth |
270
271
  | `api-canvas` | DataCanvas: register tabular data, run SQL, export, plus the `spillover()` helper for big result sets — Tier 3 opt-in |
271
272
  | `api-config` | AppConfig, parseConfig, env vars |
272
- | `api-context` | Context interface, logger, state, progress |
273
+ | `api-context` | Context interface, RequestContext, logger, state, multi-round-trip input |
273
274
  | `api-errors` | McpError, JsonRpcErrorCode, error patterns |
274
275
  | `api-linter` | Definition linter rule catalog — invoked by `bun run lint:mcp` and `devcheck` |
276
+ | `api-mirror` | MirrorService: persistent self-refreshing local mirror (embedded SQLite + FTS5) of a bulk upstream dataset — Tier 3 opt-in |
275
277
  | `api-services` | LLM, Speech, Graph services |
276
278
  | `api-testing` | createMockContext, test patterns |
277
279
  | `api-utils` | Formatting, parsing, security, pagination, scheduling, telemetry helpers |
278
280
  | `api-telemetry` | OTel catalog: spans, metrics, completion logs, env config, cardinality rules |
279
281
  | `api-workers` | Cloudflare Workers runtime |
282
+ | `techniques` | Catalog of response/data-shaping techniques — overflow handling, payload shaping, retrieval patterns |
280
283
 
281
284
  **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.
282
285
 
@@ -290,26 +293,29 @@ When you complete a skill's checklist, check the boxes and add a completion time
290
293
 
291
294
  | Command | Purpose |
292
295
  |:--------|:--------|
293
- | `npm run build` | Compile TypeScript |
294
- | `npm run rebuild` | Clean + build |
295
- | `npm run clean` | Remove build artifacts |
296
- | `npm run devcheck` | Lint + format + typecheck + security + changelog sync |
296
+ | `bun run build` | Compile TypeScript |
297
+ | `bun run rebuild` | Clean + build |
298
+ | `bun run clean` | Remove build artifacts |
299
+ | `bun run devcheck` | Lint + format + typecheck + security + changelog sync |
300
+ | `bun run lint:mcp` | Run the MCP definition linter standalone (rule catalog: `api-linter` skill) |
301
+ | `bun run lint:packaging` | Packaging surface checks — `server.json`/`manifest.json` env-var parity (run by devcheck) |
302
+ | `bun run list-skills` | Print the skill registry |
297
303
  | `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. |
298
- | `npm run tree` | Generate directory structure doc |
299
- | `npm run format` | Auto-fix formatting (safe fixes only) |
300
- | `npm run format:unsafe` | Also apply Biome's unsafe autofixes — review the diff; they can change behavior |
301
- | `npm test` | Run tests |
302
- | `npm run start:stdio` | Production mode (stdio) |
303
- | `npm run start:http` | Production mode (HTTP) |
304
- | `npm run changelog:build` | Regenerate `CHANGELOG.md` from `changelog/*.md` |
305
- | `npm run changelog:check` | Verify `CHANGELOG.md` is in sync (used by devcheck) |
306
- | `npm run bundle` | Build, pack, and clean a `.mcpb` for one-click Claude Desktop install |
304
+ | `bun run tree` | Generate directory structure doc |
305
+ | `bun run format` | Auto-fix formatting (safe fixes only) |
306
+ | `bun run format:unsafe` | Also apply Biome's unsafe autofixes — review the diff; they can change behavior |
307
+ | `bun run test` | Run tests (Vitest — use `bun run test`, not `bun test`) |
308
+ | `bun run start:stdio` | Production mode (stdio) |
309
+ | `bun run start:http` | Production mode (HTTP) |
310
+ | `bun run changelog:build` | Regenerate `CHANGELOG.md` from `changelog/*.md` |
311
+ | `bun run changelog:check` | Verify `CHANGELOG.md` is in sync (used by devcheck) |
312
+ | `bun run bundle` | Build, pack, and clean a `.mcpb` for one-click Claude Desktop install |
307
313
 
308
314
  ---
309
315
 
310
316
  ## Bundling
311
317
 
312
- `npm run bundle` produces a `.mcpb` extension bundle for one-click install in Claude Desktop. The pack step is followed by `scripts/clean-mcpb.ts`, which prunes dev dependencies (`mcpb clean`) and strips dependency-shipped agent docs (`node_modules/**` `skills/`, `.claude/`, `.agents/`, `SKILL.md`) that root-anchored `.mcpbignore` patterns cannot reach. MCPB is stdio-only — HTTP and Cloudflare Workers deployments are unaffected. Consumers who don't need it can delete `manifest.json` and `.mcpbignore`; `lint:packaging` skips cleanly.
318
+ `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.
313
319
 
314
320
  **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.
315
321
 
@@ -327,14 +333,14 @@ Each per-version file opens with YAML frontmatter:
327
333
  ---
328
334
  summary: "One-line headline, ≤350 chars" # required — powers the rollup index
329
335
  breaking: false # optional — true flags breaking changes
330
- security: false # optional — true flags security fixes
336
+ security: false # optional — true ONLY for a source-code security fix, never a dependency CVE bump
331
337
  ---
332
338
 
333
339
  # 0.1.0 — YYYY-MM-DD
334
340
  ...
335
341
  ```
336
342
 
337
- `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`.
343
+ `breaking: true` renders a `· ⚠️ Breaking` badge — use it when consumers must update code on upgrade (signature changes, removed APIs, config renames). `security: true` renders a `· 🛡️ Security` badge and pairs with a `## Security` body section — set it only for a security fix in this server's *own source code*, never for a routine dependency or transitive CVE bump (record those under `## Dependencies`). When both are set, badges render `· ⚠️ Breaking · 🛡️ Security`.
338
344
 
339
345
  `agent-notes` is an optional free-form field for maintenance agents processing the release downstream. Content here won't appear in the rendered CHANGELOG — it's consumed by agents running the `maintenance` skill. Use it for adoption instructions that don't fit the human-facing sections: new files to create, fields to populate, one-time migration steps. Omit entirely when there's nothing to say.
340
346
 
package/Dockerfile CHANGED
@@ -3,16 +3,24 @@
3
3
  #
4
4
  # This stage installs all dependencies (including dev), builds the TypeScript
5
5
  # source code into JavaScript, and prepares the production assets.
6
+ #
7
+ # --platform=$BUILDPLATFORM runs the build natively on the host arch: the output
8
+ # is platform-independent JS (only dist/ copies forward), so a multi-arch
9
+ # buildx push must not emulate this stage — Bun under QEMU aborts with
10
+ # JSC MemoryExhaustion.
6
11
  # ==============================================================================
7
- FROM oven/bun:1.3 AS build
12
+ FROM --platform=$BUILDPLATFORM oven/bun:1.4.0 AS build
8
13
 
9
14
  WORKDIR /usr/src/app
10
15
 
11
16
  # Copy dependency manifests for optimized layer caching
12
17
  COPY package.json bun.lock ./
13
18
 
14
- # Install all dependencies (including dev dependencies for building)
15
- RUN bun install --frozen-lockfile
19
+ # Install all dependencies (including dev dependencies for building).
20
+ # The BuildKit cache mount persists Bun's global package cache across builds.
21
+ # --ignore-scripts skips native postinstalls the tsc-only build never needs.
22
+ RUN --mount=type=cache,target=/root/.bun/install/cache \
23
+ bun install --frozen-lockfile --ignore-scripts
16
24
 
17
25
  # Copy the rest of the source code
18
26
  COPY . .
@@ -28,7 +36,7 @@ RUN bun run build
28
36
  # application. It uses a slim base image and only includes production
29
37
  # dependencies and build artifacts.
30
38
  # ==============================================================================
31
- FROM oven/bun:1.3-slim AS production
39
+ FROM oven/bun:1.4.0-slim AS production
32
40
 
33
41
  WORKDIR /usr/src/app
34
42
 
@@ -49,14 +57,21 @@ COPY package.json bun.lock ./
49
57
 
50
58
  # Install only production dependencies, ignoring any lifecycle scripts (like 'prepare')
51
59
  # that are not needed in the final production image.
52
- RUN bun install --production --frozen-lockfile --ignore-scripts
60
+ # `--omit=peer` drops the framework's optional peer tiers (test runner, service
61
+ # SDKs, parsers) that Bun would otherwise auto-install. Anything this server
62
+ # actually imports belongs in its own `dependencies`, so nothing needed at
63
+ # runtime is lost. The OTEL step below carries the same flag — without it, that
64
+ # install re-resolves the graph and pulls every optional peer back in.
65
+ RUN --mount=type=cache,target=/root/.bun/install/cache \
66
+ bun install --production --omit=peer --frozen-lockfile --ignore-scripts
53
67
 
54
68
  # Conditionally install OpenTelemetry optional peer dependencies (Tier 3).
55
69
  # These are not bundled by default to keep the base image lean. Enable at build time
56
70
  # with: docker build --build-arg OTEL_ENABLED=true
57
71
  ARG OTEL_ENABLED=true
58
- RUN if [ "$OTEL_ENABLED" = "true" ]; then \
59
- bun add @hono/otel \
72
+ RUN --mount=type=cache,target=/root/.bun/install/cache \
73
+ if [ "$OTEL_ENABLED" = "true" ]; then \
74
+ bun add --omit=dev --omit=peer --ignore-scripts @hono/otel \
60
75
  @opentelemetry/instrumentation-http \
61
76
  @opentelemetry/exporter-metrics-otlp-http \
62
77
  @opentelemetry/exporter-trace-otlp-http \
package/LICENSE CHANGED
@@ -186,7 +186,7 @@ Apache License
186
186
  same "printed page" as the copyright notice for easier
187
187
  identification within third-party archives.
188
188
 
189
- Copyright 2025 Casey Hand @cyanheads
189
+ Copyright 2026 Casey Hand @cyanheads
190
190
 
191
191
  Licensed under the Apache License, Version 2.0 (the "License");
192
192
  you may not use this file except in compliance with the License.
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  <div align="center">
9
9
 
10
- [![Version](https://img.shields.io/badge/Version-0.1.1-blue.svg?style=flat-square)](./CHANGELOG.md) [![License](https://img.shields.io/badge/License-Apache%202.0-orange.svg?style=flat-square)](./LICENSE) [![Docker](https://img.shields.io/badge/Docker-ghcr.io-2496ED?style=flat-square&logo=docker&logoColor=white)](https://github.com/users/cyanheads/packages/container/package/finnhub-mcp-server) [![MCP SDK](https://img.shields.io/badge/MCP%20SDK-^1.29.0-green.svg?style=flat-square)](https://modelcontextprotocol.io/) [![npm](https://img.shields.io/npm/v/@cyanheads/finnhub-mcp-server?style=flat-square&logo=npm&logoColor=white)](https://www.npmjs.com/package/@cyanheads/finnhub-mcp-server) [![TypeScript](https://img.shields.io/badge/TypeScript-^6.0.3-3178C6.svg?style=flat-square)](https://www.typescriptlang.org/) [![Bun](https://img.shields.io/badge/Bun-v1.3.0-blueviolet.svg?style=flat-square)](https://bun.sh/)
10
+ [![Version](https://img.shields.io/badge/Version-0.1.3-blue.svg?style=flat-square)](./CHANGELOG.md) [![License](https://img.shields.io/badge/License-Apache%202.0-orange.svg?style=flat-square)](./LICENSE) [![Docker](https://img.shields.io/badge/Docker-ghcr.io-2496ED?style=flat-square&logo=docker&logoColor=white)](https://github.com/users/cyanheads/packages/container/package/finnhub-mcp-server) [![MCP SDK](https://img.shields.io/badge/MCP%20SDK-2.0.0-green.svg?style=flat-square)](https://modelcontextprotocol.io/) [![npm](https://img.shields.io/npm/v/@cyanheads/finnhub-mcp-server?style=flat-square&logo=npm&logoColor=white)](https://www.npmjs.com/package/@cyanheads/finnhub-mcp-server) [![TypeScript](https://img.shields.io/badge/TypeScript-^7.0.2-3178C6.svg?style=flat-square)](https://www.typescriptlang.org/) [![Bun](https://img.shields.io/badge/Bun-v1.3.0-blueviolet.svg?style=flat-square)](https://bun.sh/)
11
11
 
12
12
  </div>
13
13
 
@@ -27,7 +27,7 @@ Six tools, name-first: `finnhub_search_symbols` resolves a company name to a US
27
27
 
28
28
  | Tool | Description |
29
29
  |:---|:---|
30
- | `finnhub_search_symbols` | Resolve a company name or partial ticker to US stock symbols, best US match first. The entry point for every other tool. |
30
+ | `finnhub_search_symbols` | Resolve a company name or partial ticker to stock symbols, best likely-US match first. The entry point for every other tool. |
31
31
  | `finnhub_get_quote` | Real-time price quote for one US symbol, paired with live market-status so the response states whether the price is live or the prior close. |
32
32
  | `finnhub_get_company` | Full company context in one call — profile, headline fundamentals (P/E, EPS, margins, growth), and sector peers. |
33
33
  | `finnhub_get_earnings` | Earnings in two modes: a symbol's past quarters with actual-vs-estimate surprises (`history`), or market-wide upcoming releases in a date window (`calendar`). |
@@ -38,8 +38,9 @@ Six tools, name-first: `finnhub_search_symbols` resolves a company name to a US
38
38
 
39
39
  Resolve a company name, partial name, or ticker fragment to Finnhub stock symbols. Run this first when you have a name, not a ticker — the rest of the surface needs a symbol.
40
40
 
41
- - Full-text match across symbols and descriptions; US Common Stock matches surfaced first
42
- - Each result carries `isLikelyUS` (a dot-suffix heuristic — `.SS`, `.T`, `.L` are international) so an agent can avoid spending a call on a symbol the free tier can't reach
41
+ - Full-text match across symbols and descriptions; likely-US Common Stock matches surfaced first
42
+ - `query` accepts 1–20 characters; use a shorter company name or ticker fragment when needed
43
+ - Each result carries `isLikelyUS`, a symbol-format heuristic: plain tickers and `.A`/`.B` class shares are likely US, while exchange suffixes such as `.SS`, `.T`, and `.L` are not. Quote and profile responses remain authoritative
43
44
  - `limit` (1–50, default 10); reports the total match count and discloses truncation when more matched than returned
44
45
 
45
46
  ---
@@ -124,7 +125,7 @@ Agent-friendly output:
124
125
 
125
126
  - Honest sparsity — every fundamental is nullable and absent values stay null; Finnhub's thinly-covered names are surfaced as-is, never zero-filled or fabricated
126
127
  - Two distinct "not available" signals — `symbol_not_found` (unknown US ticker, detected from the all-zero quote / empty profile sentinel) vs. `not_us_or_paid` (international or paid-only, HTTP 403) — so an agent can tell them apart and recover
127
- - Typed error contracts with recovery hints on every failure, plus `isLikelyUS` on search results so an agent avoids burning a call on an unreachable symbol
128
+ - Typed error contracts with recovery hints on every failure, plus the `isLikelyUS` search heuristic so an agent can prioritize likely free-tier symbols
128
129
  - Capped lists report their total count and disclose truncation, so an agent knows when more data exists
129
130
 
130
131
  ## Getting started
@@ -193,7 +194,7 @@ Or with Docker:
193
194
  For Streamable HTTP, set the transport and start the server:
194
195
 
195
196
  ```sh
196
- MCP_TRANSPORT_TYPE=http MCP_HTTP_PORT=3010 FINNHUB_API_KEY=... bun run start:http
197
+ MCP_TRANSPORT_TYPE=http MCP_SESSION_MODE=stateless MCP_HTTP_PORT=3010 FINNHUB_API_KEY=... bun run start:http
197
198
  # Server listens at http://localhost:3010/mcp
198
199
  ```
199
200
 
@@ -240,6 +241,7 @@ All configuration is validated at startup via Zod schemas in `src/config/server-
240
241
  | `MCP_TRANSPORT_TYPE` | Transport: `stdio` or `http`. | `stdio` |
241
242
  | `MCP_HTTP_PORT` | Port for the HTTP server. | `3010` |
242
243
  | `MCP_HTTP_ENDPOINT_PATH` | HTTP endpoint path where the MCP server is mounted. | `/mcp` |
244
+ | `MCP_SESSION_MODE` | Session handling: `auto`, `stateful`, or `stateless`. This project's `.env.example` and Docker image explicitly select `stateless`; an explicit environment value takes precedence. When unset, the framework defaults to `auto`, which currently resolves to `stateful`. | `auto` when unset; project example uses `stateless` |
243
245
  | `MCP_AUTH_MODE` | Auth mode: `none`, `jwt`, or `oauth`. | `none` |
244
246
  | `MCP_LOG_LEVEL` | Log level (RFC 5424: `debug`, `info`, `notice`, `warning`, `error`). | `info` |
245
247
  | `STORAGE_PROVIDER_TYPE` | Storage backend: `in-memory`, `filesystem`, `supabase`, `cloudflare-kv/r2/d1`. | `in-memory` |
@@ -0,0 +1,36 @@
1
+ ---
2
+ summary: "MCP SDK v2 via @cyanheads/mcp-ts-core ^0.12.3: protocol revision 2026-07-28 served beside 2025-era clients, strict tool inputs, error-envelope output schemas. Missing-symbol errors reclassified ValidationError. Bun 1.4.0 images, supply-chain install guard, TypeScript 7."
3
+ breaking: false
4
+ security: false
5
+ ---
6
+
7
+ # 0.1.2 — 2026-08-21
8
+
9
+ ## Changed
10
+
11
+ - **MCP SDK v2** — framework `@cyanheads/mcp-ts-core` ^0.10.6 → ^0.12.3. Every endpoint now also serves protocol revision 2026-07-28 alongside the 2025 era; existing 2025-era clients keep working.
12
+ - **Strict tool inputs** — an argument key a tool's schema does not declare is rejected by name instead of stripped.
13
+ - **Error envelope on the wire** — the advertised output schema declares `error`, so clients that validate `structuredContent` without checking `isError` stop rejecting error results with `-32602`.
14
+ - **`missing_symbol` reclassified** — `finnhub_get_earnings` (history mode) and `finnhub_get_news` (company mode) return `ValidationError` instead of `InvalidParams` when the required symbol is absent.
15
+ - **Bun 1.4.0** — Dockerfile pins on both stages plus `packageManager`; the build stage runs natively per architecture so multi-arch pushes do not emulate Bun; the production image omits optional peer tiers.
16
+ - **Supply-chain guard** — `bunfig.toml` holds freshly published versions for 3 days and runs the Socket security scanner on every install; framework releases are excluded and adopt same-day.
17
+ - **TypeScript ^7.0.2** — and the tsconfig split typechecks `tests/` alongside `src/`.
18
+
19
+ ## Fixed
20
+
21
+ - **Fetch timeouts classify as `Timeout`** again rather than surfacing as `ServiceUnavailable`.
22
+ - **`withRetry` honors upstream `Retry-After`** headers instead of blind exponential backoff.
23
+ - **A stalled response body aborts** — the request deadline now bounds the whole exchange, not just the response headers.
24
+ - **`MCP_AUTH_MODE=none` no longer advertises OAuth** protected-resource metadata over HTTP.
25
+ - **Stateful HTTP replays dropped SSE streams** — a client reconnecting with `Last-Event-ID` receives the frames it missed.
26
+
27
+ ## Dependencies
28
+
29
+ - `@cyanheads/mcp-ts-core` `^0.10.6` → `^0.12.3`
30
+ - `typescript` `^6.0.3` → `^7.0.2`
31
+ - `@types/node` `25.9.3` → `26.2.0`
32
+ - `@biomejs/biome` `2.5.0` → `2.5.9`
33
+ - `vitest` `^4.1.8` → `^4.1.11`
34
+ - `tsc-alias` `^1.8.17` → `^1.9.2`
35
+ - `ignore` `^7.0.5` → `^7.0.6`
36
+ - `@socketsecurity/bun-security-scanner` `^1.1.2` added
@@ -0,0 +1,21 @@
1
+ ---
2
+ summary: "Search now identifies US class-share symbols and rejects overlong queries before calling Finnhub; configuration examples explicitly choose stateless HTTP sessions."
3
+ breaking: false
4
+ security: false
5
+ ---
6
+
7
+ # 0.1.3 — 2026-08-30
8
+
9
+ ## Changed
10
+
11
+ - **`isLikelyUS`** — recognizes `.A` and `.B` US class-share symbols and ranks likely-US Common Stock results first; the documented flag remains a symbol-format heuristic, not an availability guarantee. (#1)
12
+ - **`MCP_SESSION_MODE`** — the environment example, HTTP launch example, and configuration reference explicitly select `stateless`; an unset value still follows the framework's `auto` behavior. (#8)
13
+
14
+ ## Fixed
15
+
16
+ - **`finnhub_search_symbols.query`** — rejects inputs longer than Finnhub's 20-character search limit before making an upstream request. (#3)
17
+
18
+ ## Dependencies
19
+
20
+ - `@biomejs/biome` `2.5.9` → `2.5.11`
21
+ - `@types/node` `26.2.0` → `26.4.0`