@cyanheads/hn-mcp-server 0.6.0 → 0.7.0
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 +6 -6
- package/CLAUDE.md +6 -6
- package/README.md +24 -22
- package/changelog/0.6.x/0.6.1.md +34 -0
- package/changelog/0.7.x/0.7.0.md +32 -0
- package/changelog/template.md +10 -3
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp-server/tools/definitions/get-stories.tool.d.ts +15 -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 +47 -24
- package/dist/mcp-server/tools/definitions/get-stories.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/get-thread.tool.d.ts +10 -1
- package/dist/mcp-server/tools/definitions/get-thread.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/get-thread.tool.js +235 -277
- package/dist/mcp-server/tools/definitions/get-thread.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/get-user.tool.d.ts +14 -1
- package/dist/mcp-server/tools/definitions/get-user.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/get-user.tool.js +43 -72
- package/dist/mcp-server/tools/definitions/get-user.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/search-content.tool.d.ts +15 -17
- package/dist/mcp-server/tools/definitions/search-content.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/search-content.tool.js +124 -163
- package/dist/mcp-server/tools/definitions/search-content.tool.js.map +1 -1
- package/dist/mcp-server/tools/username-input.d.ts +23 -0
- package/dist/mcp-server/tools/username-input.d.ts.map +1 -0
- package/dist/mcp-server/tools/username-input.js +30 -0
- package/dist/mcp-server/tools/username-input.js.map +1 -0
- package/dist/services/hn/hn-service.d.ts +57 -8
- package/dist/services/hn/hn-service.d.ts.map +1 -1
- package/dist/services/hn/hn-service.js +128 -16
- 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 +8 -8
- package/server.json +3 -3
- package/skills/hn-guide/SKILL.md +8 -8
- package/dist/mcp-server/tools/response-budget.d.ts +0 -111
- package/dist/mcp-server/tools/response-budget.d.ts.map +0 -1
- package/dist/mcp-server/tools/response-budget.js +0 -204
- package/dist/mcp-server/tools/response-budget.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cyanheads/hn-mcp-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Browse Hacker News feeds, threads, and user profiles with full-text search via MCP. STDIO or Streamable HTTP.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
}
|
|
80
80
|
],
|
|
81
81
|
"engines": {
|
|
82
|
-
"bun": ">=1.4.
|
|
82
|
+
"bun": ">=1.4.4",
|
|
83
83
|
"node": ">=24.0.0"
|
|
84
84
|
},
|
|
85
85
|
"packageManager": "bun@1.4.4",
|
|
@@ -87,19 +87,19 @@
|
|
|
87
87
|
"access": "public"
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
|
-
"@cyanheads/mcp-ts-core": "^0.13.
|
|
90
|
+
"@cyanheads/mcp-ts-core": "^0.13.22",
|
|
91
91
|
"pino-pretty": "^13.2.0",
|
|
92
92
|
"zod": "^4.6.7"
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|
|
95
|
-
"@biomejs/biome": "^2.6.
|
|
95
|
+
"@biomejs/biome": "^2.6.7",
|
|
96
96
|
"@socketsecurity/bun-security-scanner": "^1.1.3",
|
|
97
|
-
"@types/node": "^26.6.
|
|
98
|
-
"@vitest/coverage-istanbul": "^5.0
|
|
97
|
+
"@types/node": "^26.6.6",
|
|
98
|
+
"@vitest/coverage-istanbul": "^5.1.0",
|
|
99
99
|
"depcheck": "^1.4.7",
|
|
100
100
|
"ignore": "^7.0.14",
|
|
101
|
-
"tsc-alias": "^1.9.
|
|
101
|
+
"tsc-alias": "^1.9.10",
|
|
102
102
|
"typescript": "^7.0.2",
|
|
103
|
-
"vitest": "^5.0
|
|
103
|
+
"vitest": "^5.1.0"
|
|
104
104
|
}
|
|
105
105
|
}
|
package/server.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"url": "https://github.com/cyanheads/hn-mcp-server",
|
|
7
7
|
"source": "github"
|
|
8
8
|
},
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.7.0",
|
|
10
10
|
"remotes": [
|
|
11
11
|
{
|
|
12
12
|
"type": "streamable-http",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"registryBaseUrl": "https://registry.npmjs.org",
|
|
20
20
|
"identifier": "@cyanheads/hn-mcp-server",
|
|
21
21
|
"runtimeHint": "npx",
|
|
22
|
-
"version": "0.
|
|
22
|
+
"version": "0.7.0",
|
|
23
23
|
"environmentVariables": [
|
|
24
24
|
{
|
|
25
25
|
"name": "HN_CONCURRENCY_LIMIT",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"registryBaseUrl": "https://registry.npmjs.org",
|
|
46
46
|
"identifier": "@cyanheads/hn-mcp-server",
|
|
47
47
|
"runtimeHint": "npx",
|
|
48
|
-
"version": "0.
|
|
48
|
+
"version": "0.7.0",
|
|
49
49
|
"environmentVariables": [
|
|
50
50
|
{
|
|
51
51
|
"name": "MCP_TRANSPORT_TYPE",
|
package/skills/hn-guide/SKILL.md
CHANGED
|
@@ -4,7 +4,7 @@ description: Find the Hacker News thread behind a link, search topics without Al
|
|
|
4
4
|
license: Apache-2.0
|
|
5
5
|
metadata:
|
|
6
6
|
author: cyanheads
|
|
7
|
-
version: "1.
|
|
7
|
+
version: "1.2"
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
## Scope
|
|
@@ -17,21 +17,21 @@ Hacker News, read-only and keyless: live feeds, items, and profiles from HN's Fi
|
|
|
17
17
|
|:--|:--|
|
|
18
18
|
| A story's whole discussion | a feed story's or story hit's `id`; a comment hit's `storyId`; a comment root's `item.storyId` from `hn_get_thread` |
|
|
19
19
|
| One comment and its replies | the comment's `id`, from a search hit, a thread page, or a user's submissions |
|
|
20
|
-
| What a comment replied to | `parent` on a `hn_get_thread` comment root or a `hn_get_user` submission; search
|
|
20
|
+
| What a comment replied to | `parent` on a `hn_get_thread` comment root or a `hn_get_user` submission; `parentId` on a comment search hit (its story's id for a top-level comment, otherwise the parent comment's id), and `storyUrl` when that story links out |
|
|
21
21
|
| A user | a `by` or `author` field, copied exactly |
|
|
22
22
|
|
|
23
|
-
Usernames match case-sensitively on every tool: `Animats` exists, while `animats` answers `user_not_found` and empties an author-filtered search. When the name came from the user rather than a field, confirm it with `hn_get_user
|
|
23
|
+
Usernames match case-sensitively on every tool: `Animats` exists, while `animats` answers `user_not_found` and empties an author-filtered search. When the name came from the user rather than a field, confirm it with `hn_get_user` (a leading `@` is dropped, a name with spaces is rejected as a display name); on `user_not_found`, keyword-search the name (text search ignores case) and read the `author` of the hits that differ from it only in case.
|
|
24
24
|
|
|
25
25
|
## Gates
|
|
26
26
|
|
|
27
27
|
- **Find a link's thread with a story search.** A URL query searches comment text too, and comments that paste the link crowd out the submission: for `https://paulgraham.com/greatwork.html` the first six hits were all comments. Search it with the story type. One URL is often submitted many times, each a separate thread: that essay has about 11 story submissions, from 1,008 points and 432 comments down to reposts with a handful of points. Take the one with the most comments, or read several when the question is about reception over time.
|
|
28
|
-
- **Quote a term to match it exactly.** Algolia's keyword matching is typo-tolerant and matches the last term as a prefix: `kubernetse` returns Kubernetes stories, and `zig` matches "Zigbee". Wrap a term in double quotes to match only that word, and put `-` before a word to exclude it. October 2026 stories for `zig` number "about
|
|
28
|
+
- **Quote a term to match it exactly.** Algolia's keyword matching is typo-tolerant and matches the last term as a prefix: `kubernetse` returns Kubernetes stories, and `zig` matches "Zigbee". Wrap a term in double quotes to match only that word, and put `-` before a word to exclude it. October 2026 stories for `zig` number "about 595"; for `"zig"`, exactly 31, and `"zig" -devlog` 30. The `<em>` span in `highlights.title` and `highlights.text` shows what actually matched; `highlights.text` is absent under the compact view and on any body Algolia left unhighlighted, which does not mean the body lacks the term. Read `highlights.title` and `matchedWords` where present; on a hit Algolia left unhighlighted `matchedWords` is absent too, so read the body `text` (`view: "full"`).
|
|
29
29
|
- **An estimate is not a count.** Report `totalHits` as a number only when `totalHitsExact` is true, and as "about N" otherwise. An unquoted estimate also counts the fuzzy matches: `rust` by one author is "about 1,633" with off-topic comments among the newest hits, `"rust"` an exact 906.
|
|
30
|
-
- **Relevance is not popularity.** With a query, title matches outrank body-only matches whatever their score: a 57-point story that mentions `"zig"` only in its text ranked below 1-point title matches. For the biggest stories on a topic, set a
|
|
31
|
-
- **One thread page is not the thread.** `hn_get_thread` walks breadth-first, so on a large story the default page holds only top-level comments:
|
|
30
|
+
- **Relevance is not popularity.** With a query, title matches outrank body-only matches whatever their score: a 57-point story that mentions `"zig"` only in its text ranked below 1-point title matches. For the biggest stories on a topic, set a `minPoints` floor; for the most discussed, a `minComments` floor. Both filter rather than sort, so order the survivors by `points` or `numComments` yourself, and both drop comments and jobs (`minComments` drops poll options too, which carry votes but no comment count) and are rejected with `tags: "comment"` or `"job"`.
|
|
31
|
+
- **One thread page is not the thread.** `hn_get_thread` walks breadth-first, so on a large story the default page holds only top-level comments: 25 of 544, every one at depth 0, no replies. Before summarizing a discussion, either follow `nextCursor` until it is absent, or drill into the first top-level comments: each comment's id as `itemId`, with a deeper depth, returns its subtree (one top-level comment returned 23 live replies over four levels in a single call). A story's thread is complete when the comments loaded across pages reach `totalAvailable`. A comment root reports no `totalAvailable`; its subtree is complete when `truncated` is absent.
|
|
32
32
|
- **Comments have no scores.** HN exposes no comment votes: thread comments carry no `score` and comment hits no `points`. "Top comments" are the first top-level comments `hn_get_thread` returns, in HN's ranking order. Never call one the most upvoted.
|
|
33
|
-
- **Feed order is HN's rank, not score.** `hn_get_stories` returns a feed in ranking order: on the top feed a 66-point story sat fifth, above a 1,137-point one. The `front_page` search tag returns the same 30 stories sorted by points instead. "Most discussed" is the highest `descendants` (feeds, threads) or `numComments` (search), and it often disagrees with score: 534 comments on a 387-point story, 364 on the 1,137-point one.
|
|
34
|
-
- **Hiring threads are not the jobs feed.** The `jobs` feed and the `job` type hold YC company job ads, scored 1 with no comments. The monthly "Ask HN: Who is hiring?" and "Ask HN: Who wants to be hired?" threads are stories posted on the
|
|
33
|
+
- **Feed order is HN's rank, not score.** `hn_get_stories` returns a feed in ranking order: on the top feed a 66-point story sat fifth, above a 1,137-point one. The `front_page` search tag returns the same 30 stories sorted by points instead. "Most discussed" is the highest `descendants` (feeds, threads) or `numComments` (search), and it often disagrees with score: 534 comments on a 387-point story, 364 on the 1,137-point one. In a search window, `minComments` with the story type drops the lightly discussed stories before you rank; it does not sort.
|
|
34
|
+
- **Hiring threads are not the jobs feed.** The `jobs` feed and the `job` type hold YC company job ads, scored 1 with no comments. The monthly "Ask HN: Who is hiring?" and "Ask HN: Who wants to be hired?" threads are stories posted by the user `whoishiring` on the month's first weekday, except January, when they went up on the 2nd in both 2025 and 2026 (in 14 of the 25 months from November 2024 to November 2026, that was the 1st), and each posting is a top-level comment. Find the month's thread with an author search for `whoishiring` and a `dateRange` from the last day of the previous month to the 5th, never the 1st alone, with the title in `query` to tell the two threads apart; list its postings with `hn_get_thread` at depth 1, or search them with a comment search scoped to its `storyId` (`remote rust`).
|
|
35
35
|
- **A user's submissions are everything they posted.** `hn_get_user` returns every item type, newest first, with no topic filter, so an active user's page is mostly comments. For what a user said about a topic, search with the author filter and a quoted term, sorted by date for their recent views; each comment hit's `storyTitle` names the thread it was posted in.
|
|
36
36
|
|
|
37
37
|
## Workflows
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview The fixed byte budget a page-returning tool holds each response
|
|
3
|
-
* surface to, and the arithmetic that keeps a page within it: measure both
|
|
4
|
-
* surfaces as the caller receives them — whole, or as a page plus the
|
|
5
|
-
* enrichment the framework adds — then either cut the longest bodies to the
|
|
6
|
-
* largest byte limit they can share, on a code-point boundary, or serve the
|
|
7
|
-
* longest prefix of the page that fits. The tool decides what is cuttable or
|
|
8
|
-
* droppable and how the cut is disclosed.
|
|
9
|
-
* @module mcp-server/tools/response-budget
|
|
10
|
-
*/
|
|
11
|
-
/** Bytes each surface may carry: all `content[]` text, the enrichment trailer included, and the `structuredContent` JSON. */
|
|
12
|
-
export declare const RESPONSE_BUDGET_BYTES = 64000;
|
|
13
|
-
/** {@link RESPONSE_BUDGET_BYTES} as the descriptions and notices write it. */
|
|
14
|
-
export declare const RESPONSE_BUDGET_TEXT: string;
|
|
15
|
-
/** The line `content[]` puts after a body cut to the budget, outside its quote. */
|
|
16
|
-
export declare const cutPointer: (id: number) => string;
|
|
17
|
-
/** UTF-8 length of `text`. */
|
|
18
|
-
export declare function byteLength(text: string): number;
|
|
19
|
-
/**
|
|
20
|
-
* The longest prefix of `text` within `maxBytes` UTF-8 bytes. It ends on a
|
|
21
|
-
* code-point boundary: a character that would straddle the limit, a surrogate
|
|
22
|
-
* pair included, is left out whole.
|
|
23
|
-
*/
|
|
24
|
-
export declare function cutToBytes(text: string, maxBytes: number): string;
|
|
25
|
-
/** A response as the handler is about to return it. */
|
|
26
|
-
export interface ResponseDraft {
|
|
27
|
-
/** The blocks the definition's `format()` renders for `result`. */
|
|
28
|
-
content: readonly {
|
|
29
|
-
type: string;
|
|
30
|
-
text?: string;
|
|
31
|
-
}[];
|
|
32
|
-
/** Every enrichment field the call writes, `notice` included, as the framework will hold them. */
|
|
33
|
-
enrichment: Readonly<Record<string, unknown>>;
|
|
34
|
-
/** The handler's return value. */
|
|
35
|
-
result: Readonly<Record<string, unknown>>;
|
|
36
|
-
/** The definition's `enrichmentTrailer`. */
|
|
37
|
-
trailer?: Readonly<Record<string, {
|
|
38
|
-
label?: string;
|
|
39
|
-
render?: (value: never) => string;
|
|
40
|
-
} | undefined>> | undefined;
|
|
41
|
-
}
|
|
42
|
-
/** A response's size on each surface. */
|
|
43
|
-
export interface ResponseBytes {
|
|
44
|
-
contentBytes: number;
|
|
45
|
-
structuredBytes: number;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* The bytes the framework adds to each surface for `enrichment`: its
|
|
49
|
-
* `content[]` trailer, and the `"key":value` members it merges into the
|
|
50
|
-
* `structuredContent` object, each with the comma before it. Exact for a
|
|
51
|
-
* result that serializes with at least one member and shares no key with the
|
|
52
|
-
* enrichment. A tool that sizes its page as it builds it adds this to the
|
|
53
|
-
* page's own bytes; {@link measureResponse} does the same for a whole draft.
|
|
54
|
-
*
|
|
55
|
-
* @throws TypeError for a string or object field with no `render`, as
|
|
56
|
-
* {@link measureResponse} does.
|
|
57
|
-
*/
|
|
58
|
-
export declare function enrichmentBytes(enrichment: ResponseDraft['enrichment'], trailer?: ResponseDraft['trailer']): ResponseBytes;
|
|
59
|
-
/**
|
|
60
|
-
* Size a response on both surfaces as the caller receives it: every `content[]`
|
|
61
|
-
* text block plus the enrichment trailer the framework appends, and the
|
|
62
|
-
* `structuredContent` JSON — the handler's return merged with its enrichment,
|
|
63
|
-
* which shares none of the return's keys.
|
|
64
|
-
*/
|
|
65
|
-
export declare function measureResponse(draft: ResponseDraft): ResponseBytes;
|
|
66
|
-
/** True when both surfaces are within {@link RESPONSE_BUDGET_BYTES}. */
|
|
67
|
-
export declare function fitsBudget(bytes: ResponseBytes): boolean;
|
|
68
|
-
/**
|
|
69
|
-
* The largest byte limit at which the page fits the budget when every body
|
|
70
|
-
* longer than the limit is cut to it and every other body stays whole.
|
|
71
|
-
*
|
|
72
|
-
* Every body reaches each surface at least once, whole or cut, so a page cut
|
|
73
|
-
* at a limit carries at least the bodies' bytes at that limit on each surface.
|
|
74
|
-
* No limit whose body bytes alone exceed the budget can fit, and none is
|
|
75
|
-
* measured: every page `measure` renders is within the budget in body bytes,
|
|
76
|
-
* however long the bodies are.
|
|
77
|
-
*
|
|
78
|
-
* A page's size is not monotone in the limit: raising it to a body's length
|
|
79
|
-
* returns that body whole, which drops its cut disclosure, so a page can fit at
|
|
80
|
-
* a body's length and not one byte below. The limits are therefore searched as
|
|
81
|
-
* cut sets — the longest body alone, then the two longest — each tried at its
|
|
82
|
-
* lowest limit, where it cuts its bodies furthest. The answer is the first set
|
|
83
|
-
* that fits there, bisected within, where the size does grow with the limit.
|
|
84
|
-
* The first set the body bytes allow is measured, then the last; between them
|
|
85
|
-
* the sets are bisected, on the assumption that once one set fits every larger
|
|
86
|
-
* one does — where an earlier set also fits, a smaller limit is served. That is
|
|
87
|
-
* at most two measurements plus a bisection over the sets and one within.
|
|
88
|
-
*
|
|
89
|
-
* @param bodyBytes UTF-8 length of each cuttable body; 0 for an item without
|
|
90
|
-
* one. Each body must reach both surfaces, at least once, cut or whole.
|
|
91
|
-
* @param measure Both surfaces with every body longer than `limitBytes` cut to
|
|
92
|
-
* it. With the same bodies cut, a larger limit must never measure smaller.
|
|
93
|
-
* @returns 0 when even cutting every body to nothing leaves the page over
|
|
94
|
-
* budget — the smallest page cutting can make.
|
|
95
|
-
*/
|
|
96
|
-
export declare function largestFittingLimit(bodyBytes: readonly number[], measure: (limitBytes: number) => ResponseBytes): number;
|
|
97
|
-
/**
|
|
98
|
-
* Which of a page's `count` prefixes to serve: the longest that fits the
|
|
99
|
-
* budget, or the first — the shortest the caller allows, served even over
|
|
100
|
-
* budget — when none does.
|
|
101
|
-
*
|
|
102
|
-
* Prefixes are measured from the longest down, each at most once and the first
|
|
103
|
-
* never. A prefix's overflow says nothing about a shorter one: what a response
|
|
104
|
-
* adds beyond its page, such as a cursor of the entries still unread, can shrink
|
|
105
|
-
* as the page shortens as well as grow.
|
|
106
|
-
*
|
|
107
|
-
* @param measure The whole response serving prefix `index`.
|
|
108
|
-
* @returns The index of the prefix to serve.
|
|
109
|
-
*/
|
|
110
|
-
export declare function longestFittingPrefix(count: number, measure: (index: number) => ResponseBytes): number;
|
|
111
|
-
//# sourceMappingURL=response-budget.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"response-budget.d.ts","sourceRoot":"","sources":["../../../src/mcp-server/tools/response-budget.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,6HAA6H;AAC7H,eAAO,MAAM,qBAAqB,QAAS,CAAC;AAE5C,8EAA8E;AAC9E,eAAO,MAAM,oBAAoB,QAAgD,CAAC;AAElF,mFAAmF;AACnF,eAAO,MAAM,UAAU,OAAQ,MAAM,WAC4D,CAAC;AAIlG,8BAA8B;AAC9B,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAIjE;AAED,uDAAuD;AACvD,MAAM,WAAW,aAAa;IAC5B,mEAAmE;IACnE,OAAO,EAAE,SAAS;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACpD,kGAAkG;IAClG,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC9C,kCAAkC;IAClC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC1C,4CAA4C;IAC5C,OAAO,CAAC,EACJ,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC,CAAC,GAC3F,SAAS,CAAC;CACf;AAED,yCAAyC;AACzC,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;CACzB;AAqCD;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,aAAa,CAAC,YAAY,CAAC,EACvC,OAAO,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,GACjC,aAAa,CASf;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa,CAUnE;AAED,wEAAwE;AACxE,wBAAgB,UAAU,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAIxD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,SAAS,MAAM,EAAE,EAC5B,OAAO,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,aAAa,GAC7C,MAAM,CAyCR;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,aAAa,GACxC,MAAM,CAKR"}
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview The fixed byte budget a page-returning tool holds each response
|
|
3
|
-
* surface to, and the arithmetic that keeps a page within it: measure both
|
|
4
|
-
* surfaces as the caller receives them — whole, or as a page plus the
|
|
5
|
-
* enrichment the framework adds — then either cut the longest bodies to the
|
|
6
|
-
* largest byte limit they can share, on a code-point boundary, or serve the
|
|
7
|
-
* longest prefix of the page that fits. The tool decides what is cuttable or
|
|
8
|
-
* droppable and how the cut is disclosed.
|
|
9
|
-
* @module mcp-server/tools/response-budget
|
|
10
|
-
*/
|
|
11
|
-
/** Bytes each surface may carry: all `content[]` text, the enrichment trailer included, and the `structuredContent` JSON. */
|
|
12
|
-
export const RESPONSE_BUDGET_BYTES = 64_000;
|
|
13
|
-
/** {@link RESPONSE_BUDGET_BYTES} as the descriptions and notices write it. */
|
|
14
|
-
export const RESPONSE_BUDGET_TEXT = RESPONSE_BUDGET_BYTES.toLocaleString('en-US');
|
|
15
|
-
/** The line `content[]` puts after a body cut to the budget, outside its quote. */
|
|
16
|
-
export const cutPointer = (id) => `Text cut short to fit the response budget — hn_get_thread with itemId ${id} returns it whole.`;
|
|
17
|
-
const utf8 = new TextEncoder();
|
|
18
|
-
/** UTF-8 length of `text`. */
|
|
19
|
-
export function byteLength(text) {
|
|
20
|
-
return utf8.encode(text).byteLength;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* The longest prefix of `text` within `maxBytes` UTF-8 bytes. It ends on a
|
|
24
|
-
* code-point boundary: a character that would straddle the limit, a surrogate
|
|
25
|
-
* pair included, is left out whole.
|
|
26
|
-
*/
|
|
27
|
-
export function cutToBytes(text, maxBytes) {
|
|
28
|
-
/** `encodeInto` stops before the first code point that does not fit; `read` counts the UTF-16 units it consumed. */
|
|
29
|
-
const { read } = utf8.encodeInto(text, new Uint8Array(maxBytes));
|
|
30
|
-
return text.slice(0, read);
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* The bytes the framework's `content[]` trailer takes for `enrichment`, at
|
|
34
|
-
* most one byte per field over. The trailer is rendered after `format()`, out
|
|
35
|
-
* of the handler's sight, so each field is sized as the framework renders it —
|
|
36
|
-
* the definition's `render`, the `notice` as a block quote, any other value as
|
|
37
|
-
* `**key:** value` — plus two bytes: the trailer opens with a blank line and
|
|
38
|
-
* joins its fields with one line break, or two after a block quote.
|
|
39
|
-
*
|
|
40
|
-
* @throws TypeError for a string or object field with no `render`, which the
|
|
41
|
-
* framework renders as a code literal this does not size.
|
|
42
|
-
*/
|
|
43
|
-
function trailerBytes(enrichment, trailer) {
|
|
44
|
-
let bytes = 0;
|
|
45
|
-
for (const [key, value] of Object.entries(enrichment)) {
|
|
46
|
-
const field = trailer?.[key];
|
|
47
|
-
let line;
|
|
48
|
-
if (field?.render) {
|
|
49
|
-
line = field.render(value);
|
|
50
|
-
}
|
|
51
|
-
else if (key === 'notice') {
|
|
52
|
-
line = String(value)
|
|
53
|
-
.split(/\r\n|\r|\n/)
|
|
54
|
-
.map((part) => (part === '' ? '>' : `> ${part}`))
|
|
55
|
-
.join('\n');
|
|
56
|
-
}
|
|
57
|
-
else if (value == null || typeof value === 'number' || typeof value === 'boolean') {
|
|
58
|
-
line = `**${field?.label ?? key}:** ${String(value)}`;
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
throw new TypeError(`Cannot size enrichment field "${key}" (${typeof value}) for the response budget: give it an enrichmentTrailer render.`);
|
|
62
|
-
}
|
|
63
|
-
bytes += 2 + byteLength(line);
|
|
64
|
-
}
|
|
65
|
-
return bytes;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* The bytes the framework adds to each surface for `enrichment`: its
|
|
69
|
-
* `content[]` trailer, and the `"key":value` members it merges into the
|
|
70
|
-
* `structuredContent` object, each with the comma before it. Exact for a
|
|
71
|
-
* result that serializes with at least one member and shares no key with the
|
|
72
|
-
* enrichment. A tool that sizes its page as it builds it adds this to the
|
|
73
|
-
* page's own bytes; {@link measureResponse} does the same for a whole draft.
|
|
74
|
-
*
|
|
75
|
-
* @throws TypeError for a string or object field with no `render`, as
|
|
76
|
-
* {@link measureResponse} does.
|
|
77
|
-
*/
|
|
78
|
-
export function enrichmentBytes(enrichment, trailer) {
|
|
79
|
-
let structuredBytes = 0;
|
|
80
|
-
for (const [key, value] of Object.entries(enrichment)) {
|
|
81
|
-
/** `undefined` is what JSON.stringify returns for a value it leaves out of an object. */
|
|
82
|
-
const json = JSON.stringify(value);
|
|
83
|
-
if (json !== undefined)
|
|
84
|
-
structuredBytes += 2 + byteLength(JSON.stringify(key)) + byteLength(json);
|
|
85
|
-
}
|
|
86
|
-
return { contentBytes: trailerBytes(enrichment, trailer), structuredBytes };
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Size a response on both surfaces as the caller receives it: every `content[]`
|
|
90
|
-
* text block plus the enrichment trailer the framework appends, and the
|
|
91
|
-
* `structuredContent` JSON — the handler's return merged with its enrichment,
|
|
92
|
-
* which shares none of the return's keys.
|
|
93
|
-
*/
|
|
94
|
-
export function measureResponse(draft) {
|
|
95
|
-
const added = enrichmentBytes(draft.enrichment, draft.trailer);
|
|
96
|
-
let contentBytes = added.contentBytes;
|
|
97
|
-
for (const block of draft.content) {
|
|
98
|
-
if (block.type === 'text' && block.text != null)
|
|
99
|
-
contentBytes += byteLength(block.text);
|
|
100
|
-
}
|
|
101
|
-
const result = JSON.stringify(draft.result);
|
|
102
|
-
/** Merged into an object with no members, the first field takes no comma. */
|
|
103
|
-
const noComma = result === '{}' && added.structuredBytes > 0 ? 1 : 0;
|
|
104
|
-
return { contentBytes, structuredBytes: byteLength(result) + added.structuredBytes - noComma };
|
|
105
|
-
}
|
|
106
|
-
/** True when both surfaces are within {@link RESPONSE_BUDGET_BYTES}. */
|
|
107
|
-
export function fitsBudget(bytes) {
|
|
108
|
-
return (bytes.contentBytes <= RESPONSE_BUDGET_BYTES && bytes.structuredBytes <= RESPONSE_BUDGET_BYTES);
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* The largest byte limit at which the page fits the budget when every body
|
|
112
|
-
* longer than the limit is cut to it and every other body stays whole.
|
|
113
|
-
*
|
|
114
|
-
* Every body reaches each surface at least once, whole or cut, so a page cut
|
|
115
|
-
* at a limit carries at least the bodies' bytes at that limit on each surface.
|
|
116
|
-
* No limit whose body bytes alone exceed the budget can fit, and none is
|
|
117
|
-
* measured: every page `measure` renders is within the budget in body bytes,
|
|
118
|
-
* however long the bodies are.
|
|
119
|
-
*
|
|
120
|
-
* A page's size is not monotone in the limit: raising it to a body's length
|
|
121
|
-
* returns that body whole, which drops its cut disclosure, so a page can fit at
|
|
122
|
-
* a body's length and not one byte below. The limits are therefore searched as
|
|
123
|
-
* cut sets — the longest body alone, then the two longest — each tried at its
|
|
124
|
-
* lowest limit, where it cuts its bodies furthest. The answer is the first set
|
|
125
|
-
* that fits there, bisected within, where the size does grow with the limit.
|
|
126
|
-
* The first set the body bytes allow is measured, then the last; between them
|
|
127
|
-
* the sets are bisected, on the assumption that once one set fits every larger
|
|
128
|
-
* one does — where an earlier set also fits, a smaller limit is served. That is
|
|
129
|
-
* at most two measurements plus a bisection over the sets and one within.
|
|
130
|
-
*
|
|
131
|
-
* @param bodyBytes UTF-8 length of each cuttable body; 0 for an item without
|
|
132
|
-
* one. Each body must reach both surfaces, at least once, cut or whole.
|
|
133
|
-
* @param measure Both surfaces with every body longer than `limitBytes` cut to
|
|
134
|
-
* it. With the same bodies cut, a larger limit must never measure smaller.
|
|
135
|
-
* @returns 0 when even cutting every body to nothing leaves the page over
|
|
136
|
-
* budget — the smallest page cutting can make.
|
|
137
|
-
*/
|
|
138
|
-
export function largestFittingLimit(bodyBytes, measure) {
|
|
139
|
-
const lengths = [...new Set(bodyBytes)].filter((n) => n > 0).sort((a, b) => b - a);
|
|
140
|
-
const longest = lengths[0];
|
|
141
|
-
if (longest === undefined)
|
|
142
|
-
return 0;
|
|
143
|
-
/** The body bytes a page cut at `limit` carries on each surface, at least. */
|
|
144
|
-
const bodiesAt = (limit) => bodyBytes.reduce((sum, bytes) => sum + Math.min(bytes, limit), 0);
|
|
145
|
-
/** The highest limit whose body bytes fit; nothing above it can. */
|
|
146
|
-
let ceiling = 0;
|
|
147
|
-
for (let high = longest; ceiling < high;) {
|
|
148
|
-
const mid = Math.ceil((ceiling + high) / 2);
|
|
149
|
-
if (bodiesAt(mid) <= RESPONSE_BUDGET_BYTES)
|
|
150
|
-
ceiling = mid;
|
|
151
|
-
else
|
|
152
|
-
high = mid - 1;
|
|
153
|
-
}
|
|
154
|
-
/** Cut set `i` takes limits from its lowest, `lowestOf(i)`, up to one below its own length. */
|
|
155
|
-
const lowestOf = (i) => lengths[i + 1] ?? 0;
|
|
156
|
-
const fitsAtLowest = (i) => fitsBudget(measure(lowestOf(i)));
|
|
157
|
-
const last = lengths.length - 1;
|
|
158
|
-
let set = lengths.findIndex((_, i) => lowestOf(i) <= ceiling);
|
|
159
|
-
if (!fitsAtLowest(set)) {
|
|
160
|
-
if (set === last || !fitsAtLowest(last))
|
|
161
|
-
return 0;
|
|
162
|
-
/** `set` overflows at its lowest limit and `fitting` fits at its own. */
|
|
163
|
-
let fitting = last;
|
|
164
|
-
while (fitting - set > 1) {
|
|
165
|
-
const mid = Math.floor((set + fitting) / 2);
|
|
166
|
-
if (fitsAtLowest(mid))
|
|
167
|
-
fitting = mid;
|
|
168
|
-
else
|
|
169
|
-
set = mid;
|
|
170
|
-
}
|
|
171
|
-
set = fitting;
|
|
172
|
-
}
|
|
173
|
-
let lowest = lowestOf(set);
|
|
174
|
-
let highest = Math.min(lengths[set] - 1, ceiling);
|
|
175
|
-
while (lowest < highest) {
|
|
176
|
-
const mid = Math.ceil((lowest + highest) / 2);
|
|
177
|
-
if (fitsBudget(measure(mid)))
|
|
178
|
-
lowest = mid;
|
|
179
|
-
else
|
|
180
|
-
highest = mid - 1;
|
|
181
|
-
}
|
|
182
|
-
return lowest;
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Which of a page's `count` prefixes to serve: the longest that fits the
|
|
186
|
-
* budget, or the first — the shortest the caller allows, served even over
|
|
187
|
-
* budget — when none does.
|
|
188
|
-
*
|
|
189
|
-
* Prefixes are measured from the longest down, each at most once and the first
|
|
190
|
-
* never. A prefix's overflow says nothing about a shorter one: what a response
|
|
191
|
-
* adds beyond its page, such as a cursor of the entries still unread, can shrink
|
|
192
|
-
* as the page shortens as well as grow.
|
|
193
|
-
*
|
|
194
|
-
* @param measure The whole response serving prefix `index`.
|
|
195
|
-
* @returns The index of the prefix to serve.
|
|
196
|
-
*/
|
|
197
|
-
export function longestFittingPrefix(count, measure) {
|
|
198
|
-
for (let index = count - 1; index > 0; index--) {
|
|
199
|
-
if (fitsBudget(measure(index)))
|
|
200
|
-
return index;
|
|
201
|
-
}
|
|
202
|
-
return 0;
|
|
203
|
-
}
|
|
204
|
-
//# sourceMappingURL=response-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