@hunt-labs/bytekit-mcp 0.2.1 → 0.2.2

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/CHANGELOG.md CHANGED
@@ -8,6 +8,61 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8
8
  This file records only the delta between versions. For how to use the package
9
9
  today, see [README.md](./README.md), which remains the authoritative usage guide.
10
10
 
11
+ ## [Unreleased]
12
+
13
+ ## [0.2.2] - 2026-07-29
14
+
15
+ ### Fixed
16
+
17
+ - `scrape_url` / `get_result` render every returned textual format
18
+ (`markdown`/`html`/`raw_html`), not just the first present — a multi-format call
19
+ previously dropped every secondary format silently despite it being billed. Secondary
20
+ formats are rendered under a `--- format: <name> ---` delimiter, in canonical order
21
+ after the unlabeled primary. (#2589)
22
+ - The 100KB output truncation budget now covers the links/images blocks too — they were
23
+ previously appended AFTER truncation, so a combined output could exceed the budget.
24
+ The whole assembled payload is now truncated exactly once, with the links/images
25
+ block reserved its own share of the budget so it is never dropped in full just
26
+ because the textual formats alone already fill the budget. (#2589)
27
+ - `scrape_url` / `get_result` descriptions no longer advertise a queued `sc_` outcome
28
+ that the MCP input schema (`url`/`formats`/`country`) cannot produce — that outcome
29
+ was only reachable via `body.async` or fields `can-fast-path.ts` gates on, none of
30
+ which this tool's schema exposes. (#2589)
31
+ - `web_search` now renders `credits_used` and `related_searches`, both spec-required
32
+ fields that were previously dropped silently. (#2591)
33
+ - A sync-failed screenshot's `ss_` handle — absent from the 422 error body — is now
34
+ read from the `X-Screenshot-ID` response header and included in the error text, so
35
+ it can still be redeemed via `get_result`. Degrades gracefully when the header is
36
+ absent. (#2591)
37
+ - The 402 message on `/v1/screenshots` no longer says "Bandwidth quota exhausted"
38
+ (screenshot quotas are credit/count-based) and no longer points at `get_account`,
39
+ which is rate-limit-fragile immediately after a quota failure. Every other endpoint's
40
+ 402 wording is unchanged. (#2591)
41
+ - `get_result`'s invalid-id-prefix message no longer truncates the offending id to 3
42
+ characters. (#2591)
43
+ - `get_result` now gives the same "poll with get_result" guidance `screenshot_url`'s
44
+ queued branch gives when a screenshot is still `pending`/`processing`. (#2591)
45
+ - `get_account` no longer renders a duplicate email (`Account: foo@bar.com
46
+ (foo@bar.com)`) when the account has no name. (#2591)
47
+ - `search_docs` snippets no longer duplicate the page title when the match falls near
48
+ the body's own leading `# <Title>` heading. (#2591)
49
+ - `ScrapeErrorEnvelope.id` is now modeled as nullable, matching
50
+ `docs/api/openapi.yaml` (`id` is null when a scrape was never queued, e.g. a
51
+ validation failure) — `get_result`/`scrape_url` render `ID: —` instead of the
52
+ literal `ID: null`. (#2591)
53
+
54
+ ### Changed
55
+
56
+ - `get_account` now issues its `getAccount`/`getUsage` requests serially instead of
57
+ via `Promise.all`, so it no longer doubles the concurrent request rate against
58
+ 1-rps plans. (#2591)
59
+ - Regenerated the bundled `src/docs-bundle/docs-bundle.json` against the current
60
+ `packages/docs/content` tree. Every guarded endpoint's docs page now states its
61
+ request-body byte ceiling and the `request_too_large` error code (#2640), and the
62
+ `/v1/bulk` pages document `defaults.type` inheritance plus the 422 on unrecognized
63
+ keys (#2643). Content only — no tool surface, schema, or runtime behavior changed.
64
+ (#2640, #2643)
65
+
11
66
  ## [0.2.1] - 2026-07-24
12
67
 
13
68
  ### Fixed
@@ -122,6 +177,8 @@ today, see [README.md](./README.md), which remains the authoritative usage guide
122
177
  (scrape, screenshot, search, docs) to AI agents over the Model Context Protocol,
123
178
  as a local stdio server or hosted.
124
179
 
180
+ [0.2.2]: https://github.com/Hunt-Labs-Inc/ByteKit/tree/main/packages/mcp-server
181
+ [0.2.1]: https://github.com/Hunt-Labs-Inc/ByteKit/tree/main/packages/mcp-server
125
182
  [0.2.0]: https://github.com/Hunt-Labs-Inc/ByteKit/tree/main/packages/mcp-server
126
183
  [0.1.3]: https://github.com/Hunt-Labs-Inc/ByteKit/tree/main/packages/mcp-server
127
184
  [0.1.2]: https://github.com/Hunt-Labs-Inc/ByteKit/tree/main/packages/mcp-server
package/README.md CHANGED
@@ -25,8 +25,8 @@ Point any MCP client that speaks the Streamable HTTP transport at:
25
25
  https://api.bytekit.com/mcp
26
26
  ```
27
27
 
28
- Send your API key as a bearer token. Example client config (Claude Desktop,
29
- Cursor, and most hosts accept this shape):
28
+ Send your API key as a bearer token. Example client config for a host that
29
+ speaks Streamable HTTP directly (Cursor and most hosts accept this shape):
30
30
 
31
31
  ```json
32
32
  {
@@ -41,6 +41,35 @@ Cursor, and most hosts accept this shape):
41
41
  }
42
42
  ```
43
43
 
44
+ **Claude Desktop does not accept this shape.** `claude_desktop_config.json`
45
+ only launches local **stdio** subprocesses (`command`/`args`/`env`) — it has
46
+ no native `url`-based remote-server entry, so pasting the config above into
47
+ it will not connect. To reach the hosted endpoint from Claude Desktop, either:
48
+
49
+ - add ByteKit as a [Connector](https://claude.com/connectors) (Settings →
50
+ Connectors → Add custom connector), or
51
+ - bridge it locally with [`mcp-remote`](https://www.npmjs.com/package/mcp-remote):
52
+
53
+ ```json
54
+ {
55
+ "mcpServers": {
56
+ "bytekit": {
57
+ "command": "npx",
58
+ "args": [
59
+ "-y",
60
+ "mcp-remote",
61
+ "https://api.bytekit.com/mcp",
62
+ "--header",
63
+ "Authorization: Bearer $BYTEKIT_API_KEY"
64
+ ]
65
+ }
66
+ }
67
+ }
68
+ ```
69
+
70
+ Or skip the hosted endpoint entirely and run the **local stdio server**
71
+ (Option 2 below), which Claude Desktop supports natively.
72
+
44
73
  ## Option 2 — Local stdio (`npx`)
45
74
 
46
75
  Run the server as a local subprocess over stdio. Nothing to install globally —
@@ -75,12 +104,13 @@ Client config for a stdio server (`claude_desktop_config.json` and equivalents):
75
104
 
76
105
  ### CLI flags
77
106
 
78
- | Flag | Purpose |
79
- | ------------------ | --------------------------------------------------------------------------------------- |
80
- | `--api-key <key>` | ByteKit API key. |
81
- | `--base-url <url>` | API base URL (default `https://api.bytekit.com`) — point at staging or a local gateway. |
82
- | `--verbose` | Log requests to stderr. |
83
- | `--help` | Show usage. |
107
+ | Flag | Purpose |
108
+ | ------------------- | --------------------------------------------------------------------------------------- |
109
+ | `--api-key <key>` | ByteKit API key. |
110
+ | `--base-url <url>` | API base URL (default `https://api.bytekit.com`) — point at staging or a local gateway. |
111
+ | `--timeout-ms <ms>` | Per-request timeout budget in milliseconds (default `120000`; `0` disables it). |
112
+ | `--verbose` | Log requests to stderr. |
113
+ | `--help` | Show usage. |
84
114
 
85
115
  ### API-key resolution order
86
116
 
@@ -89,6 +119,15 @@ The local server resolves the key in this order:
89
119
  1. `--api-key <key>` flag
90
120
  2. `BYTEKIT_API_KEY` environment variable
91
121
 
122
+ ### Base-URL resolution order
123
+
124
+ The base URL resolves the same way, and it is not just an `--help`-only
125
+ detail — it also falls back to an environment variable:
126
+
127
+ 1. `--base-url <url>` flag
128
+ 2. `BYTEKIT_BASE_URL` environment variable
129
+ 3. `https://api.bytekit.com` (built-in default)
130
+
92
131
  ## Tool inventory
93
132
 
94
133
  | Tool | What it does |
@@ -106,6 +145,23 @@ The server also exposes **resources** (`bytekit://account`,
106
145
  `bytekit://screenshot/{id}`) and **prompts** (`summarize_webpage`,
107
146
  `extract_structured_data`, `research_topic`) that MCP hosts can surface directly.
108
147
 
148
+ ### `scrape_url` output shape
149
+
150
+ `scrape_url` (and `get_result` redeeming a scrape's `sc_` handle) render every
151
+ requested format present in the response: the first present format (default
152
+ `markdown`) is unlabeled, and each additional one (`html`, `raw_html`) follows under
153
+ its own `--- format: <name> ---` delimiter, with `links`/`images` blocks appended
154
+ after. That rendered content (the requested formats plus any `links`/`images`
155
+ blocks) is capped at a single 100KB budget — on very large pages a requested format's
156
+ content may be truncated, and in extreme cases a secondary format may not appear, to
157
+ stay within that budget. A handful of header lines (id, URL, status, page title) are
158
+ added on top of the rendered content and are not counted against the cap.
159
+
160
+ None of the three textual formats is HTML-sanitized — `raw_html`, `html`, and
161
+ `markdown` all reflect the page's own markup (`markdown` differs only in being
162
+ content-extracted, not sanitized). Treat all of their content as untrusted page data,
163
+ the same as fetching the page directly.
164
+
109
165
  ## Documentation
110
166
 
111
167
  Full MCP guide: [bytekit.com/docs/mcp](https://bytekit.com/docs/mcp).
package/dist/cli.d.ts CHANGED
@@ -39,7 +39,24 @@ export declare function resolveBaseUrl(opts: {
39
39
  flag?: string | undefined;
40
40
  env: Record<string, string | undefined>;
41
41
  }): string;
42
- export declare const HELP_TEXT = "ByteKit MCP Server\n\nUsage:\n bytekit-mcp --api-key <key> [--base-url <url>] [--verbose]\n\nOptions:\n --api-key ByteKit API key. Resolution order: --api-key flag, then\n BYTEKIT_API_KEY.\n --base-url API base URL. Resolution order: --base-url flag, then\n BYTEKIT_BASE_URL (default: https://api.bytekit.com)\n --verbose Log requests to stderr\n --help Show this help message\n";
42
+ export declare const TIMEOUT_MS_INVALID_MESSAGE = "Error: --timeout-ms must be a non-negative number.\n";
43
+ /**
44
+ * Parse the `--timeout-ms` flag into the numeric budget the {@link BytekitClient}
45
+ * constructor's `timeoutMs` option accepts, or `undefined` to let the client fall
46
+ * through to its own default. Mirrors {@link resolveApiKey}/{@link resolveBaseUrl}'s
47
+ * flag-parsing shape (empty/absent flag falls through); a non-finite parse result
48
+ * (`NaN`, e.g. from a non-numeric flag) is likewise treated as absent. The
49
+ * {@link BytekitClient} constructor's `validateTimeout` does NOT clamp or normalize —
50
+ * it THROWS a `TypeError` for any negative value — so a finite negative flag is
51
+ * rejected HERE instead, as a {@link RangeError} carrying
52
+ * {@link TIMEOUT_MS_INVALID_MESSAGE}, before it ever reaches the constructor. This
53
+ * deliberately does NOT special-case `0` as "absent", since `0` is a meaningful
54
+ * value (disables the budget entirely).
55
+ *
56
+ * @throws {RangeError} when the flag parses to a finite negative number.
57
+ */
58
+ export declare function resolveTimeoutMs(flag: string | undefined): number | undefined;
59
+ export declare const HELP_TEXT = "ByteKit MCP Server\n\nUsage:\n bytekit-mcp --api-key <key> [--base-url <url>] [--timeout-ms <ms>] [--verbose]\n\nOptions:\n --api-key ByteKit API key. Resolution order: --api-key flag, then\n BYTEKIT_API_KEY.\n --base-url API base URL. Resolution order: --base-url flag, then\n BYTEKIT_BASE_URL (default: https://api.bytekit.com)\n --timeout-ms Per-request timeout budget in milliseconds (default: 120000;\n 0 disables it)\n --verbose Log requests to stderr\n --help Show this help message\n";
43
60
  /**
44
61
  * True when this module is the process entrypoint (run directly or via its bin),
45
62
  * false when it is merely imported (e.g. the test suite exercising resolveApiKey).
package/dist/cli.js CHANGED
@@ -44,24 +44,54 @@ export function resolveBaseUrl(opts) {
44
44
  const flag = opts.flag && opts.flag.length > 0 ? opts.flag : undefined;
45
45
  return flag ?? opts.env['BYTEKIT_BASE_URL'] ?? DEFAULT_BASE_URL;
46
46
  }
47
+ export const TIMEOUT_MS_INVALID_MESSAGE = 'Error: --timeout-ms must be a non-negative number.\n';
48
+ /**
49
+ * Parse the `--timeout-ms` flag into the numeric budget the {@link BytekitClient}
50
+ * constructor's `timeoutMs` option accepts, or `undefined` to let the client fall
51
+ * through to its own default. Mirrors {@link resolveApiKey}/{@link resolveBaseUrl}'s
52
+ * flag-parsing shape (empty/absent flag falls through); a non-finite parse result
53
+ * (`NaN`, e.g. from a non-numeric flag) is likewise treated as absent. The
54
+ * {@link BytekitClient} constructor's `validateTimeout` does NOT clamp or normalize —
55
+ * it THROWS a `TypeError` for any negative value — so a finite negative flag is
56
+ * rejected HERE instead, as a {@link RangeError} carrying
57
+ * {@link TIMEOUT_MS_INVALID_MESSAGE}, before it ever reaches the constructor. This
58
+ * deliberately does NOT special-case `0` as "absent", since `0` is a meaningful
59
+ * value (disables the budget entirely).
60
+ *
61
+ * @throws {RangeError} when the flag parses to a finite negative number.
62
+ */
63
+ export function resolveTimeoutMs(flag) {
64
+ if (flag === undefined || flag.length === 0)
65
+ return undefined;
66
+ const parsed = Number(flag);
67
+ if (!Number.isFinite(parsed))
68
+ return undefined;
69
+ if (parsed < 0) {
70
+ throw new RangeError(TIMEOUT_MS_INVALID_MESSAGE);
71
+ }
72
+ return parsed;
73
+ }
47
74
  export const HELP_TEXT = `ByteKit MCP Server
48
75
 
49
76
  Usage:
50
- bytekit-mcp --api-key <key> [--base-url <url>] [--verbose]
77
+ bytekit-mcp --api-key <key> [--base-url <url>] [--timeout-ms <ms>] [--verbose]
51
78
 
52
79
  Options:
53
- --api-key ByteKit API key. Resolution order: --api-key flag, then
54
- BYTEKIT_API_KEY.
55
- --base-url API base URL. Resolution order: --base-url flag, then
56
- BYTEKIT_BASE_URL (default: https://api.bytekit.com)
57
- --verbose Log requests to stderr
58
- --help Show this help message
80
+ --api-key ByteKit API key. Resolution order: --api-key flag, then
81
+ BYTEKIT_API_KEY.
82
+ --base-url API base URL. Resolution order: --base-url flag, then
83
+ BYTEKIT_BASE_URL (default: https://api.bytekit.com)
84
+ --timeout-ms Per-request timeout budget in milliseconds (default: 120000;
85
+ 0 disables it)
86
+ --verbose Log requests to stderr
87
+ --help Show this help message
59
88
  `;
60
89
  async function main() {
61
90
  const { values } = parseArgs({
62
91
  options: {
63
92
  'api-key': { type: 'string' },
64
93
  'base-url': { type: 'string' },
94
+ 'timeout-ms': { type: 'string' },
65
95
  verbose: { type: 'boolean', default: false },
66
96
  help: { type: 'boolean', default: false },
67
97
  },
@@ -76,10 +106,27 @@ async function main() {
76
106
  process.stderr.write(API_KEY_REQUIRED_MESSAGE);
77
107
  process.exit(1);
78
108
  }
109
+ // `exactOptionalPropertyTypes` forbids passing `timeoutMs: undefined` explicitly
110
+ // (the constructor's `timeoutMs?: number` means "present and a number", not
111
+ // "present and possibly undefined") — spread it in only when resolved, so an
112
+ // absent --timeout-ms flag falls through to the constructor's own default.
113
+ let timeoutMs;
114
+ try {
115
+ timeoutMs = resolveTimeoutMs(values['timeout-ms']);
116
+ }
117
+ catch (err) {
118
+ // resolveTimeoutMs throws a RangeError for a finite negative value — surface
119
+ // it as a graceful CLI error (mirroring the missing-API-key path below)
120
+ // instead of letting it propagate into the BytekitClient constructor, where
121
+ // validateTimeout would throw an uncaught TypeError.
122
+ process.stderr.write(err instanceof Error ? err.message : String(err));
123
+ process.exit(1);
124
+ }
79
125
  const client = new BytekitClient({
80
126
  apiKey,
81
127
  baseUrl: resolveBaseUrl({ flag: values['base-url'], env: process.env }),
82
128
  verbose: values.verbose,
129
+ ...(timeoutMs !== undefined ? { timeoutMs } : {}),
83
130
  });
84
131
  const server = createServer(client);
85
132
  const transport = new StdioServerTransport();
package/dist/client.js CHANGED
@@ -346,12 +346,30 @@ export class BytekitClient {
346
346
  if (path.startsWith('/v1/search')) {
347
347
  throw new BytekitApiError('Search credit quota exhausted. Add credits or upgrade your plan to run more searches.', 402, 'quota_exceeded');
348
348
  }
349
+ // Screenshot quotas are credit/count-based, not bandwidth (issue #2591 item 3) --
350
+ // the bandwidth wording below is factually wrong for this endpoint. The
351
+ // get_account pointer is also dropped here: recommending an immediate follow-up
352
+ // call right after a quota failure is rate-limit-fragile on a 1-rps plan.
353
+ // Exact-match (not startsWith) so `/v1/screenshots/{id}` GET is unaffected.
354
+ if (path === '/v1/screenshots') {
355
+ throw new BytekitApiError('Screenshot quota exhausted. Add credits or upgrade your plan to capture more screenshots.', 402, 'quota_exceeded');
356
+ }
349
357
  throw new BytekitApiError('Bandwidth quota exhausted. Check usage with get_account.', 402, 'quota_exceeded');
350
358
  }
351
359
  if (status === 422) {
352
360
  const base = envelope.message ?? 'Validation error.';
353
361
  const detail = envelope.details !== undefined ? `${base} (${formatErrorDetails(envelope.details)})` : base;
354
- throw new BytekitApiError(detail, 422, envelope.code ?? 'validation_error');
362
+ // A sync-failed screenshot (POST /v1/screenshots -> 422) carries no `ss_` handle in
363
+ // the generic error body this branch parses (only message/details/code) -- the
364
+ // handle is only GUARANTEED to travel in the `X-Screenshot-ID` response header
365
+ // (openapi.yaml: "matches `id` in the JSON envelope"). Reading it here lets the
366
+ // agent redeem the failed screenshot later via get_result (issue #2591 item 2).
367
+ // Scoped to the exact create-endpoint path (not `startsWith`, which would also
368
+ // match `/v1/screenshots/{id}` GET) so no other 422 path is affected. Header
369
+ // absent -> degrade gracefully, omit the handle line entirely (E1).
370
+ const screenshotId = path === '/v1/screenshots' ? response.headers.get('X-Screenshot-ID') : null;
371
+ const message = screenshotId ? `${detail} (Screenshot ID: ${screenshotId})` : detail;
372
+ throw new BytekitApiError(message, 422, envelope.code ?? 'validation_error');
355
373
  }
356
374
  // ── Flat vendor-masked shape: `{ "error": "<code>" }` (e.g. /v1/search 502,
357
375
  // docs/api/openapi.yaml §/v1/search 502). The string IS the error code, so