@hunt-labs/bytekit-mcp 0.2.8 → 0.3.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.
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { loadBundle } from '../docs-bundle/load-bundle.js';
3
+ import { boundDocBody, MAX_DOC_BODY_BYTES } from '../docs-bundle/body-bound.js';
3
4
  /**
4
5
  * Validates that a path is safe to use as a bundle key lookup.
5
6
  *
@@ -20,7 +21,10 @@ function isValidPath(path) {
20
21
  return !segments.some((seg) => seg === '..' || seg === '.');
21
22
  }
22
23
  export function getDocTool(server) {
23
- server.tool('get_doc', 'Retrieve the full rendered markdown for a specific documentation page. Use list_docs or search_docs to discover valid paths first.', {
24
+ server.tool('get_doc', 'Retrieve the rendered markdown for a specific documentation page. Bodies are capped at ' +
25
+ `${MAX_DOC_BODY_BYTES} bytes; a page above the cap is returned cut short, with a closing ` +
26
+ 'notice naming its full size and the URL that serves all of it. Use list_docs or ' +
27
+ 'search_docs to discover valid paths first.', {
24
28
  path: z
25
29
  .string()
26
30
  .describe('Relative doc path (e.g. "guides/authentication", "api/scrape/createscrape")'),
@@ -50,11 +54,17 @@ export function getDocTool(server) {
50
54
  ],
51
55
  };
52
56
  }
57
+ // The bound is applied HERE, at the read, and not only at the harvest step that
58
+ // produced the bundle: `loadBundle` reads whatever docs-bundle.json is on disk, so
59
+ // the tool's own contract — never return a body no caller can use — has to hold for
60
+ // a bundle this repo did not generate. Over an already-bounded body the call is a
61
+ // no-op, which is what keeps every other entry byte-identical (issue #3233).
62
+ const { body } = boundDocBody(entry.body, params.path);
53
63
  return {
54
64
  content: [
55
65
  {
56
66
  type: 'text',
57
- text: JSON.stringify({ title: entry.title, section: entry.section, body: entry.body }, null, 2),
67
+ text: JSON.stringify({ title: entry.title, section: entry.section, body }, null, 2),
58
68
  },
59
69
  ],
60
70
  };
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { loadBundle } from '../docs-bundle/load-bundle.js';
3
+ import { MAX_DOC_BODY_BYTES, DOCS_BASE_URL } from '../docs-bundle/body-bound.js';
3
4
  const SNIPPET_RADIUS = 100; // chars on each side of the first match → ~200 total
4
5
  const MAX_RESULTS = 10;
5
6
  /**
@@ -64,8 +65,48 @@ function extractSnippet(text, tokens) {
64
65
  const snippet = text.slice(start, end).trim();
65
66
  return (start > 0 ? '…' : '') + snippet + (end < text.length ? '…' : '');
66
67
  }
68
+ /**
69
+ * The advertised description of `search_docs`.
70
+ *
71
+ * The closing disclosure is #3307's. `scoreEntry` runs over the bundle's harvested bodies, and
72
+ * those are bounded at {@link MAX_DOC_BODY_BYTES} — so search coverage is the bounded body, not
73
+ * the published page. On the `changelog` entry that is 16 KB of a ~140 KB page, and a query for a
74
+ * release below the cut returns nothing, with no way for the caller to tell an absent feature
75
+ * from an unindexed one. Saying so in the schema is the part of the fix an agent meets BEFORE it
76
+ * phrases a query; the per-page truncation notice (`body-bound.ts`) is the part it meets after.
77
+ *
78
+ * SAY WHICH TEXT IS MISSING, NOT JUST THAT SOME IS (#3307 review B1)
79
+ * ------------------------------------------------------------------
80
+ * The first wording called the missing part "every release older than the kept window". That was
81
+ * false, and false in the direction that does damage: the cut is POSITIONAL — the leading
82
+ * {@link MAX_DOC_BODY_BYTES} bytes in page order — and the changelog is ordered by distribution,
83
+ * not by date. The window ends inside the FIRST of its four `##` package sections, so the Python
84
+ * SDK, CLI and MCP-server histories are outside it entirely, newest releases included; the CLI's
85
+ * `0.9.0` and the MCP server's `0.3.0` share a release date with the TypeScript SDK release that
86
+ * IS inside the window. An agent told only older releases are missing, querying for the newest
87
+ * CLI release and getting nothing, concludes the feature does not exist — which is this ticket's
88
+ * own defect, recreated by the sentence meant to close it. A partial model is worse than none,
89
+ * because the agent acts on it.
90
+ *
91
+ * Both the limit and the docs origin are interpolated rather than restated, so this text cannot
92
+ * name a bound the harvest step does not apply or an origin the truncation notice does not use.
93
+ * The page URL is named outright, not merely pointed at: a search that returns zero results hands
94
+ * the agent no result to read, so routing it through `get_doc` first would cost a second call to
95
+ * learn where to go. The claim about which sections survive is re-derived from the committed
96
+ * bundle in `__tests__/search-coverage-disclosure.test.ts`, so prose and artifact are pinned to
97
+ * each other.
98
+ */
99
+ const SEARCH_DOCS_DESCRIPTION = 'Search the ByteKit documentation bundle. Returns up to 10 results with a snippet showing ' +
100
+ 'context around the first match. Case-insensitive token match over title and body. Body ' +
101
+ `matching covers only the bounded body get_doc returns — the leading ${MAX_DOC_BODY_BYTES} ` +
102
+ 'bytes of a page — so text cut from a longer page is not searchable here. The cut is ' +
103
+ 'positional, by page order, never by age. On the changelog page that window currently reaches ' +
104
+ 'only part of the first of its four package histories (@hunt-labs/bytekit-sdk), so the ' +
105
+ 'bytekit-sdk (Python), @hunt-labs/bytekit-cli and @hunt-labs/bytekit-mcp histories are not ' +
106
+ 'searchable here at all, their newest releases included; read the whole page at ' +
107
+ `${DOCS_BASE_URL}/changelog.`;
67
108
  export function searchDocsTool(server) {
68
- server.tool('search_docs', 'Search the ByteKit documentation bundle. Returns up to 10 results with a snippet showing context around the first match. Case-insensitive token match over title and body.', {
109
+ server.tool('search_docs', SEARCH_DOCS_DESCRIPTION, {
69
110
  query: z
70
111
  .string()
71
112
  .min(1, 'query must be non-empty')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hunt-labs/bytekit-mcp",
3
- "version": "0.2.8",
3
+ "version": "0.3.1",
4
4
  "description": "ByteKit MCP server — exposes ByteKit web-data tools (scrape, screenshot, search, docs) to AI agents over the Model Context Protocol, hosted or as a local stdio server.",
5
5
  "license": "MIT",
6
6
  "type": "module",