@cyanheads/hn-mcp-server 0.5.22 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +24 -11
- package/CLAUDE.md +24 -11
- package/Dockerfile +9 -3
- package/README.md +25 -15
- package/changelog/0.6.x/0.6.0.md +38 -0
- package/changelog/0.6.x/0.6.1.md +34 -0
- package/changelog/template.md +10 -3
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp-server/tools/definitions/get-stories.tool.d.ts +14 -0
- package/dist/mcp-server/tools/definitions/get-stories.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/get-stories.tool.js +25 -6
- package/dist/mcp-server/tools/definitions/get-stories.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/get-thread.tool.d.ts +8 -0
- package/dist/mcp-server/tools/definitions/get-thread.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/get-thread.tool.js +304 -182
- package/dist/mcp-server/tools/definitions/get-thread.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/get-user.tool.d.ts +15 -0
- package/dist/mcp-server/tools/definitions/get-user.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/get-user.tool.js +177 -104
- package/dist/mcp-server/tools/definitions/get-user.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/search-content.tool.d.ts +28 -4
- package/dist/mcp-server/tools/definitions/search-content.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/search-content.tool.js +291 -190
- package/dist/mcp-server/tools/definitions/search-content.tool.js.map +1 -1
- package/dist/mcp-server/tools/response-budget.d.ts +111 -0
- package/dist/mcp-server/tools/response-budget.d.ts.map +1 -0
- package/dist/mcp-server/tools/response-budget.js +204 -0
- package/dist/mcp-server/tools/response-budget.js.map +1 -0
- package/dist/services/hn/hn-service.d.ts +56 -12
- package/dist/services/hn/hn-service.d.ts.map +1 -1
- package/dist/services/hn/hn-service.js +147 -25
- package/dist/services/hn/hn-service.js.map +1 -1
- package/dist/services/hn/types.d.ts +4 -0
- package/dist/services/hn/types.d.ts.map +1 -1
- package/package.json +12 -11
- package/server.json +3 -3
- package/skills/hn-guide/SKILL.md +39 -0
package/AGENTS.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# Developer Protocol
|
|
2
2
|
|
|
3
3
|
**Server:** hn-mcp-server
|
|
4
|
-
**Version:** 0.
|
|
5
|
-
**Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core) `^0.13.
|
|
6
|
-
**Engines:** Bun ≥1.4.
|
|
7
|
-
**MCP SDK:** `@modelcontextprotocol/server` 2.
|
|
4
|
+
**Version:** 0.6.1
|
|
5
|
+
**Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core) `^0.13.22`
|
|
6
|
+
**Engines:** Bun ≥1.4.4, Node ≥24.0.0
|
|
7
|
+
**MCP SDK:** `@modelcontextprotocol/server` 2.4.0
|
|
8
8
|
**Zod:** ^4.6.7
|
|
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.
|
|
@@ -48,7 +48,7 @@ Tailor suggestions to what's actually missing or stale — don't recite the full
|
|
|
48
48
|
|
|
49
49
|
```ts
|
|
50
50
|
import { tool, z } from '@cyanheads/mcp-ts-core';
|
|
51
|
-
import { getHnService, settlePage, normalizeUrl, stripHtml } from '@/services/hn/hn-service.js';
|
|
51
|
+
import { CALL_BUDGET_MS, getHnService, settlePage, normalizeUrl, stripHtml } from '@/services/hn/hn-service.js';
|
|
52
52
|
|
|
53
53
|
export const getStories = tool('hn_get_stories', {
|
|
54
54
|
description: 'Fetch stories from an HN feed (top, new, best, ask, show, jobs).',
|
|
@@ -70,10 +70,12 @@ export const getStories = tool('hn_get_stories', {
|
|
|
70
70
|
|
|
71
71
|
async handler(input, ctx) {
|
|
72
72
|
const hn = getHnService();
|
|
73
|
-
|
|
73
|
+
// One time budget for the feed and every item fetch after it.
|
|
74
|
+
const deadline = Date.now() + CALL_BUDGET_MS;
|
|
75
|
+
const feedIds = await hn.fetchFeed(input.feed, ctx, deadline);
|
|
74
76
|
const sliced = feedIds.slice(input.offset, input.offset + input.count);
|
|
75
77
|
// Live items plus the IDs whose fetch failed; throws when every item failed.
|
|
76
|
-
const { items, failedIds } = settlePage(await hn.fetchItems(sliced, ctx));
|
|
78
|
+
const { items, failedIds } = settlePage(await hn.fetchItems(sliced, ctx, deadline));
|
|
77
79
|
if (failedIds.length > 0) ctx.enrich({ failedIds });
|
|
78
80
|
ctx.log.info('Fetched stories', { feed: input.feed, count: items.length });
|
|
79
81
|
return { stories: items.map(/* ... */), feed: input.feed, total: feedIds.length };
|
|
@@ -201,7 +203,7 @@ import { McpError, JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
|
201
203
|
throw new McpError(JsonRpcErrorCode.DatabaseError, 'Connection failed', { pool: 'primary' });
|
|
202
204
|
```
|
|
203
205
|
|
|
204
|
-
**Service-layer:** services don't have `ctx.fail`, but can carry the contract reason via `data: { reason: 'X' }` on a factory throw. The auto-classifier preserves `data` on the wire so clients see the same `error.data.reason` they'd see from `ctx.fail`, and the framework fills the contract's `recovery` for a throw that carries none. `hn-service.ts` throws
|
|
206
|
+
**Service-layer:** services don't have `ctx.fail`, but can carry the contract reason via `data: { reason: 'X' }` on a factory throw. The auto-classifier preserves `data` on the wire so clients see the same `error.data.reason` they'd see from `ctx.fail`, and the framework fills the contract's `recovery` for a throw that carries none. `hn-service.ts` throws five `upstream_*` reasons this way, each with an explicit `recovery: { hint }` that overrides the contract text with runtime context (the upstream's name, the `Retry-After` wait), plus `upstream_no_response` (a stories or user page on which every item failed, most often with no answer from the API), which carries no hint, so the contract's `recovery` fills it, and the declared `retry_deadline_exceeded` (`hn_get_stories`, `hn_get_user`, `hn_get_thread`). Each of their `errors[]` entries carries `thrownBy: 'service'` — `error-contract-unthrown` reads the handler body alone and would otherwise flag them as dead. See framework CLAUDE.md and `api-errors` skill for the full auto-classification table and all factories.
|
|
205
207
|
|
|
206
208
|
---
|
|
207
209
|
|
|
@@ -218,6 +220,7 @@ src/
|
|
|
218
220
|
types.ts # HN domain types
|
|
219
221
|
mcp-server/
|
|
220
222
|
tools/markdown-escape.ts # format() boundary: escape titles, quote bodies
|
|
223
|
+
tools/response-budget.ts # 64,000-byte budget per response surface: measure both surfaces, largest shared body cut, code-point cut
|
|
221
224
|
tools/served-at-cap.ts # notice sentence for a size input served at its per-call cap
|
|
222
225
|
tools/thread-cursor.ts # hn_get_thread cursor codec: packed frontier, JSON format still decoded
|
|
223
226
|
tools/definitions/
|
|
@@ -242,9 +245,18 @@ src/
|
|
|
242
245
|
|
|
243
246
|
## Skills
|
|
244
247
|
|
|
245
|
-
|
|
248
|
+
Two skill trees live at the project root, written for different readers:
|
|
246
249
|
|
|
247
|
-
|
|
250
|
+
| Tree | For | Written by |
|
|
251
|
+
|:-----|:----|:-----------|
|
|
252
|
+
| `framework-skills/` | The agent developing this server — framework skills (`metadata.audience: external`) plus any development-time skills of the server's own | `init` and the `maintenance` sync (framework skills); you (your own) |
|
|
253
|
+
| `skills/` | The agents that install the server and call its tools — tool chains, identifier sources, gates | You, deliberately, with the `add-skill` skill. Absent by default; usually none is needed |
|
|
254
|
+
|
|
255
|
+
Development skills are modular instructions. Read them directly when a task matches — e.g., `framework-skills/add-tool/SKILL.md` when adding a tool. `bun run list-skills` prints the full registry. Their directory is deliberately not `skills/`: Claude Code and Codex auto-load a plugin's root `skills/`, so a server that ships `.claude-plugin/` or `.codex-plugin/` would hand them to every agent that installs it.
|
|
256
|
+
|
|
257
|
+
A published skill in root `skills/` reaches plugin installs and the `.mcpb` bundle as-is, ships in the npm package and the Docker image, and reaches MCP clients when the server opts in with `createApp({ skills: 'skills' })`. `lint:packaging` validates the tree.
|
|
258
|
+
|
|
259
|
+
**Agent skill directory:** Copy `framework-skills/` into the directory your agent discovers (Claude Code: `.claude/skills/`, others: equivalent). Skills then load as context without referencing `framework-skills/` paths. After framework updates, run the `maintenance` skill — Phase B re-syncs the agent directory.
|
|
248
260
|
|
|
249
261
|
Available skills:
|
|
250
262
|
|
|
@@ -256,6 +268,7 @@ Available skills:
|
|
|
256
268
|
| `add-app-tool` | Scaffold an MCP App tool + paired UI resource |
|
|
257
269
|
| `add-resource` | Scaffold a new resource definition |
|
|
258
270
|
| `add-prompt` | Scaffold a new prompt definition |
|
|
271
|
+
| `add-skill` | Author a skill the server publishes in root `skills/` for the agents that use it — when one earns its place, structure, validation, delivery |
|
|
259
272
|
| `add-service` | Scaffold a new service integration |
|
|
260
273
|
| `add-test` | Scaffold test file for a tool, resource, or service |
|
|
261
274
|
| `field-test` | Exercise tools/resources/prompts with real inputs, verify behavior, report issues |
|
|
@@ -322,7 +335,7 @@ When you complete a skill's checklist, check the boxes and add a completion time
|
|
|
322
335
|
|
|
323
336
|
## Bundling
|
|
324
337
|
|
|
325
|
-
`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
|
|
338
|
+
`bun run bundle` produces a `.mcpb` extension bundle for one-click install in Claude Desktop. `mcpb pack` reads `.mcpbignore`, not `.gitignore`, so every root path the bundle must not ship — source, tests, docs, caches, logs, agent docs, plugin manifests, gitignored and local-only files such as `claude-plans/` — needs a root-anchored line there (`/docs/`, never `docs/`, which also strips `node_modules/*/docs/`); `lint:packaging` names each missing or unanchored line. Root `skills/` ships on purpose. The pack step is followed by `scripts/clean-mcpb.ts`, which prunes dev dependencies (`mcpb clean`) and strips four classes of `node_modules/**` content that root-anchored `.mcpbignore` patterns cannot reach: dependency-shipped agent docs (`framework-skills/`, `skills/`, `.claude/`, `.agents/`, `AGENTS.md`, and `CLAUDE.md` at a package's root, and any `SKILL.md`); platform-specific native bindings; node-gyp build output beside a `binding.gyp`; and the framework's build-only files. The agent-doc selector matches only at a package root because a `skills/` deeper in a package is runtime code: MCP SDK 2.4 ships its Skills extension at `@modelcontextprotocol/{server,core}/dist/ext/skills/`, which the framework imports at startup. `tests/scripts/bundle-agent-docs.test.ts` pins that selector in both `clean-mcpb.ts` and `lint-packaging.ts`, so a script resync that would strip the SDK's modules fails the suite. MCPB is stdio-only — HTTP deployments are unaffected.
|
|
326
339
|
|
|
327
340
|
**Adding an env var requires both files:** `server.json` (registry discovery, `environmentVariables[]`) and `manifest.json` (bundle install UX, `mcp_config.env` + `user_config`). `lint:packaging` (run by `devcheck`) verifies the env var names match, that every `user_config` option is wired into `mcp_config.env` as `"X": "${user_config.X}"` (the host substitutes nothing else — `"${X}"` reaches the server as that literal string), and that an optional string option carries `"default": ""`.
|
|
328
341
|
|
package/CLAUDE.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# Developer Protocol
|
|
2
2
|
|
|
3
3
|
**Server:** hn-mcp-server
|
|
4
|
-
**Version:** 0.
|
|
5
|
-
**Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core) `^0.13.
|
|
6
|
-
**Engines:** Bun ≥1.4.
|
|
7
|
-
**MCP SDK:** `@modelcontextprotocol/server` 2.
|
|
4
|
+
**Version:** 0.6.1
|
|
5
|
+
**Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core) `^0.13.22`
|
|
6
|
+
**Engines:** Bun ≥1.4.4, Node ≥24.0.0
|
|
7
|
+
**MCP SDK:** `@modelcontextprotocol/server` 2.4.0
|
|
8
8
|
**Zod:** ^4.6.7
|
|
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.
|
|
@@ -48,7 +48,7 @@ Tailor suggestions to what's actually missing or stale — don't recite the full
|
|
|
48
48
|
|
|
49
49
|
```ts
|
|
50
50
|
import { tool, z } from '@cyanheads/mcp-ts-core';
|
|
51
|
-
import { getHnService, settlePage, normalizeUrl, stripHtml } from '@/services/hn/hn-service.js';
|
|
51
|
+
import { CALL_BUDGET_MS, getHnService, settlePage, normalizeUrl, stripHtml } from '@/services/hn/hn-service.js';
|
|
52
52
|
|
|
53
53
|
export const getStories = tool('hn_get_stories', {
|
|
54
54
|
description: 'Fetch stories from an HN feed (top, new, best, ask, show, jobs).',
|
|
@@ -70,10 +70,12 @@ export const getStories = tool('hn_get_stories', {
|
|
|
70
70
|
|
|
71
71
|
async handler(input, ctx) {
|
|
72
72
|
const hn = getHnService();
|
|
73
|
-
|
|
73
|
+
// One time budget for the feed and every item fetch after it.
|
|
74
|
+
const deadline = Date.now() + CALL_BUDGET_MS;
|
|
75
|
+
const feedIds = await hn.fetchFeed(input.feed, ctx, deadline);
|
|
74
76
|
const sliced = feedIds.slice(input.offset, input.offset + input.count);
|
|
75
77
|
// Live items plus the IDs whose fetch failed; throws when every item failed.
|
|
76
|
-
const { items, failedIds } = settlePage(await hn.fetchItems(sliced, ctx));
|
|
78
|
+
const { items, failedIds } = settlePage(await hn.fetchItems(sliced, ctx, deadline));
|
|
77
79
|
if (failedIds.length > 0) ctx.enrich({ failedIds });
|
|
78
80
|
ctx.log.info('Fetched stories', { feed: input.feed, count: items.length });
|
|
79
81
|
return { stories: items.map(/* ... */), feed: input.feed, total: feedIds.length };
|
|
@@ -201,7 +203,7 @@ import { McpError, JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
|
201
203
|
throw new McpError(JsonRpcErrorCode.DatabaseError, 'Connection failed', { pool: 'primary' });
|
|
202
204
|
```
|
|
203
205
|
|
|
204
|
-
**Service-layer:** services don't have `ctx.fail`, but can carry the contract reason via `data: { reason: 'X' }` on a factory throw. The auto-classifier preserves `data` on the wire so clients see the same `error.data.reason` they'd see from `ctx.fail`, and the framework fills the contract's `recovery` for a throw that carries none. `hn-service.ts` throws
|
|
206
|
+
**Service-layer:** services don't have `ctx.fail`, but can carry the contract reason via `data: { reason: 'X' }` on a factory throw. The auto-classifier preserves `data` on the wire so clients see the same `error.data.reason` they'd see from `ctx.fail`, and the framework fills the contract's `recovery` for a throw that carries none. `hn-service.ts` throws five `upstream_*` reasons this way, each with an explicit `recovery: { hint }` that overrides the contract text with runtime context (the upstream's name, the `Retry-After` wait), plus `upstream_no_response` (a stories or user page on which every item failed, most often with no answer from the API), which carries no hint, so the contract's `recovery` fills it, and the declared `retry_deadline_exceeded` (`hn_get_stories`, `hn_get_user`, `hn_get_thread`). Each of their `errors[]` entries carries `thrownBy: 'service'` — `error-contract-unthrown` reads the handler body alone and would otherwise flag them as dead. See framework CLAUDE.md and `api-errors` skill for the full auto-classification table and all factories.
|
|
205
207
|
|
|
206
208
|
---
|
|
207
209
|
|
|
@@ -218,6 +220,7 @@ src/
|
|
|
218
220
|
types.ts # HN domain types
|
|
219
221
|
mcp-server/
|
|
220
222
|
tools/markdown-escape.ts # format() boundary: escape titles, quote bodies
|
|
223
|
+
tools/response-budget.ts # 64,000-byte budget per response surface: measure both surfaces, largest shared body cut, code-point cut
|
|
221
224
|
tools/served-at-cap.ts # notice sentence for a size input served at its per-call cap
|
|
222
225
|
tools/thread-cursor.ts # hn_get_thread cursor codec: packed frontier, JSON format still decoded
|
|
223
226
|
tools/definitions/
|
|
@@ -242,9 +245,18 @@ src/
|
|
|
242
245
|
|
|
243
246
|
## Skills
|
|
244
247
|
|
|
245
|
-
|
|
248
|
+
Two skill trees live at the project root, written for different readers:
|
|
246
249
|
|
|
247
|
-
|
|
250
|
+
| Tree | For | Written by |
|
|
251
|
+
|:-----|:----|:-----------|
|
|
252
|
+
| `framework-skills/` | The agent developing this server — framework skills (`metadata.audience: external`) plus any development-time skills of the server's own | `init` and the `maintenance` sync (framework skills); you (your own) |
|
|
253
|
+
| `skills/` | The agents that install the server and call its tools — tool chains, identifier sources, gates | You, deliberately, with the `add-skill` skill. Absent by default; usually none is needed |
|
|
254
|
+
|
|
255
|
+
Development skills are modular instructions. Read them directly when a task matches — e.g., `framework-skills/add-tool/SKILL.md` when adding a tool. `bun run list-skills` prints the full registry. Their directory is deliberately not `skills/`: Claude Code and Codex auto-load a plugin's root `skills/`, so a server that ships `.claude-plugin/` or `.codex-plugin/` would hand them to every agent that installs it.
|
|
256
|
+
|
|
257
|
+
A published skill in root `skills/` reaches plugin installs and the `.mcpb` bundle as-is, ships in the npm package and the Docker image, and reaches MCP clients when the server opts in with `createApp({ skills: 'skills' })`. `lint:packaging` validates the tree.
|
|
258
|
+
|
|
259
|
+
**Agent skill directory:** Copy `framework-skills/` into the directory your agent discovers (Claude Code: `.claude/skills/`, others: equivalent). Skills then load as context without referencing `framework-skills/` paths. After framework updates, run the `maintenance` skill — Phase B re-syncs the agent directory.
|
|
248
260
|
|
|
249
261
|
Available skills:
|
|
250
262
|
|
|
@@ -256,6 +268,7 @@ Available skills:
|
|
|
256
268
|
| `add-app-tool` | Scaffold an MCP App tool + paired UI resource |
|
|
257
269
|
| `add-resource` | Scaffold a new resource definition |
|
|
258
270
|
| `add-prompt` | Scaffold a new prompt definition |
|
|
271
|
+
| `add-skill` | Author a skill the server publishes in root `skills/` for the agents that use it — when one earns its place, structure, validation, delivery |
|
|
259
272
|
| `add-service` | Scaffold a new service integration |
|
|
260
273
|
| `add-test` | Scaffold test file for a tool, resource, or service |
|
|
261
274
|
| `field-test` | Exercise tools/resources/prompts with real inputs, verify behavior, report issues |
|
|
@@ -322,7 +335,7 @@ When you complete a skill's checklist, check the boxes and add a completion time
|
|
|
322
335
|
|
|
323
336
|
## Bundling
|
|
324
337
|
|
|
325
|
-
`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
|
|
338
|
+
`bun run bundle` produces a `.mcpb` extension bundle for one-click install in Claude Desktop. `mcpb pack` reads `.mcpbignore`, not `.gitignore`, so every root path the bundle must not ship — source, tests, docs, caches, logs, agent docs, plugin manifests, gitignored and local-only files such as `claude-plans/` — needs a root-anchored line there (`/docs/`, never `docs/`, which also strips `node_modules/*/docs/`); `lint:packaging` names each missing or unanchored line. Root `skills/` ships on purpose. The pack step is followed by `scripts/clean-mcpb.ts`, which prunes dev dependencies (`mcpb clean`) and strips four classes of `node_modules/**` content that root-anchored `.mcpbignore` patterns cannot reach: dependency-shipped agent docs (`framework-skills/`, `skills/`, `.claude/`, `.agents/`, `AGENTS.md`, and `CLAUDE.md` at a package's root, and any `SKILL.md`); platform-specific native bindings; node-gyp build output beside a `binding.gyp`; and the framework's build-only files. The agent-doc selector matches only at a package root because a `skills/` deeper in a package is runtime code: MCP SDK 2.4 ships its Skills extension at `@modelcontextprotocol/{server,core}/dist/ext/skills/`, which the framework imports at startup. `tests/scripts/bundle-agent-docs.test.ts` pins that selector in both `clean-mcpb.ts` and `lint-packaging.ts`, so a script resync that would strip the SDK's modules fails the suite. MCPB is stdio-only — HTTP deployments are unaffected.
|
|
326
339
|
|
|
327
340
|
**Adding an env var requires both files:** `server.json` (registry discovery, `environmentVariables[]`) and `manifest.json` (bundle install UX, `mcp_config.env` + `user_config`). `lint:packaging` (run by `devcheck`) verifies the env var names match, that every `user_config` option is wired into `mcp_config.env` as `"X": "${user_config.X}"` (the host substitutes nothing else — `"${X}"` reaches the server as that literal string), and that an optional string option carries `"default": ""`.
|
|
328
341
|
|
package/Dockerfile
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
# output. A stage that compiles a native addon needs the target-arch toolchain
|
|
15
15
|
# and cannot cross-compile this way — drop the flag there.
|
|
16
16
|
# ==============================================================================
|
|
17
|
-
FROM --platform=$BUILDPLATFORM oven/bun:1.4.
|
|
17
|
+
FROM --platform=$BUILDPLATFORM oven/bun:1.4.4 AS build
|
|
18
18
|
|
|
19
19
|
WORKDIR /usr/src/app
|
|
20
20
|
|
|
@@ -29,6 +29,11 @@ RUN --mount=type=cache,target=/root/.bun/install/cache \
|
|
|
29
29
|
# Copy the rest of the source code
|
|
30
30
|
COPY . .
|
|
31
31
|
|
|
32
|
+
# The skills a server publishes (`createApp({ skills: 'skills' })`) are read at
|
|
33
|
+
# runtime from the application root. Created when the project has none, so the
|
|
34
|
+
# production stage's copy below holds with or without one.
|
|
35
|
+
RUN mkdir -p skills
|
|
36
|
+
|
|
32
37
|
# Build the application
|
|
33
38
|
RUN bun run build
|
|
34
39
|
|
|
@@ -46,7 +51,7 @@ RUN bun run build
|
|
|
46
51
|
# A clean image rather than `FROM build`: the build stage's node_modules holds
|
|
47
52
|
# devDependencies.
|
|
48
53
|
# ==============================================================================
|
|
49
|
-
FROM --platform=$BUILDPLATFORM oven/bun:1.4.
|
|
54
|
+
FROM --platform=$BUILDPLATFORM oven/bun:1.4.4 AS deps
|
|
50
55
|
|
|
51
56
|
WORKDIR /usr/src/app
|
|
52
57
|
|
|
@@ -114,7 +119,7 @@ RUN rm -rf node_modules/@socketsecurity/bun-security-scanner
|
|
|
114
119
|
# dependencies and build artifacts. Its only Bun invocations are HEALTHCHECK
|
|
115
120
|
# and CMD, which run on the real target at container start.
|
|
116
121
|
# ==============================================================================
|
|
117
|
-
FROM oven/bun:1.4.
|
|
122
|
+
FROM oven/bun:1.4.4-slim AS production
|
|
118
123
|
|
|
119
124
|
WORKDIR /usr/src/app
|
|
120
125
|
|
|
@@ -136,6 +141,7 @@ COPY --from=deps /usr/src/app/node_modules ./node_modules
|
|
|
136
141
|
|
|
137
142
|
# Copy the compiled application code from the build stage
|
|
138
143
|
COPY --from=build /usr/src/app/dist ./dist
|
|
144
|
+
COPY --from=build /usr/src/app/skills ./skills
|
|
139
145
|
|
|
140
146
|
# The 'oven/bun' image already provides a non-root user named 'bun'.
|
|
141
147
|
# We will use this existing user for enhanced security.
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
<div align="center">
|
|
9
9
|
|
|
10
|
-
[](./CHANGELOG.md) [](./LICENSE) [](https://github.com/users/cyanheads/packages/container/package/hn-mcp-server) [](https://modelcontextprotocol.io/) [](https://www.npmjs.com/package/@cyanheads/hn-mcp-server) [](https://www.typescriptlang.org/) [](https://bun.sh/)
|
|
11
11
|
|
|
12
12
|
</div>
|
|
13
13
|
|
|
@@ -38,7 +38,13 @@ Hacker News feeds, threads, and profiles. Browse ranked feeds, read full comment
|
|
|
38
38
|
| `hn_get_stories` | Fetch stories from an HN feed (top, new, best, ask, show, jobs), with title, URL, score, author, and comment count |
|
|
39
39
|
| `hn_get_thread` | Get an item and its comment tree as a threaded discussion, with depth and comment-count controls and a cursor to page through long threads |
|
|
40
40
|
| `hn_get_user` | Fetch a user profile with karma, about, and optionally a page of resolved submissions |
|
|
41
|
-
| `hn_search_content` | Search stories, comments, polls, and jobs via Algolia by keyword, by filters alone, or both — type, author, parent story, date range, and minimum
|
|
41
|
+
| `hn_search_content` | Search stories, comments, polls, and jobs via Algolia by keyword, by filters alone, or both — type, author, parent story, date range, minimum points, and minimum comment count |
|
|
42
|
+
|
|
43
|
+
### Agent skill
|
|
44
|
+
|
|
45
|
+
| Skill | Description |
|
|
46
|
+
|:---|:---|
|
|
47
|
+
| [`hn-guide`](skills/hn-guide/SKILL.md) | How to find a link's thread, search without Algolia's fuzzy matches, read large comment trees in full, and search what one user said. Served over MCP as `skill://hn-guide/SKILL.md` and shipped in the npm package |
|
|
42
48
|
|
|
43
49
|
## Capability reference
|
|
44
50
|
|
|
@@ -47,19 +53,19 @@ Hacker News feeds, threads, and profiles. Browse ranked feeds, read full comment
|
|
|
47
53
|
- Six feed types: `top`, `new`, `best`, `ask`, `show`, `jobs`; `count` (default 30) and `offset` for pagination. One call serves at most 100 stories; a `count` up to 1,000 is served at 100, with a `notice` naming the next `offset`
|
|
48
54
|
- Returns id, type, title, url, domain, score, author, timestamp, comment count, and body text — each field omitted (not null) when HN doesn't provide it
|
|
49
55
|
- Enrichment reports `total`, `offset`, and `hasMore`; while more stories remain, `truncated` is set and `notice` names the next `offset`, and a `notice` explains empty pages (empty feed, offset past end, or every item on the page deleted/flagged). The last page carries no truncation
|
|
50
|
-
- Items whose fetch failed after retries are listed in `failedIds` with a `notice` naming the retry; a page where every item failed returns the classified
|
|
56
|
+
- Items whose fetch failed after retries, or ran past the call's 50-second time budget, are listed in `failedIds` with a `notice` naming the retry; a page where every item failed returns the classified error of its dominant cause instead of an empty list: `upstream_rate_limited` when any item was rate-limited, otherwise the most frequent declared upstream reason, or `upstream_no_response` (`Timeout`) when no answer from the HN API at all was the most common failure
|
|
51
57
|
|
|
52
58
|
---
|
|
53
59
|
|
|
54
60
|
### `hn_get_thread` <sub>tool</sub>
|
|
55
61
|
|
|
56
|
-
- `itemId` plus `depth` (default 3; 0 returns the item with no comments) and `maxComments` (default 50) capping one response across all levels, alongside a fixed 64,000-byte text
|
|
62
|
+
- `itemId` plus `depth` (default 3; 0 returns the item with no comments) and `maxComments` (default 50) capping one response across all levels, alongside a fixed 64,000-byte budget on each response surface (all `content[]` text, `nextCursor` included, and the `structuredContent` JSON) that cuts only between comments and always returns a page's first comment whole. One call resolves at most 10 levels and 200 comments; a `depth` up to 100 is served at 10 and a `maxComments` up to 1,000 at 200, with a `notice` naming the comment to pass as `itemId` or the `nextCursor` that reaches the rest
|
|
57
63
|
- Breadth-first traversal ranked like HN — top-ranked top-level comments resolve first, replies fill in only after the level above is exhausted
|
|
58
|
-
- Resumable: a response stopped by `maxComments`, the byte budget,
|
|
64
|
+
- Resumable: a response stopped by `maxComments`, the byte budget, an upstream rate limit, or the call's 50-second time budget returns `nextCursor`; passing it back as `cursor` with the same `itemId` continues at the next unseen comment. The cursor carries the unvisited comments themselves, so re-ranked replies cannot shift it, and the server keeps no session state. A cursor the tool did not issue, an altered one, or one passed with a different `itemId` fails with `invalid_cursor`
|
|
59
65
|
- The root carries its relationships and state: `parent` and `storyId` (the story or poll the discussion belongs to) for a comment, `poll` for a poll option, `parts` and resolved `options` (text and votes, at every depth) for a poll, and `deleted`/`dead` markers. The `content[]` heading names the type — a title, `Comment by <author>`, `Poll option by <author> on poll <id>` — and marks a deleted or dead root
|
|
60
66
|
- Flat comment list carries `depth`/`parentId` for tree reconstruction, plus `childCount` and an `isOp` flag when the comment author submitted the thread's story — on a comment root, the story at `storyId`, never the comment's own author. Dead and deleted comments are left out, but their live replies are still returned at their true `depth`, with `parentId` naming the omitted comment
|
|
61
|
-
- `truncated` and `truncationReason` (`count`, `size`, `rate_limited`, or `depth` when replies lie below the depth limit) are set only while comments remain unread — never on a terminal page, including a thread that loads in full at exactly the cap. `notice` reports deleted/dead comments omitted during traversal and the next step: the cursor, or a larger `depth` or a comment id as `itemId`, naming by ID any omitted comment whose replies the depth limit cut
|
|
62
|
-
- Comments and poll options whose fetch failed after retries are listed in `failedIds`, and `notice` names them with the retry; failed comments ride in `nextCursor`, so paging on retries them rather than skipping them. The root item is still returned, and a failure is never passed off as a `maxComments`/`depth` limit
|
|
67
|
+
- `truncated` and `truncationReason` (`count`, `size`, `rate_limited`, `time`, or `depth` when replies lie below the depth limit) are set only while comments remain unread — never on a terminal page, including a thread that loads in full at exactly the cap. `notice` reports deleted/dead comments omitted during traversal and the next step: the cursor, or a larger `depth` or a comment id as `itemId`, naming by ID any omitted comment whose replies the depth limit cut
|
|
68
|
+
- Comments and poll options whose fetch failed after retries or ran past the call's time budget are listed in `failedIds`, and `notice` names them with the retry; failed comments ride in `nextCursor`, so paging on retries them rather than skipping them. The root item is still returned, and a failure is never passed off as a `maxComments`/`depth` limit
|
|
63
69
|
|
|
64
70
|
---
|
|
65
71
|
|
|
@@ -69,22 +75,26 @@ Hacker News feeds, threads, and profiles. Browse ranked feeds, read full comment
|
|
|
69
75
|
- Profile includes karma, creation date, and about text (HTML stripped); submissions filter out dead/deleted items
|
|
70
76
|
- A comment submission carries its `parent` and a poll-option submission its `poll`, so either links back to what it answered
|
|
71
77
|
- Enrichment echoes `submissionOffset` and the offset to send next, or a notice when the requested offset is past the end of the history
|
|
72
|
-
- Submissions whose fetch failed after retries are listed in `failedIds` with a `notice` naming the retry; a window where every submission failed returns the classified
|
|
78
|
+
- Submissions whose fetch failed after retries, or that the call's 50-second time budget cut, are listed in `failedIds` with a `notice` naming the retry (and the budget, when it cut them); a window where every submission failed returns the classified error of its dominant cause, as `hn_get_stories` does, with `upstream_no_response` (`Timeout`) when no answer was the most common failure, the budget cutting them all included
|
|
79
|
+
- A final window whose submissions are all dead, deleted, or absent gets a `notice` saying so, with the `submissionOffset` and `total`
|
|
80
|
+
- Each response surface is held to a fixed 64,000-byte budget: an over-budget page keeps every submission and cuts the longest bodies to one shared length, flagging each with `textTruncated` and pointing to `hn_get_thread` for the whole text
|
|
73
81
|
|
|
74
82
|
---
|
|
75
83
|
|
|
76
84
|
### `hn_search_content` <sub>tool</sub>
|
|
77
85
|
|
|
78
|
-
- Free-text `query` plus `tags` (`story`/`comment`/`poll`/`job`/`ask_hn`/`show_hn`/`front_page`), `author` (the exact, case-sensitive username), `storyId`, `dateRange`, and `
|
|
86
|
+
- Free-text `query` — typo-tolerant, with the last term also matching as a prefix; wrap a term in double quotes to match it exactly and put `-` before one to exclude it — plus `tags` (`story`/`comment`/`poll`/`job`/`ask_hn`/`show_hn`/`front_page`), `author` (the exact, case-sensitive username), `storyId`, `dateRange`, `minPoints`, and `minComments` filters; `sort` by relevance or date; `count` (default 30) and `page` for pagination. One call serves at most 50 hits; a `count` up to 1,000 is served as the page of 50 starting at the requested page's first hit, with a `notice` naming the `count: 50` page to pass next; a non-zero `page` whose first hit begins no page of 50 fails with `count_page_unaligned`, naming a `count` and `page` that start there and, when that count is under 25, the page of 50 that holds that hit
|
|
79
87
|
- `tags: "front_page"` is the front page right now (about 30 stories), never past front pages; for an earlier window, use `tags: "story"` with `dateRange` and `minPoints`
|
|
80
88
|
- `query` is optional when a filter is set — list Ask HN, Show HN, polls, or jobs on their own, or pass a story's `storyId` with `tags: "comment"` to search within one thread. No query and no filter fails with `missing_query_or_filter`
|
|
81
89
|
- To check whether a page was discussed, pass its URL alone as `query`: the leading `http://`, `https://`, or `www.` is dropped before searching, so submissions under either scheme, with or without `www.`, all match. The output `query` and the notice show what was searched
|
|
82
90
|
- `dateRange` bounds take ISO 8601 (`YYYY`, `YYYY-MM`, `YYYY-MM-DD`, or a date-time with optional offset), read as UTC and both exclusive; an empty or out-of-order range fails with `invalid_date_range`
|
|
83
91
|
- `minPoints` applies to stories and polls — comments and jobs carry no points, so pairing it with `tags: "comment"` or `"job"` fails with `min_points_unscored_type`
|
|
84
|
-
- `
|
|
92
|
+
- `minComments` applies to stories and polls the same way: any value, 0 included, excludes comments, jobs, and poll options, so an untagged search returns only stories and polls, and pairing it with `tags: "comment"` or `"job"` fails with `min_comments_unscored_type`. It filters; it does not sort
|
|
93
|
+
- A comment hit carries `parentId` (its story's id for a top-level comment, otherwise the parent comment's id, which `hn_get_thread` reads) and, when its story links out, `storyUrl`; in `content[]` the meta line shows `parent:<id>` and the story link sits on its own line
|
|
94
|
+
- `view: "compact"` drops the two body-text fields (`text`, `highlights.text`), which otherwise repeat a long comment twice per hit — pass a hit id to `hn_get_thread` to read the body. In `full`, a page over 64,000 bytes per response surface drops `highlights.text` from every hit (`highlightsTextOmitted`), then cuts the longest bodies to one shared length (`textTruncated`, with an `hn_get_thread` pointer) — every hit stays
|
|
85
95
|
- Each hit carries its `type` (`story`, `comment`, `poll`, `pollopt`, `job`) when Algolia records one. Untagged searches also return poll options, which carry only an id, author, vote count, and date — `hn_get_thread` reads an option's text and poll. A poll hit has no `storyId`; its own `id` is the discussion root
|
|
86
96
|
- Job descriptions come back as `text`, though keywords don't search them
|
|
87
|
-
- Highlight metadata (`highlights.title`, `highlights.text`, `matchedWords`) shows which terms matched and where
|
|
97
|
+
- Highlight metadata (`highlights.title`, `highlights.text`, `matchedWords`) shows which terms matched and where; `highlights.text` is the matched body in full with `<em>` markers
|
|
88
98
|
- Enrichment echoes the applied `criteria` — each filter set (`author` trimmed, `dateRange` as the exclusive UTC bounds applied, to the second), plus `sort`, `count`, and `view` with defaults filled — so a saved result says what it answers
|
|
89
99
|
- Enrichment reports `totalHits`, `page`, and the actual reachable `totalPages` — not derived from `totalHits`, since broad queries report far more hits than Algolia will serve. `totalHitsExact: false` marks `totalHits` as an estimate, and `reachableHits: 1000` marks a search that matches more than Algolia's 1,000-hit ceiling; the last page of such a search gets a notice naming the ceiling and narrower `dateRange` windows to reach the rest. While more pages remain, `truncated` is set and `notice` names the next `page`; a page past the end gets a notice naming the last valid page (or `page: 0` past the ceiling)
|
|
90
100
|
|
|
@@ -98,14 +108,14 @@ HN-specific:
|
|
|
98
108
|
- Concurrent batch fetching with configurable parallelism for item resolution (`HN_CONCURRENCY_LIMIT`)
|
|
99
109
|
- HTML bodies stripped to plain text — entities decoded once, code blocks kept verbatim, each link rendered once as its full URL — while titles, which are not HTML though some carry entities, are entity-decoded and never tag-stripped
|
|
100
110
|
- Server-level `instructions` forwarded to LLM clients on `initialize` — item types, ID reuse across tools, case-sensitive usernames, field sparsity
|
|
101
|
-
- No API keys required — both upstream APIs are public
|
|
111
|
+
- No API keys required — both upstream APIs are public; every request identifies itself with a `User-Agent` of `hn-mcp-server/<version>` and the repository URL
|
|
102
112
|
|
|
103
113
|
Agent-friendly output:
|
|
104
114
|
|
|
105
|
-
- Graceful partial failure — an item whose fetch fails after retries is reported by ID in `failedIds`, apart from deleted, dead, or nonexistent items, rather than silently shrinking the result; `hn_get_thread` also counts the deleted and dead comments it drops, and a rate-limited item stops the batch instead of sending every remaining item through its own retry ladder
|
|
115
|
+
- Graceful partial failure — an item whose fetch fails after retries is reported by ID in `failedIds`, apart from deleted, dead, or nonexistent items, rather than silently shrinking the result; each `hn_get_thread`, `hn_get_stories`, and `hn_get_user` call runs under one 50-second time budget, so hung fetches cannot hold it past an MCP client's 60-second timeout; `hn_get_thread` also counts the deleted and dead comments it drops, and a rate-limited item stops the batch instead of sending every remaining item through its own retry ladder
|
|
106
116
|
- Discriminated output contracts — typed error reasons (`item_not_found`, `upstream_rate_limited`, `upstream_html`, …) with per-reason recovery text (a rate limit passes on the upstream's `Retry-After` as `retryAfter`), and a `depth`/`parentId` pair on every comment so callers reconstruct the tree without guessing nesting
|
|
107
117
|
- Pagination provenance — every paged listing echoes the offset it used (`offset`, `submissionOffset`, `page`) plus the exact next-offset value in `notice`, `hn_search_content` also echoes the `criteria` it searched with, and `hn_get_thread` returns a self-contained `nextCursor`, so an agent can resume without recomputing state
|
|
108
|
-
- Response shaping — HTML stripping, URL normalization, and domain extraction remove upstream markup noise; `hn_search_content`'s `view: "compact"` drops the two body-text fields that otherwise duplicate a hit's full text
|
|
118
|
+
- Response shaping — HTML stripping, URL normalization, and domain extraction remove upstream markup noise; `hn_search_content`'s `view: "compact"` drops the two body-text fields that otherwise duplicate a hit's full text, and a 64,000-byte budget on each response surface cuts the longest bodies of an over-budget page
|
|
109
119
|
- Fenced upstream text — in `content[]`, every line of a body is block-quoted and titles are escaped only where they could break the surrounding Markdown, so a comment cannot pass for a server-authored line
|
|
110
120
|
|
|
111
121
|
## Getting started
|
|
@@ -183,7 +193,7 @@ Or with Docker:
|
|
|
183
193
|
|
|
184
194
|
### Prerequisites
|
|
185
195
|
|
|
186
|
-
- [Bun v1.4.
|
|
196
|
+
- [Bun v1.4.4](https://bun.sh/) or higher (or Node.js >= 24)
|
|
187
197
|
|
|
188
198
|
### Installation
|
|
189
199
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
summary: "hn_search_content, hn_get_user, and hn_get_thread hold each response surface to 64,000 bytes; hn_get_thread, hn_get_stories, and hn_get_user run under one 50-second time budget; the hn-guide agent skill is served as a skill:// resource."
|
|
3
|
+
breaking: false
|
|
4
|
+
security: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# 0.6.0 — 2026-10-28
|
|
8
|
+
|
|
9
|
+
## Added
|
|
10
|
+
|
|
11
|
+
- **Published `hn-guide` Agent Skill**: `resources/list` now lists `skill://hn-guide/SKILL.md` and `resources/templates/list` lists the `skill://{+path}` template, served through mcp-ts-core 0.13.18's `createApp({ skills })`. The skill also ships in the npm package and the Docker image.
|
|
12
|
+
- **Root `plugin.json` and `mcp.json`**: the Agent Plugins 1.0.0 manifest pair, alongside the Claude and Codex plugin overlays.
|
|
13
|
+
|
|
14
|
+
## Changed
|
|
15
|
+
|
|
16
|
+
- **`hn_search_content` `query` description** documents typo tolerance, prefix matching on the last term, `"quoted"` exact terms, and `-` exclusion. `highlights.text` is described as the matched body in full, not a snippet.
|
|
17
|
+
- **Framework rendering in `content[]`** (mcp-ts-core 0.13.16–0.13.18): error text and trailer text gain Markdown escapes, every line of a `notice` is block-quoted, and string trailer values such as `nextCursor` and `truncationReason` render as code spans. `structuredContent` is unchanged.
|
|
18
|
+
- **`.mcpb` bundle** leaves out repo-local root paths and build-only package files; the agent-doc strip is anchored at each package root so MCP SDK 2.4's `dist/ext/skills/` stays in the bundle.
|
|
19
|
+
- **Framework sync**: `framework-skills/` synced to 0.13.18 (adds `add-skill`), `scripts/` and `.github/ISSUE_TEMPLATE/bug_report.yml` resynced, and `bunfig.toml` `minimumReleaseAge` is 1 day (was 3).
|
|
20
|
+
|
|
21
|
+
## Fixed
|
|
22
|
+
|
|
23
|
+
- **`hn_search_content` holds the `full` view to 64,000 bytes** on all of `content[]` and on `structuredContent`, each. An over-budget page drops `highlights.text` from every hit (`highlightsTextOmitted: true`), then cuts the longest `text` bodies to one shared limit (`textTruncated: true`, with an `hn_get_thread` pointer in `content[]`). Every hit stays, and `notice` names the budget and the cut ids. (#46)
|
|
24
|
+
- **`hn_get_user` holds a submissions page to the same 64,000 bytes per surface**: the longest submission bodies are cut to one shared limit and flagged `textTruncated`, every submission stays, and `user.about` is never cut. (#49)
|
|
25
|
+
- **`hn_get_thread` counts the whole response against its `size` stop**: `content[]` text with the trailer and `nextCursor`, and the `structuredContent` JSON, are each held to 64,000 bytes. A page's first comment is still returned whole. (#50)
|
|
26
|
+
- **`hn_get_thread`, `hn_get_stories`, and `hn_get_user` run under one 50-second time budget** counted from the call's start. A fetch the budget cuts or leaves unstarted is listed in `failedIds` and `notice` names the budget; `hn_get_thread` stops with `truncationReason: "time"` and a `nextCursor`, and a stories or user call where the budget cuts every fetch fails with `Timeout`. (#47)
|
|
27
|
+
|
|
28
|
+
## Dependencies
|
|
29
|
+
|
|
30
|
+
- `@cyanheads/mcp-ts-core` ^0.13.15 → ^0.13.18 (0.13.16: Markdown-escaped error and trailer text; 0.13.17: `@modelcontextprotocol/server` 2.4; 0.13.18: `createApp({ skills })`, code-span trailer values)
|
|
31
|
+
- `@modelcontextprotocol/server` 2.3.1 → 2.4.0 (via the framework)
|
|
32
|
+
- `@modelcontextprotocol/core` 2.3.1 → 2.4.0 (transitive)
|
|
33
|
+
- `@opentelemetry/api` 1.9.1 → 1.10.0 (transitive)
|
|
34
|
+
- `jose` 6.2.12 → 6.2.13 (transitive)
|
|
35
|
+
- Dev: `@biomejs/biome` ^2.5.15 → ^2.6.3
|
|
36
|
+
- Dev: `ignore` ^7.0.12 → ^7.0.14
|
|
37
|
+
- Dev: `tsc-alias` ^1.9.7 → ^1.9.9
|
|
38
|
+
- `packageManager` bun@1.4.3 → bun@1.4.4; Docker base images `oven/bun` 1.4.3 → 1.4.4
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
summary: "hn_search_content gains a minComments filter and parentId and storyUrl on comment hits; a stories or user page on which every item failed throws its dominant cause, with a new upstream_no_response reason when the HN API gave no answer."
|
|
3
|
+
breaking: false
|
|
4
|
+
security: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# 0.6.1 — 2026-11-12
|
|
8
|
+
|
|
9
|
+
## Added
|
|
10
|
+
|
|
11
|
+
- **`hn_search_content` `minComments` filter**: an integer ≥ 0, sent to Algolia as `num_comments>=N`. It applies to stories and polls and is rejected with `tags: "comment"` or `"job"` as `min_comments_unscored_type`. (#54)
|
|
12
|
+
- **`hn_search_content` comment hits carry `parentId` and `storyUrl`**: the id of the item the comment replies to (read it with `hn_get_thread`), and the link its story submitted, absent for a text post. (#53)
|
|
13
|
+
- **`User-Agent` on every Firebase and Algolia request**: `hn-mcp-server/<version> (+https://github.com/cyanheads/hn-mcp-server)`.
|
|
14
|
+
|
|
15
|
+
## Changed
|
|
16
|
+
|
|
17
|
+
- **`hn_get_user` notice for an empty final window**: a window whose submissions are all dead, deleted, or absent now says so, with its `submissionOffset` and `total`.
|
|
18
|
+
- **`hn-guide` skill 1.1**: corrects the hiring-thread posting dates and adds `minComments` guidance.
|
|
19
|
+
- **Framework adoption** (mcp-ts-core 0.13.19–0.13.22): Bun ≥1.4.4 is required; on Node.js below 24 the server now exits at startup, naming the running version; `initialize`'s `serverInfo` carries `description`; a rate-limit error's trailer adds `retry after <value>`; installed as a project dependency, the server resolves its own `skills/` and logs directory; the `.mcpb` bundle no longer ships dependency-root `AGENTS.md` and `CLAUDE.md`. `framework-skills/`, `scripts/`, and `changelog/template.md` are resynced.
|
|
20
|
+
|
|
21
|
+
## Fixed
|
|
22
|
+
|
|
23
|
+
- **A stories or user page on which every item failed throws its dominant cause** instead of the first slot's error: a rate limit first, otherwise the most frequent declared upstream reason. When no answer from the HN API is the most common failure, it throws the new `upstream_no_response` (`Timeout`, with `data.itemCount` and `data.budgetCut`), declared on `hn_get_stories` and `hn_get_user`. (#51)
|
|
24
|
+
- **`retry_deadline_exceeded` is declared** in `errors[]` on `hn_get_stories`, `hn_get_user`, and `hn_get_thread`.
|
|
25
|
+
|
|
26
|
+
## Dependencies
|
|
27
|
+
|
|
28
|
+
- `@cyanheads/mcp-ts-core` ^0.13.18 → ^0.13.22
|
|
29
|
+
- Dev: `@biomejs/biome` ^2.6.3 → ^2.6.6
|
|
30
|
+
- Dev: `@types/node` ^26.6.5 → ^26.6.6
|
|
31
|
+
- Dev: `@vitest/coverage-istanbul` ^5.0.5 → ^5.1.0
|
|
32
|
+
- Dev: `vitest` ^5.0.5 → ^5.1.0
|
|
33
|
+
- Dev: `tsc-alias` ^1.9.9 → ^1.9.10
|
|
34
|
+
- `engines.bun` >=1.4.0 → >=1.4.4
|
package/changelog/template.md
CHANGED
|
@@ -116,14 +116,21 @@ security: false
|
|
|
116
116
|
resolves to whatever real item already owns 42, and timeline previews pull
|
|
117
117
|
in that unrelated item's metadata.
|
|
118
118
|
|
|
119
|
+
Outside reporters: when the issue or PR came from outside the project
|
|
120
|
+
(`git-wrapup` step 5 says how to tell), thank its author in the same
|
|
121
|
+
parenthetical, profile linked by full URL for the same reason:
|
|
122
|
+
|
|
123
|
+
([#38](https://github.com/cyanheads/mcp-ts-core/issues/38), thanks [@octocat](https://github.com/octocat)!)
|
|
124
|
+
|
|
119
125
|
TAG ANNOTATIONS — the annotated tag body renders as the GitHub Release body
|
|
120
126
|
via `gh release create --notes-from-tag`. It is a condensed digest of this
|
|
121
127
|
entry, never a copy, and its format is owned by the `release-and-publish`
|
|
122
128
|
skill (step 4, "Create the annotated tag"): a short subject line without the
|
|
123
129
|
version, flat headline bullets — no Keep-a-Changelog section headers, no
|
|
124
|
-
gates line — at most one deps line, issue backlinks
|
|
125
|
-
last. In release-PR mode the `git-wrapup`
|
|
126
|
-
PR body's `## Changes` and the tag copies
|
|
130
|
+
gates line — at most one deps line, issue backlinks with any outside-reporter
|
|
131
|
+
thanks, and the changelog link last. In release-PR mode the `git-wrapup`
|
|
132
|
+
skill authors those bullets as the PR body's `## Changes` and the tag copies
|
|
133
|
+
them.
|
|
127
134
|
-->
|
|
128
135
|
|
|
129
136
|
## Added
|
package/dist/index.js
CHANGED
|
@@ -13,9 +13,10 @@ await createApp({
|
|
|
13
13
|
name: 'hn-mcp-server',
|
|
14
14
|
title: 'hn-mcp-server',
|
|
15
15
|
tools: [getStories, getThread, getUser, searchHn],
|
|
16
|
-
instructions: 'Use the hn_* tools to access Hacker News via the Firebase API and Algolia search: ranked feeds; search by keyword, by type/author/story/date/score filters alone, or both; user profiles; and items with their comment trees. Items are addressed by integer ID, reused across tools and item types (story, comment, job, poll, pollopt); passing a comment id to hn_get_thread drills into that subtree. Usernames are case-sensitive; HN sparsely populates fields, so treat absent values as unknown.',
|
|
16
|
+
instructions: 'Use the hn_* tools to access Hacker News via the Firebase API and Algolia search: ranked feeds; search by keyword, by type/author/story/date/score/comment-count filters alone, or both; user profiles; and items with their comment trees. Items are addressed by integer ID, reused across tools and item types (story, comment, job, poll, pollopt); passing a comment id to hn_get_thread drills into that subtree. Usernames are case-sensitive; HN sparsely populates fields, so treat absent values as unknown.',
|
|
17
17
|
landing: { requireAuth: false },
|
|
18
18
|
sessionMode: 'stateless',
|
|
19
|
+
skills: 'skills',
|
|
19
20
|
setup() {
|
|
20
21
|
initHnService();
|
|
21
22
|
},
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,oDAAoD,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,mDAAmD,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,iDAAiD,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,uDAAuD,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,MAAM,SAAS,CAAC;IACd,IAAI,EAAE,eAAe;IACrB,KAAK,EAAE,eAAe;IACtB,KAAK,EAAE,CAAC,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,CAAC;IACjD,YAAY,EACV,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,oDAAoD,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,mDAAmD,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,iDAAiD,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,uDAAuD,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,MAAM,SAAS,CAAC;IACd,IAAI,EAAE,eAAe;IACrB,KAAK,EAAE,eAAe;IACtB,KAAK,EAAE,CAAC,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,CAAC;IACjD,YAAY,EACV,wfAAwf;IAC1f,OAAO,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE;IAC/B,WAAW,EAAE,WAAW;IACxB,MAAM,EAAE,QAAQ;IAChB,KAAK;QACH,aAAa,EAAE,CAAC;IAClB,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -63,6 +63,20 @@ export declare const getStories: import("@cyanheads/mcp-ts-core").ToolDefinition
|
|
|
63
63
|
readonly recovery: "Retry after a brief delay; no input change helps while the upstream serves this.";
|
|
64
64
|
readonly retryable: true;
|
|
65
65
|
readonly thrownBy: "service";
|
|
66
|
+
}, {
|
|
67
|
+
readonly reason: "upstream_no_response";
|
|
68
|
+
readonly code: JsonRpcErrorCode.Timeout;
|
|
69
|
+
readonly when: "Every item on the page failed, none with HTTP 429, and no answer from the HN API was the most common failure — timed out after retries, could not connect, or ran past this call's 50-second time budget.";
|
|
70
|
+
readonly recovery: "Retry the same call after a short delay; when the time budget cut any of the items, pass a smaller count so fewer items share it.";
|
|
71
|
+
readonly retryable: true;
|
|
72
|
+
readonly thrownBy: "service";
|
|
73
|
+
}, {
|
|
74
|
+
readonly reason: "retry_deadline_exceeded";
|
|
75
|
+
readonly code: JsonRpcErrorCode.Timeout;
|
|
76
|
+
readonly when: "The HN API was too slow to return the feed: its retries ran past this call's 50-second time budget.";
|
|
77
|
+
readonly recovery: "Retry the same call after a short delay; the HN API answered too slowly to finish within this call's time budget.";
|
|
78
|
+
readonly retryable: true;
|
|
79
|
+
readonly thrownBy: "service";
|
|
66
80
|
}], {
|
|
67
81
|
readonly total: z.ZodNumber;
|
|
68
82
|
readonly offset: z.ZodNumber;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-stories.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/get-stories.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"get-stories.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/get-stories.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAoBjE,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiSrB,CAAC"}
|
|
@@ -6,7 +6,7 @@ import { tool, z } from '@cyanheads/mcp-ts-core';
|
|
|
6
6
|
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
7
7
|
import { escapeInline, quoteBody } from '../markdown-escape.js';
|
|
8
8
|
import { servedAtCap } from '../served-at-cap.js';
|
|
9
|
-
import { decodeHtmlEntities, extractDomain, getHnService, normalizeUrl, settlePage, stripHtml, } from '../../../services/hn/hn-service.js';
|
|
9
|
+
import { CALL_BUDGET_MS, decodeHtmlEntities, extractDomain, getHnService, normalizeUrl, settlePage, stripHtml, timeBudgetCutSentence, } from '../../../services/hn/hn-service.js';
|
|
10
10
|
/** Most stories one call serves; a larger `count` is served at this cap. */
|
|
11
11
|
const COUNT_CAP = 100;
|
|
12
12
|
/** Largest `count` accepted; anything above it is rejected. */
|
|
@@ -54,6 +54,22 @@ export const getStories = tool('hn_get_stories', {
|
|
|
54
54
|
retryable: true,
|
|
55
55
|
thrownBy: 'service',
|
|
56
56
|
},
|
|
57
|
+
{
|
|
58
|
+
reason: 'upstream_no_response',
|
|
59
|
+
code: JsonRpcErrorCode.Timeout,
|
|
60
|
+
when: `Every item on the page failed, none with HTTP 429, and no answer from the HN API was the most common failure — timed out after retries, could not connect, or ran past this call's ${CALL_BUDGET_MS / 1000}-second time budget.`,
|
|
61
|
+
recovery: 'Retry the same call after a short delay; when the time budget cut any of the items, pass a smaller count so fewer items share it.',
|
|
62
|
+
retryable: true,
|
|
63
|
+
thrownBy: 'service',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
reason: 'retry_deadline_exceeded',
|
|
67
|
+
code: JsonRpcErrorCode.Timeout,
|
|
68
|
+
when: `The HN API was too slow to return the feed: its retries ran past this call's ${CALL_BUDGET_MS / 1000}-second time budget.`,
|
|
69
|
+
recovery: "Retry the same call after a short delay; the HN API answered too slowly to finish within this call's time budget.",
|
|
70
|
+
retryable: true,
|
|
71
|
+
thrownBy: 'service',
|
|
72
|
+
},
|
|
57
73
|
],
|
|
58
74
|
input: z.object({
|
|
59
75
|
feed: z
|
|
@@ -134,21 +150,24 @@ export const getStories = tool('hn_get_stories', {
|
|
|
134
150
|
failedIds: z
|
|
135
151
|
.array(z.number())
|
|
136
152
|
.optional()
|
|
137
|
-
.describe(
|
|
153
|
+
.describe(`IDs on this page whose fetch failed after retries or ran past the call's ${CALL_BUDGET_MS / 1000}-second time budget. They are not deleted or missing and may load on a later call: retry the page with the same offset, or pass an ID to hn_get_thread to fetch that story alone. Absent when every item on the page loaded.`),
|
|
138
154
|
notice: z
|
|
139
155
|
.string()
|
|
140
156
|
.optional()
|
|
141
|
-
.describe(
|
|
157
|
+
.describe(`Agent guidance: the offset to pass for the next page while more stories remain, the IDs that failed to load and how to retry them (naming the call's ${CALL_BUDGET_MS / 1000}-second time budget when it cut them), or why a page came back empty — offset past the end of the feed, an empty feed, or every item on the page deleted or flagged — noting when count was served at its per-call cap. Absent on the last page of a non-empty result with no failed IDs.`),
|
|
142
158
|
},
|
|
143
159
|
enrichmentTrailer: {
|
|
144
160
|
failedIds: { render: (ids) => `**Failed to load:** ${(ids ?? []).join(', ')}` },
|
|
145
161
|
},
|
|
146
162
|
async handler(input, ctx) {
|
|
147
163
|
const hn = getHnService();
|
|
148
|
-
|
|
164
|
+
/** One budget for the feed and every item fetch after it. */
|
|
165
|
+
const deadline = Date.now() + CALL_BUDGET_MS;
|
|
166
|
+
const feedIds = await hn.fetchFeed(input.feed, ctx, deadline);
|
|
149
167
|
const count = Math.min(input.count, COUNT_CAP);
|
|
150
168
|
const sliced = feedIds.slice(input.offset, input.offset + count);
|
|
151
|
-
const
|
|
169
|
+
const slots = await hn.fetchItems(sliced, ctx, deadline);
|
|
170
|
+
const { items, failedIds } = settlePage(slots);
|
|
152
171
|
const stories = items.map((item) => {
|
|
153
172
|
const url = normalizeUrl(item.url);
|
|
154
173
|
const domain = extractDomain(url);
|
|
@@ -181,7 +200,7 @@ export const getStories = tool('hn_get_stories', {
|
|
|
181
200
|
});
|
|
182
201
|
const deadPageMessage = `No live stories on this page of the ${input.feed} feed (offset:${input.offset}, total:${total}). Items may have been deleted or flagged.`;
|
|
183
202
|
const failureMessage = failedIds.length > 0
|
|
184
|
-
? `Could not fetch ${failedIds.length} of ${sliced.length} items on this page (id${failedIds.length === 1 ? '' : 's'} ${failedIds.join(', ')})
|
|
203
|
+
? `Could not fetch ${failedIds.length} of ${sliced.length} items on this page (id${failedIds.length === 1 ? '' : 's'} ${failedIds.join(', ')}).${timeBudgetCutSentence(slots)} Retry with offset: ${input.offset}, or pass an id as itemId to hn_get_thread to fetch that story alone.`
|
|
185
204
|
: undefined;
|
|
186
205
|
if (hasMore) {
|
|
187
206
|
const raiseCount = input.count < COUNT_CAP ? `, or raise count (max ${COUNT_CAP})` : '';
|