@cyanheads/hn-mcp-server 0.5.18 → 0.5.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/AGENTS.md +5 -3
  2. package/CLAUDE.md +5 -3
  3. package/README.md +13 -7
  4. package/changelog/0.5.x/0.5.19.md +19 -0
  5. package/dist/mcp-server/tools/definitions/get-stories.tool.d.ts +2 -1
  6. package/dist/mcp-server/tools/definitions/get-stories.tool.d.ts.map +1 -1
  7. package/dist/mcp-server/tools/definitions/get-stories.tool.js +33 -11
  8. package/dist/mcp-server/tools/definitions/get-stories.tool.js.map +1 -1
  9. package/dist/mcp-server/tools/definitions/get-thread.tool.d.ts +30 -2
  10. package/dist/mcp-server/tools/definitions/get-thread.tool.d.ts.map +1 -1
  11. package/dist/mcp-server/tools/definitions/get-thread.tool.js +510 -173
  12. package/dist/mcp-server/tools/definitions/get-thread.tool.js.map +1 -1
  13. package/dist/mcp-server/tools/definitions/get-user.tool.d.ts +4 -1
  14. package/dist/mcp-server/tools/definitions/get-user.tool.d.ts.map +1 -1
  15. package/dist/mcp-server/tools/definitions/get-user.tool.js +54 -21
  16. package/dist/mcp-server/tools/definitions/get-user.tool.js.map +1 -1
  17. package/dist/mcp-server/tools/definitions/search-content.tool.d.ts +1 -1
  18. package/dist/mcp-server/tools/definitions/search-content.tool.d.ts.map +1 -1
  19. package/dist/mcp-server/tools/definitions/search-content.tool.js +3 -3
  20. package/dist/mcp-server/tools/definitions/search-content.tool.js.map +1 -1
  21. package/dist/services/hn/hn-service.d.ts +60 -12
  22. package/dist/services/hn/hn-service.d.ts.map +1 -1
  23. package/dist/services/hn/hn-service.js +87 -25
  24. package/dist/services/hn/hn-service.js.map +1 -1
  25. package/package.json +1 -1
  26. package/server.json +3 -3
package/AGENTS.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Developer Protocol
2
2
 
3
3
  **Server:** hn-mcp-server
4
- **Version:** 0.5.18
4
+ **Version:** 0.5.19
5
5
  **Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core) `^0.13.6`
6
6
  **Engines:** Bun ≥1.4.0, Node ≥24.0.0
7
7
  **MCP SDK:** `@modelcontextprotocol/server` 2.0.0
@@ -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, filterLiveItems, normalizeUrl, stripHtml } from '@/services/hn/hn-service.js';
51
+ import { 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).',
@@ -72,7 +72,9 @@ export const getStories = tool('hn_get_stories', {
72
72
  const hn = getHnService();
73
73
  const feedIds = await hn.fetchFeed(input.feed, ctx);
74
74
  const sliced = feedIds.slice(input.offset, input.offset + input.count);
75
- const items = filterLiveItems(await hn.fetchItems(sliced, ctx));
75
+ // Live items plus the IDs whose fetch failed; throws when every item failed.
76
+ const { items, failedIds } = settlePage(await hn.fetchItems(sliced, ctx));
77
+ if (failedIds.length > 0) ctx.enrich({ failedIds });
76
78
  ctx.log.info('Fetched stories', { feed: input.feed, count: items.length });
77
79
  return { stories: items.map(/* ... */), feed: input.feed, total: feedIds.length };
78
80
  },
package/CLAUDE.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Developer Protocol
2
2
 
3
3
  **Server:** hn-mcp-server
4
- **Version:** 0.5.18
4
+ **Version:** 0.5.19
5
5
  **Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core) `^0.13.6`
6
6
  **Engines:** Bun ≥1.4.0, Node ≥24.0.0
7
7
  **MCP SDK:** `@modelcontextprotocol/server` 2.0.0
@@ -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, filterLiveItems, normalizeUrl, stripHtml } from '@/services/hn/hn-service.js';
51
+ import { 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).',
@@ -72,7 +72,9 @@ export const getStories = tool('hn_get_stories', {
72
72
  const hn = getHnService();
73
73
  const feedIds = await hn.fetchFeed(input.feed, ctx);
74
74
  const sliced = feedIds.slice(input.offset, input.offset + input.count);
75
- const items = filterLiveItems(await hn.fetchItems(sliced, ctx));
75
+ // Live items plus the IDs whose fetch failed; throws when every item failed.
76
+ const { items, failedIds } = settlePage(await hn.fetchItems(sliced, ctx));
77
+ if (failedIds.length > 0) ctx.enrich({ failedIds });
76
78
  ctx.log.info('Fetched stories', { feed: input.feed, count: items.length });
77
79
  return { stories: items.map(/* ... */), feed: input.feed, total: feedIds.length };
78
80
  },
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.5.18-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/hn-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/hn-mcp-server?style=flat-square&logo=npm&logoColor=white)](https://www.npmjs.com/package/@cyanheads/hn-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->=1.4.0-f9f1e1.svg?style=flat-square)](https://bun.sh/)
10
+ [![Version](https://img.shields.io/badge/Version-0.5.19-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/hn-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/hn-mcp-server?style=flat-square&logo=npm&logoColor=white)](https://www.npmjs.com/package/@cyanheads/hn-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->=1.4.0-f9f1e1.svg?style=flat-square)](https://bun.sh/)
11
11
 
12
12
  </div>
13
13
 
@@ -36,7 +36,7 @@ Feeds, threads, and profiles from the Hacker News Firebase API and Algolia Searc
36
36
  | Tool | Description |
37
37
  |:---|:---|
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
- | `hn_get_thread` | Get an item and its comment tree as a threaded discussion, with depth and comment-count controls |
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
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 points |
42
42
 
@@ -47,15 +47,19 @@ Feeds, threads, and profiles from the Hacker News Firebase API and Algolia Searc
47
47
  - Six feed types: `top`, `new`, `best`, `ask`, `show`, `jobs`; `count` (1–100, default 30) and `offset` for pagination
48
48
  - 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
49
  - 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 upstream error instead of an empty list
50
51
 
51
52
  ---
52
53
 
53
54
  ### `hn_get_thread` <sub>tool</sub>
54
55
 
55
- - `itemId` plus `depth` (0–10, default 3; 0 returns the item with no comments) and `maxComments` (1–200, default 50) capping the total across all levels
56
+ - `itemId` plus `depth` (0–10, default 3; 0 returns the item with no comments) and `maxComments` (1–200, default 50) capping one response across all levels, alongside a fixed 64,000-byte text budget that cuts only between comments
56
57
  - 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, or an upstream rate limit 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 passed with a different `itemId` fails with `invalid_cursor`
59
+ - The root carries its relationships and state: `parent` 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
57
60
  - Flat comment list carries `depth`/`parentId` for tree reconstruction, plus `childCount` and an `isOp` flag when the comment author matches the root item's author
58
- - `notice` reports deleted/dead comments omitted during traversal and, when `totalLoaded` is below `totalAvailable`, the hint to raise `maxComments`/`depth`; `truncated` is set only when `maxComments` stopped the traversal with comments left, not when a thread loads in full at exactly the cap
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`
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
59
63
 
60
64
  ---
61
65
 
@@ -63,7 +67,9 @@ Feeds, threads, and profiles from the Hacker News Firebase API and Algolia Searc
63
67
 
64
68
  - `username` is case-sensitive and trimmed; `includeSubmissions` (default false) resolves recent submissions, with `submissionCount` (1–50, default 10) and `submissionOffset` paging through a long history
65
69
  - Profile includes karma, creation date, and about text (HTML stripped); submissions filter out dead/deleted items
70
+ - A comment submission carries its `parent` and a poll-option submission its `poll`, so either links back to what it answered
66
71
  - 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 upstream error
67
73
 
68
74
  ---
69
75
 
@@ -91,9 +97,9 @@ HN-specific:
91
97
 
92
98
  Agent-friendly output:
93
99
 
94
- - Graceful partial failure — `hn_get_thread` counts deleted and dead comments dropped during traversal and surfaces the count in `notice` rather than silently shrinking the result; `hn_get_stories` and `hn_get_user` filter dead/deleted items the same way
95
- - Discriminated output contracts — typed error reasons (`item_not_found`, `upstream_rate_limited`, `upstream_html`, …) with per-reason recovery text, and a `depth`/`parentId` pair on every comment so callers reconstruct the tree without guessing nesting
96
- - Pagination provenance — every paged tool echoes the offset it used (`offset`, `submissionOffset`, `page`) plus the exact next-offset value in `notice`, so an agent can resume a listing without recomputing state
100
+ - 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
101
+ - 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
102
+ - Pagination provenance — every paged listing echoes the offset it used (`offset`, `submissionOffset`, `page`) plus the exact next-offset value in `notice`, and `hn_get_thread` returns a self-contained `nextCursor`, so an agent can resume without recomputing state
97
103
  - 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
98
104
 
99
105
  ## Getting started
@@ -0,0 +1,19 @@
1
+ ---
2
+ summary: "hn_get_thread gains a resumable cursor, root relationships, and poll options; hn_get_stories/hn_get_thread/hn_get_user report failed item fetches instead of dropping them, and a 429's Retry-After now reaches the recovery hint."
3
+ breaking: false
4
+ security: false
5
+ ---
6
+
7
+ # 0.5.19 — 2026-09-23
8
+
9
+ ## Added
10
+
11
+ - **`hn_get_thread.cursor` / `nextCursor`** resume a traversal cut by `maxComments`, a new 64,000-byte response budget, a 1,000-item ceiling on what one call examines, or a rate limit, without skipping or repeating comments. `truncationReason` (`count`, `size`, `rate_limited`, `depth`) replaces the old raise-`maxComments`-or-`depth` guidance, and an `invalid_cursor` reason fires when a cursor is passed with a different `itemId`. ([#20](https://github.com/cyanheads/hn-mcp-server/issues/20))
12
+ - **`hn_get_thread`'s root** carries `parent` (comment roots), `poll` (poll-option roots), `parts` and resolved `options` (poll roots, resolved at every `depth` including `0`), and `deleted`/`dead` markers; the `content[]` heading is type-aware. `hn_get_user` submissions carry the same `parent`/`poll` links. ([#19](https://github.com/cyanheads/hn-mcp-server/issues/19))
13
+ - **`failedIds`** on `hn_get_stories`, `hn_get_thread`, and `hn_get_user` names items whose fetch failed after retries, apart from deleted, dead, or missing ones, with a retry notice. An `hn_get_stories` or `hn_get_user` page where every item failed now throws the classified upstream error instead of returning empty; `hn_get_thread` still returns its root. A rate-limited item stops the batch rather than sending every remaining item through its own retry ladder. ([#18](https://github.com/cyanheads/hn-mcp-server/issues/18))
14
+ - **A 429's `Retry-After` header** passes through unchanged as `data.retryAfter` and the recovery hint, naming the exact wait instead of a generic "several seconds". ([#26](https://github.com/cyanheads/hn-mcp-server/issues/26))
15
+
16
+ ## Fixed
17
+
18
+ - **`hn_search_content.dateRange.end`** rounds a fractional second up instead of down, so an item created in that same whole second is no longer excluded.
19
+ - **`hn_search_content`'s `invalid_date_range` check** compares `start` and `end` as exact instants instead of truncated seconds, so two bounds within the same second are no longer rejected as out of order.
@@ -39,7 +39,7 @@ export declare const getStories: import("@cyanheads/mcp-ts-core").ToolDefinition
39
39
  readonly reason: "upstream_rate_limited";
40
40
  readonly code: JsonRpcErrorCode.RateLimited;
41
41
  readonly when: "The HN API answered with HTTP 429.";
42
- readonly recovery: "Wait several seconds before retrying, and call this tool less often.";
42
+ readonly recovery: "Wait the interval in retryAfter when the error carries one, otherwise several seconds, then retry and call this tool less often.";
43
43
  readonly retryable: true;
44
44
  readonly thrownBy: "service";
45
45
  }, {
@@ -70,6 +70,7 @@ export declare const getStories: import("@cyanheads/mcp-ts-core").ToolDefinition
70
70
  readonly truncated: z.ZodOptional<z.ZodBoolean>;
71
71
  readonly shown: z.ZodOptional<z.ZodNumber>;
72
72
  readonly cap: z.ZodOptional<z.ZodNumber>;
73
+ readonly failedIds: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
73
74
  readonly notice: z.ZodOptional<z.ZodString>;
74
75
  }>;
75
76
  //# sourceMappingURL=get-stories.tool.d.ts.map
@@ -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;AAYjE,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqOrB,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;AAYjE,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8PrB,CAAC"}
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import { tool, z } from '@cyanheads/mcp-ts-core';
6
6
  import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
7
- import { extractDomain, filterLiveItems, getHnService, normalizeUrl, stripHtml, } from '../../../services/hn/hn-service.js';
7
+ import { extractDomain, getHnService, normalizeUrl, settlePage, stripHtml, } from '../../../services/hn/hn-service.js';
8
8
  /** Largest page `count` accepts, mirrored in the input schema. */
9
9
  const MAX_COUNT = 100;
10
10
  export const getStories = tool('hn_get_stories', {
@@ -22,7 +22,7 @@ export const getStories = tool('hn_get_stories', {
22
22
  reason: 'upstream_rate_limited',
23
23
  code: JsonRpcErrorCode.RateLimited,
24
24
  when: 'The HN API answered with HTTP 429.',
25
- recovery: 'Wait several seconds before retrying, and call this tool less often.',
25
+ recovery: 'Wait the interval in retryAfter when the error carries one, otherwise several seconds, then retry and call this tool less often.',
26
26
  retryable: true,
27
27
  thrownBy: 'service',
28
28
  },
@@ -121,17 +121,23 @@ export const getStories = tool('hn_get_stories', {
121
121
  .describe('True when more stories remain beyond this page (hasMore). Absent on the last page of the feed.'),
122
122
  shown: z.number().optional().describe('Number of stories returned on this page.'),
123
123
  cap: z.number().optional().describe('The count cap that was applied.'),
124
+ failedIds: z
125
+ .array(z.number())
126
+ .optional()
127
+ .describe('IDs on this page whose fetch failed after retries. 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.'),
124
128
  notice: z
125
129
  .string()
126
130
  .optional()
127
- .describe('Agent guidance: the offset to pass for the next page while more stories remain, 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. Absent on the last page of a non-empty result.'),
131
+ .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, 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. Absent on the last page of a non-empty result with no failed IDs.'),
132
+ },
133
+ enrichmentTrailer: {
134
+ failedIds: { render: (ids) => `**Failed to load:** ${(ids ?? []).join(', ')}` },
128
135
  },
129
136
  async handler(input, ctx) {
130
137
  const hn = getHnService();
131
138
  const feedIds = await hn.fetchFeed(input.feed, ctx);
132
139
  const sliced = feedIds.slice(input.offset, input.offset + input.count);
133
- const rawItems = await hn.fetchItems(sliced, ctx);
134
- const items = filterLiveItems(rawItems);
140
+ const { items, failedIds } = settlePage(await hn.fetchItems(sliced, ctx));
135
141
  const stories = items.map((item) => {
136
142
  const url = normalizeUrl(item.url);
137
143
  const domain = extractDomain(url);
@@ -148,21 +154,34 @@ export const getStories = tool('hn_get_stories', {
148
154
  ...(item.text && { text: stripHtml(item.text) }),
149
155
  };
150
156
  });
151
- ctx.log.info('Fetched stories', { feed: input.feed, count: stories.length });
157
+ ctx.log.info('Fetched stories', {
158
+ feed: input.feed,
159
+ count: stories.length,
160
+ failed: failedIds.length,
161
+ });
152
162
  const total = feedIds.length;
153
163
  const nextOffset = input.offset + input.count;
154
164
  const hasMore = nextOffset < total;
155
- ctx.enrich({ total, offset: input.offset, hasMore });
165
+ ctx.enrich({
166
+ total,
167
+ offset: input.offset,
168
+ hasMore,
169
+ ...(failedIds.length > 0 && { failedIds }),
170
+ });
156
171
  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.`;
172
+ const failureMessage = failedIds.length > 0
173
+ ? `Could not fetch ${failedIds.length} of ${sliced.length} items on this page (id${failedIds.length === 1 ? '' : 's'} ${failedIds.join(', ')}). Retry with offset: ${input.offset}, or pass an id as itemId to hn_get_thread to fetch that story alone.`
174
+ : undefined;
157
175
  if (hasMore) {
158
176
  const raiseCount = input.count < MAX_COUNT ? `, or raise count (max ${MAX_COUNT})` : '';
159
177
  const nextPage = `Pass offset: ${nextOffset} for the next page${raiseCount}.`;
178
+ const pageStatus = stories.length === 0 && !failureMessage
179
+ ? deadPageMessage
180
+ : `Showing items ${input.offset + 1}–${nextOffset} of ${total} in the ${input.feed} feed.`;
160
181
  ctx.enrich.truncated({
161
182
  shown: stories.length,
162
183
  cap: input.count,
163
- guidance: stories.length === 0
164
- ? `${deadPageMessage} ${nextPage}`
165
- : `Showing items ${input.offset + 1}–${nextOffset} of ${total} in the ${input.feed} feed. ${nextPage}`,
184
+ guidance: [pageStatus, failureMessage, nextPage].filter(Boolean).join(' '),
166
185
  });
167
186
  }
168
187
  else if (stories.length === 0) {
@@ -173,9 +192,12 @@ export const getStories = tool('hn_get_stories', {
173
192
  ctx.enrich.notice(`Offset ${input.offset} is past the end of the ${input.feed} feed (${total} item${total === 1 ? '' : 's'}). Reset offset below ${total}.`);
174
193
  }
175
194
  else {
176
- ctx.enrich.notice(deadPageMessage);
195
+ ctx.enrich.notice(failureMessage ?? deadPageMessage);
177
196
  }
178
197
  }
198
+ else if (failureMessage) {
199
+ ctx.enrich.notice(failureMessage);
200
+ }
179
201
  return {
180
202
  stories,
181
203
  feed: input.feed,
@@ -1 +1 @@
1
- {"version":3,"file":"get-stories.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/get-stories.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EACL,aAAa,EACb,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,SAAS,GACV,MAAM,6BAA6B,CAAC;AAErC,kEAAkE;AAClE,MAAM,SAAS,GAAG,GAA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* @fileoverview Fetch an HN item and its comment tree via ranked BFS traversal.
2
+ * @fileoverview Fetch an HN item and its comment tree via ranked BFS traversal,
3
+ * resumable through a cursor that carries the unvisited frontier.
3
4
  * @module mcp-server/tools/definitions/get-thread.tool
4
5
  */
5
6
  import { z } from '@cyanheads/mcp-ts-core';
@@ -8,6 +9,7 @@ export declare const getThread: import("@cyanheads/mcp-ts-core").ToolDefinition<
8
9
  itemId: z.ZodNumber;
9
10
  depth: z.ZodDefault<z.ZodNumber>;
10
11
  maxComments: z.ZodDefault<z.ZodNumber>;
12
+ cursor: z.ZodOptional<z.ZodString>;
11
13
  }, z.core.$strip>, z.ZodObject<{
12
14
  item: z.ZodObject<{
13
15
  id: z.ZodNumber;
@@ -19,6 +21,18 @@ export declare const getThread: import("@cyanheads/mcp-ts-core").ToolDefinition<
19
21
  text: z.ZodOptional<z.ZodString>;
20
22
  score: z.ZodOptional<z.ZodNumber>;
21
23
  descendants: z.ZodOptional<z.ZodNumber>;
24
+ parent: z.ZodOptional<z.ZodNumber>;
25
+ poll: z.ZodOptional<z.ZodNumber>;
26
+ parts: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
27
+ deleted: z.ZodOptional<z.ZodLiteral<true>>;
28
+ dead: z.ZodOptional<z.ZodLiteral<true>>;
29
+ options: z.ZodOptional<z.ZodArray<z.ZodObject<{
30
+ id: z.ZodNumber;
31
+ text: z.ZodOptional<z.ZodString>;
32
+ score: z.ZodOptional<z.ZodNumber>;
33
+ deleted: z.ZodOptional<z.ZodLiteral<true>>;
34
+ dead: z.ZodOptional<z.ZodLiteral<true>>;
35
+ }, z.core.$strip>>>;
22
36
  }, z.core.$strip>;
23
37
  comments: z.ZodArray<z.ZodObject<{
24
38
  id: z.ZodNumber;
@@ -36,6 +50,12 @@ export declare const getThread: import("@cyanheads/mcp-ts-core").ToolDefinition<
36
50
  readonly when: "HN reports no item exists for the given itemId.";
37
51
  readonly recovery: "Verify the itemId via hn_search_content or a feed listing from hn_get_stories.";
38
52
  readonly severity: "notice";
53
+ }, {
54
+ readonly reason: "invalid_cursor";
55
+ readonly code: JsonRpcErrorCode.InvalidParams;
56
+ readonly when: "The cursor was issued for a different itemId than the one passed with it.";
57
+ readonly recovery: "Pass the cursor with the same itemId it was returned for, or omit cursor to start this item from the top.";
58
+ readonly severity: "notice";
39
59
  }, {
40
60
  readonly reason: "upstream_rejected";
41
61
  readonly code: JsonRpcErrorCode.InvalidParams;
@@ -46,7 +66,7 @@ export declare const getThread: import("@cyanheads/mcp-ts-core").ToolDefinition<
46
66
  readonly reason: "upstream_rate_limited";
47
67
  readonly code: JsonRpcErrorCode.RateLimited;
48
68
  readonly when: "The HN API answered with HTTP 429.";
49
- readonly recovery: "Wait several seconds before retrying, and call this tool less often.";
69
+ readonly recovery: "Wait the interval in retryAfter when the error carries one, otherwise several seconds, then retry and call this tool less often.";
50
70
  readonly retryable: true;
51
71
  readonly thrownBy: "service";
52
72
  }, {
@@ -74,8 +94,16 @@ export declare const getThread: import("@cyanheads/mcp-ts-core").ToolDefinition<
74
94
  readonly totalLoaded: z.ZodNumber;
75
95
  readonly totalAvailable: z.ZodOptional<z.ZodNumber>;
76
96
  readonly truncated: z.ZodOptional<z.ZodBoolean>;
97
+ readonly truncationReason: z.ZodOptional<z.ZodEnum<{
98
+ count: "count";
99
+ depth: "depth";
100
+ rate_limited: "rate_limited";
101
+ size: "size";
102
+ }>>;
103
+ readonly nextCursor: z.ZodOptional<z.ZodString>;
77
104
  readonly shown: z.ZodOptional<z.ZodNumber>;
78
105
  readonly cap: z.ZodOptional<z.ZodNumber>;
106
+ readonly failedIds: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
79
107
  readonly notice: z.ZodOptional<z.ZodString>;
80
108
  }>;
81
109
  //# sourceMappingURL=get-thread.tool.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-thread.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/get-thread.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAMjE,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4UpB,CAAC"}
1
+ {"version":3,"file":"get-thread.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/get-thread.tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAsB,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAiB,gBAAgB,EAAiB,MAAM,+BAA+B,CAAC;AAkc/F,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqUpB,CAAC"}