@hunt-labs/bytekit-mcp 0.1.0 → 0.1.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.
Files changed (127) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +117 -0
  3. package/dist/cli.d.ts +5 -1
  4. package/dist/cli.js +22 -6
  5. package/dist/client.d.ts +7 -29
  6. package/dist/client.js +0 -5
  7. package/dist/docs-bundle/docs-bundle.json +46 -46
  8. package/dist/docs-bundle/helpers.d.ts +0 -1
  9. package/dist/docs-bundle/helpers.js +0 -1
  10. package/dist/docs-bundle/load-bundle.d.ts +0 -1
  11. package/dist/docs-bundle/load-bundle.js +0 -1
  12. package/dist/http.d.ts +0 -1
  13. package/dist/http.js +0 -1
  14. package/dist/index.d.ts +1 -2
  15. package/dist/index.js +12 -2
  16. package/dist/lib/truncate.d.ts +0 -1
  17. package/dist/lib/truncate.js +0 -1
  18. package/dist/prompts/extract-structured-data.d.ts +0 -1
  19. package/dist/prompts/extract-structured-data.js +0 -1
  20. package/dist/prompts/research-topic.d.ts +0 -1
  21. package/dist/prompts/research-topic.js +0 -1
  22. package/dist/prompts/summarize-webpage.d.ts +0 -1
  23. package/dist/prompts/summarize-webpage.js +0 -1
  24. package/dist/resources/account.d.ts +0 -1
  25. package/dist/resources/account.js +0 -1
  26. package/dist/resources/screenshot.d.ts +0 -1
  27. package/dist/resources/screenshot.js +0 -1
  28. package/dist/scrape-contract.generated.d.ts +166 -0
  29. package/dist/scrape-contract.generated.js +9 -0
  30. package/dist/tools/get-account.d.ts +0 -1
  31. package/dist/tools/get-account.js +0 -1
  32. package/dist/tools/get-doc.d.ts +0 -1
  33. package/dist/tools/get-doc.js +0 -1
  34. package/dist/tools/get-result.d.ts +0 -1
  35. package/dist/tools/get-result.js +0 -1
  36. package/dist/tools/list-docs.d.ts +0 -1
  37. package/dist/tools/list-docs.js +0 -1
  38. package/dist/tools/scrape-url.d.ts +0 -1
  39. package/dist/tools/scrape-url.js +48 -8
  40. package/dist/tools/screenshot-url.d.ts +0 -1
  41. package/dist/tools/screenshot-url.js +0 -1
  42. package/dist/tools/search-docs.d.ts +0 -1
  43. package/dist/tools/search-docs.js +0 -1
  44. package/dist/tools/web-search.d.ts +0 -1
  45. package/dist/tools/web-search.js +0 -1
  46. package/package.json +34 -9
  47. package/dist/__tests__/build-docs-bundle.test.d.ts +0 -2
  48. package/dist/__tests__/build-docs-bundle.test.d.ts.map +0 -1
  49. package/dist/__tests__/build-docs-bundle.test.js +0 -133
  50. package/dist/__tests__/build-docs-bundle.test.js.map +0 -1
  51. package/dist/__tests__/cli.test.d.ts +0 -2
  52. package/dist/__tests__/cli.test.d.ts.map +0 -1
  53. package/dist/__tests__/cli.test.js +0 -41
  54. package/dist/__tests__/cli.test.js.map +0 -1
  55. package/dist/__tests__/client.test.d.ts +0 -2
  56. package/dist/__tests__/client.test.d.ts.map +0 -1
  57. package/dist/__tests__/client.test.js +0 -248
  58. package/dist/__tests__/client.test.js.map +0 -1
  59. package/dist/__tests__/integration.test.d.ts +0 -2
  60. package/dist/__tests__/integration.test.d.ts.map +0 -1
  61. package/dist/__tests__/integration.test.js +0 -116
  62. package/dist/__tests__/integration.test.js.map +0 -1
  63. package/dist/__tests__/package-manifest.test.d.ts +0 -2
  64. package/dist/__tests__/package-manifest.test.d.ts.map +0 -1
  65. package/dist/__tests__/package-manifest.test.js +0 -71
  66. package/dist/__tests__/package-manifest.test.js.map +0 -1
  67. package/dist/__tests__/prompts.test.d.ts +0 -2
  68. package/dist/__tests__/prompts.test.d.ts.map +0 -1
  69. package/dist/__tests__/prompts.test.js +0 -92
  70. package/dist/__tests__/prompts.test.js.map +0 -1
  71. package/dist/__tests__/resources.test.d.ts +0 -2
  72. package/dist/__tests__/resources.test.d.ts.map +0 -1
  73. package/dist/__tests__/resources.test.js +0 -67
  74. package/dist/__tests__/resources.test.js.map +0 -1
  75. package/dist/__tests__/server-info.test.d.ts +0 -2
  76. package/dist/__tests__/server-info.test.d.ts.map +0 -1
  77. package/dist/__tests__/server-info.test.js +0 -14
  78. package/dist/__tests__/server-info.test.js.map +0 -1
  79. package/dist/__tests__/tools.test.d.ts +0 -2
  80. package/dist/__tests__/tools.test.d.ts.map +0 -1
  81. package/dist/__tests__/tools.test.js +0 -452
  82. package/dist/__tests__/tools.test.js.map +0 -1
  83. package/dist/cli.d.ts.map +0 -1
  84. package/dist/cli.js.map +0 -1
  85. package/dist/client.d.ts.map +0 -1
  86. package/dist/client.js.map +0 -1
  87. package/dist/docs-bundle/helpers.d.ts.map +0 -1
  88. package/dist/docs-bundle/helpers.js.map +0 -1
  89. package/dist/docs-bundle/load-bundle.d.ts.map +0 -1
  90. package/dist/docs-bundle/load-bundle.js.map +0 -1
  91. package/dist/http.d.ts.map +0 -1
  92. package/dist/http.js.map +0 -1
  93. package/dist/index.d.ts.map +0 -1
  94. package/dist/index.js.map +0 -1
  95. package/dist/lib/truncate.d.ts.map +0 -1
  96. package/dist/lib/truncate.js.map +0 -1
  97. package/dist/prompts/extract-structured-data.d.ts.map +0 -1
  98. package/dist/prompts/extract-structured-data.js.map +0 -1
  99. package/dist/prompts/research-topic.d.ts.map +0 -1
  100. package/dist/prompts/research-topic.js.map +0 -1
  101. package/dist/prompts/summarize-webpage.d.ts.map +0 -1
  102. package/dist/prompts/summarize-webpage.js.map +0 -1
  103. package/dist/resources/account.d.ts.map +0 -1
  104. package/dist/resources/account.js.map +0 -1
  105. package/dist/resources/screenshot.d.ts.map +0 -1
  106. package/dist/resources/screenshot.js.map +0 -1
  107. package/dist/tools/__tests__/docs-tools.test.d.ts +0 -8
  108. package/dist/tools/__tests__/docs-tools.test.d.ts.map +0 -1
  109. package/dist/tools/__tests__/docs-tools.test.js +0 -194
  110. package/dist/tools/__tests__/docs-tools.test.js.map +0 -1
  111. package/dist/tools/__tests__/fixture-bundle.json +0 -27
  112. package/dist/tools/get-account.d.ts.map +0 -1
  113. package/dist/tools/get-account.js.map +0 -1
  114. package/dist/tools/get-doc.d.ts.map +0 -1
  115. package/dist/tools/get-doc.js.map +0 -1
  116. package/dist/tools/get-result.d.ts.map +0 -1
  117. package/dist/tools/get-result.js.map +0 -1
  118. package/dist/tools/list-docs.d.ts.map +0 -1
  119. package/dist/tools/list-docs.js.map +0 -1
  120. package/dist/tools/scrape-url.d.ts.map +0 -1
  121. package/dist/tools/scrape-url.js.map +0 -1
  122. package/dist/tools/screenshot-url.d.ts.map +0 -1
  123. package/dist/tools/screenshot-url.js.map +0 -1
  124. package/dist/tools/search-docs.d.ts.map +0 -1
  125. package/dist/tools/search-docs.js.map +0 -1
  126. package/dist/tools/web-search.d.ts.map +0 -1
  127. package/dist/tools/web-search.js.map +0 -1
@@ -0,0 +1,166 @@
1
+ export type Format = 'rawHtml' | 'html' | 'markdown' | 'links' | 'images';
2
+ /**
3
+ * Contract generation emitted by every newly produced scrape envelope.
4
+ *
5
+ * This requirement applies to producer-created `ScrapeEnvelope` values. JSON
6
+ * persisted by an older deployment may omit `schema_version`; readers at
7
+ * cache and webhook-delivery boundaries must keep that data loosely typed and
8
+ * treat the missing marker as legacy v0 instead of coercing it to this union.
9
+ */
10
+ export declare const SCRAPE_ENVELOPE_SCHEMA_VERSION = 1;
11
+ export type ScrapeEnvelopeSchemaVersion = typeof SCRAPE_ENVELOPE_SCHEMA_VERSION;
12
+ export interface ScrapeScoredLink {
13
+ url: string;
14
+ text: string;
15
+ isInternal: boolean;
16
+ rel: string | null;
17
+ }
18
+ export interface ScrapeScoredImage {
19
+ url: string;
20
+ alt: string | null;
21
+ width: number | null;
22
+ height: number | null;
23
+ format: string | null;
24
+ score: number;
25
+ }
26
+ export interface ScrapeTable {
27
+ kind: 'data' | 'layout-unwrapped' | 'lossy';
28
+ gfm: string | null;
29
+ rows: number;
30
+ cols: number;
31
+ }
32
+ export interface ScrapeWarning {
33
+ code: 'lossy_table' | 'complex_math' | 'unsupported_element' | 'extraction_fallback' | 'truncated' | 'query_no_match' | 'mode_disabled_fallback' | 'artifact_unavailable' | 'llm_clean_unavailable' | 'llm_clean_failed' | 'low_quality_extraction' | 'fragment_menu_stripped';
34
+ message: string;
35
+ element: string | null;
36
+ }
37
+ export interface ScrapeStats {
38
+ chars: number;
39
+ tokens: number;
40
+ blocks: number;
41
+ }
42
+ export type ScrapeEnvelopeErrorCode = 'validation_error' | 'request_too_large' | 'quota_exhausted' | 'payload_too_large' | 'unsupported_content_type' | 'rate_limited' | 'upstream_error' | 'timeout' | 'blocked' | 'internal_error';
43
+ export interface ScrapeFormats {
44
+ /** Raw HTML format (#1535: renamed from rawHtml in the response key). */
45
+ raw_html?: string;
46
+ html?: string;
47
+ markdown?: string;
48
+ links?: string[] | ScrapeScoredLink[];
49
+ images?: string[] | ScrapeScoredImage[];
50
+ }
51
+ export interface ScrapeMetadata {
52
+ title?: string | null;
53
+ description?: string | null;
54
+ language?: string | null;
55
+ canonicalUrl?: string | null;
56
+ ogTitle?: string | null;
57
+ ogDescription?: string | null;
58
+ ogImage?: string | null;
59
+ ogUrl?: string | null;
60
+ ogSiteName?: string | null;
61
+ robots?: string | null;
62
+ byline: string | null;
63
+ publishedAt: string | null;
64
+ }
65
+ export interface ScrapeSuccessEnvelope {
66
+ schema_version: ScrapeEnvelopeSchemaVersion;
67
+ status: 'success';
68
+ /**
69
+ * Stable job identifier (sc_… prefixed). Canonical field (#1232).
70
+ */
71
+ id: string;
72
+ url: string;
73
+ /** Final URL after redirects (#1535: renamed from finalUrl). */
74
+ final_url: string;
75
+ /** Content-Type header value (#1535: renamed from contentType). */
76
+ content_type: string;
77
+ /** Compressed wire bytes — billing basis (#1535: renamed from contentLength). */
78
+ content_length: number;
79
+ /** Upstream HTTP status (#1535: renamed from statusCode). */
80
+ status_code: number | null;
81
+ /** ISO timestamp of retrieval (#1535: renamed from retrievedAt). */
82
+ retrieved_at: string;
83
+ formats: ScrapeFormats;
84
+ metadata: ScrapeMetadata;
85
+ tables?: ScrapeTable[];
86
+ warnings?: ScrapeWarning[];
87
+ stats?: ScrapeStats;
88
+ /**
89
+ * User-supplied passthrough payload (issue #129). Distinct from `metadata`,
90
+ * which is system-extracted from the HTML head. Emitted only when the
91
+ * caller passes a non-empty record — empty `{}` and undefined both omit.
92
+ */
93
+ custom?: Record<string, unknown>;
94
+ /**
95
+ * Cache verdict for the request that produced this envelope (issue #830).
96
+ * `hit` — served from a prior cache entry (billed at 0.5×).
97
+ * `miss` — freshly fetched and written to cache.
98
+ * `bypass` — `cache_ttl: '0'` skipped the read (still written).
99
+ * Emitted only when the producing path threads a cache verdict; omitted
100
+ * otherwise so consumers that predate the field (and the bulk-rehydrate
101
+ * path, which has no cache verdict) see no new key.
102
+ */
103
+ cache?: 'miss' | 'hit' | 'bypass';
104
+ /**
105
+ * Age in whole seconds of the cache entry replayed on a `hit` (issue #830).
106
+ * Clamped to ≥ 0 to absorb clock skew. Present only on `cache: 'hit'`.
107
+ */
108
+ cache_age_s?: number;
109
+ /**
110
+ * Token-budget accounting (issue #872). Present only when `token_budget` was
111
+ * supplied in the request. Contains `kept` (tokens in the returned markdown),
112
+ * `total` (tokens in the full pre-truncation markdown), and `truncated`
113
+ * (whether the output was cut). Absent on uncapped requests to avoid noise.
114
+ */
115
+ markdown_tokens?: {
116
+ kept: number;
117
+ total: number;
118
+ truncated: boolean;
119
+ };
120
+ /**
121
+ * Per-call billing multiplier for this scrape (1.0 base, +0.5/billable format).
122
+ * Matches the X-Billing-Multiplier header 1:1, and equals the
123
+ * X-Scrape-Credits-Charged header and the persisted credits_charged column.
124
+ * NOTE: pre-clean_markdown-multiplier; on clean_markdown:true the final billed
125
+ * usage is 3x this. Omitted on paths with no billing value (issue #1899).
126
+ */
127
+ billing_multiplier?: number;
128
+ /**
129
+ * Metered wire bytes for this call = round(content_length x billing_multiplier).
130
+ * Same value as the X-Billable-Bytes header (pre-clean_markdown-multiplier, like
131
+ * the header). Omitted on paths with no billing value (issue #1899).
132
+ */
133
+ billed_bytes?: number;
134
+ }
135
+ export interface ScrapeErrorEnvelope {
136
+ schema_version: ScrapeEnvelopeSchemaVersion;
137
+ status: 'failed';
138
+ /** Stable job identifier (sc_… prefixed). Canonical field (#1232; queued/error migrated #1971). */
139
+ id: string;
140
+ error: {
141
+ code: ScrapeEnvelopeErrorCode;
142
+ message: string;
143
+ /** Upstream HTTP status (#1971: renamed from httpStatus). Strict-optional — omitted when absent. */
144
+ http_status?: number;
145
+ /** ISO timestamp of failure (#1971: renamed from failedAt). */
146
+ failed_at: string;
147
+ };
148
+ }
149
+ export interface ScrapeQueuedEnvelope {
150
+ schema_version: ScrapeEnvelopeSchemaVersion;
151
+ status: 'queued';
152
+ /** Stable job identifier (sc_… prefixed). Canonical field (#1232; queued/error migrated #1971). */
153
+ id: string;
154
+ url: string;
155
+ /** Status-poll URL (#1971: renamed from statusUrl). */
156
+ status_url: string;
157
+ /** ISO timestamp of enqueue (#1971: renamed from queuedAt). */
158
+ queued_at: string;
159
+ events: string[];
160
+ }
161
+ /**
162
+ * Newly produced envelopes are v1 and use `status` as their shape
163
+ * discriminator. Stored JSON without `schema_version` is legacy v0 data and
164
+ * remains valid only at explicit read/delivery boundaries typed more loosely.
165
+ */
166
+ export type ScrapeEnvelope = ScrapeSuccessEnvelope | ScrapeErrorEnvelope | ScrapeQueuedEnvelope;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Contract generation emitted by every newly produced scrape envelope.
3
+ *
4
+ * This requirement applies to producer-created `ScrapeEnvelope` values. JSON
5
+ * persisted by an older deployment may omit `schema_version`; readers at
6
+ * cache and webhook-delivery boundaries must keep that data loosely typed and
7
+ * treat the missing marker as legacy v0 instead of coercing it to this union.
8
+ */
9
+ export const SCRAPE_ENVELOPE_SCHEMA_VERSION = 1;
@@ -1,4 +1,3 @@
1
1
  import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
2
  import type { BytekitClient } from '../client.js';
3
3
  export declare function getAccountTool(server: McpServer, client: BytekitClient): void;
4
- //# sourceMappingURL=get-account.d.ts.map
@@ -42,4 +42,3 @@ export function getAccountTool(server, client) {
42
42
  }
43
43
  });
44
44
  }
45
- //# sourceMappingURL=get-account.js.map
@@ -1,3 +1,2 @@
1
1
  import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
2
  export declare function getDocTool(server: McpServer): void;
3
- //# sourceMappingURL=get-doc.d.ts.map
@@ -68,4 +68,3 @@ export function getDocTool(server) {
68
68
  }
69
69
  });
70
70
  }
71
- //# sourceMappingURL=get-doc.js.map
@@ -1,4 +1,3 @@
1
1
  import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
2
  import type { BytekitClient } from '../client.js';
3
3
  export declare function getResultTool(server: McpServer, client: BytekitClient): void;
4
- //# sourceMappingURL=get-result.d.ts.map
@@ -41,4 +41,3 @@ export function getResultTool(server, client) {
41
41
  }
42
42
  });
43
43
  }
44
- //# sourceMappingURL=get-result.js.map
@@ -1,3 +1,2 @@
1
1
  import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
2
  export declare function listDocsTool(server: McpServer): void;
3
- //# sourceMappingURL=list-docs.d.ts.map
@@ -30,4 +30,3 @@ export function listDocsTool(server) {
30
30
  }
31
31
  });
32
32
  }
33
- //# sourceMappingURL=list-docs.js.map
@@ -1,4 +1,3 @@
1
1
  import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
2
  import type { BytekitClient } from '../client.js';
3
3
  export declare function scrapeUrlTool(server: McpServer, client: BytekitClient): void;
4
- //# sourceMappingURL=scrape-url.d.ts.map
@@ -1,5 +1,15 @@
1
1
  import { z } from 'zod';
2
2
  import { truncateContent } from '../lib/truncate.js';
3
+ function renderLinks(links) {
4
+ return links
5
+ .map((link) => typeof link === 'string' ? link : `${link.url}${link.text ? ` — ${link.text}` : ''}`)
6
+ .join('\n');
7
+ }
8
+ function renderImages(images) {
9
+ return images
10
+ .map((image) => typeof image === 'string' ? image : `${image.url}${image.alt ? ` — ${image.alt}` : ''}`)
11
+ .join('\n');
12
+ }
3
13
  export function scrapeUrlTool(server, client) {
4
14
  server.tool('scrape_url', 'Scrape a webpage and return its content. Returns markdown by default. Use the formats parameter to request additional representations (rawHtml, html, links, images).', {
5
15
  url: z.string().url().describe('The URL to scrape'),
@@ -16,15 +26,46 @@ export function scrapeUrlTool(server, client) {
16
26
  formats,
17
27
  ...(params.country !== undefined && { country: params.country }),
18
28
  });
29
+ if (result.status === 'queued') {
30
+ return {
31
+ content: [
32
+ {
33
+ type: 'text',
34
+ text: [
35
+ `ID: ${result.id}`,
36
+ 'Status: queued',
37
+ `URL: ${result.url}`,
38
+ `Status URL: ${result.status_url}`,
39
+ ].join('\n'),
40
+ },
41
+ ],
42
+ };
43
+ }
44
+ if (result.status === 'failed') {
45
+ return {
46
+ isError: true,
47
+ content: [
48
+ {
49
+ type: 'text',
50
+ text: [
51
+ `ID: ${result.id}`,
52
+ 'Status: failed',
53
+ `Error: ${result.error.code}`,
54
+ result.error.message,
55
+ ].join('\n'),
56
+ },
57
+ ],
58
+ };
59
+ }
19
60
  // Primary content for display: prefer markdown → html → rawHtml
20
- const content = result.formats.markdown ?? result.formats.html ?? result.formats.rawHtml ?? '';
61
+ const content = result.formats.markdown ?? result.formats.html ?? result.formats.raw_html ?? '';
21
62
  const { text, truncated } = truncateContent(content);
22
63
  const metaLines = [
23
- `ID: ${result.scrapeId}`,
64
+ `ID: ${result.id}`,
24
65
  `URL: ${result.url}`,
25
- result.finalUrl !== result.url ? `Final URL: ${result.finalUrl}` : null,
26
- result.statusCode !== null ? `Status Code: ${result.statusCode}` : null,
27
- result.contentType ? `Content-Type: ${result.contentType}` : null,
66
+ result.final_url !== result.url ? `Final URL: ${result.final_url}` : null,
67
+ result.status_code !== null ? `Status Code: ${result.status_code}` : null,
68
+ result.content_type ? `Content-Type: ${result.content_type}` : null,
28
69
  result.metadata.title ? `Title: ${result.metadata.title}` : null,
29
70
  truncated ? 'Note: Content was truncated to 100KB' : null,
30
71
  ]
@@ -33,12 +74,12 @@ export function scrapeUrlTool(server, client) {
33
74
  let body = `${metaLines}\n\n---\n\n${text}`;
34
75
  // Append links block when present
35
76
  if (Array.isArray(result.formats.links) && result.formats.links.length > 0) {
36
- const linkList = result.formats.links.join('\n');
77
+ const linkList = renderLinks(result.formats.links);
37
78
  body += `\n\nLinks (${result.formats.links.length}):\n${linkList}`;
38
79
  }
39
80
  // Append images block when present
40
81
  if (Array.isArray(result.formats.images) && result.formats.images.length > 0) {
41
- const imgList = result.formats.images.join('\n');
82
+ const imgList = renderImages(result.formats.images);
42
83
  body += `\n\nImages (${result.formats.images.length}):\n${imgList}`;
43
84
  }
44
85
  return {
@@ -54,4 +95,3 @@ export function scrapeUrlTool(server, client) {
54
95
  }
55
96
  });
56
97
  }
57
- //# sourceMappingURL=scrape-url.js.map
@@ -1,4 +1,3 @@
1
1
  import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
2
  import type { BytekitClient } from '../client.js';
3
3
  export declare function screenshotUrlTool(server: McpServer, client: BytekitClient): void;
4
- //# sourceMappingURL=screenshot-url.d.ts.map
@@ -56,4 +56,3 @@ export function screenshotUrlTool(server, client) {
56
56
  }
57
57
  });
58
58
  }
59
- //# sourceMappingURL=screenshot-url.js.map
@@ -1,3 +1,2 @@
1
1
  import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
2
  export declare function searchDocsTool(server: McpServer): void;
3
- //# sourceMappingURL=search-docs.d.ts.map
@@ -93,4 +93,3 @@ export function searchDocsTool(server) {
93
93
  }
94
94
  });
95
95
  }
96
- //# sourceMappingURL=search-docs.js.map
@@ -8,4 +8,3 @@ import { type BytekitClient } from '../client.js';
8
8
  * delegates to `client.search`, and shapes the response into MCP content.
9
9
  */
10
10
  export declare function webSearchTool(server: McpServer, client: BytekitClient): void;
11
- //# sourceMappingURL=web-search.d.ts.map
@@ -73,4 +73,3 @@ export function webSearchTool(server, client) {
73
73
  }
74
74
  });
75
75
  }
76
- //# sourceMappingURL=web-search.js.map
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@hunt-labs/bytekit-mcp",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
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
+ "license": "MIT",
5
6
  "type": "module",
6
7
  "publishConfig": {
7
8
  "access": "public"
@@ -21,14 +22,35 @@
21
22
  ],
22
23
  "exports": {
23
24
  ".": {
24
- "import": "./dist/index.js",
25
- "types": "./dist/index.d.ts"
25
+ "types": "./dist/index.d.ts",
26
+ "import": "./dist/index.js"
26
27
  },
27
28
  "./http": {
28
- "import": "./dist/http.js",
29
- "types": "./dist/http.d.ts"
29
+ "types": "./dist/http.d.ts",
30
+ "import": "./dist/http.js"
30
31
  }
31
32
  },
33
+ "engines": {
34
+ "node": ">=18.3"
35
+ },
36
+ "keywords": [
37
+ "bytekit",
38
+ "data-extraction",
39
+ "web-data",
40
+ "mcp",
41
+ "model-context-protocol",
42
+ "mcp-server",
43
+ "scraping",
44
+ "web-scraping",
45
+ "screenshot",
46
+ "llm",
47
+ "ai-agents",
48
+ "claude"
49
+ ],
50
+ "homepage": "https://bytekit.com/mcp/",
51
+ "bugs": {
52
+ "email": "support@bytekit.com"
53
+ },
32
54
  "dependencies": {
33
55
  "@modelcontextprotocol/sdk": "^1.12.1",
34
56
  "zod": "^3.23.6"
@@ -41,9 +63,12 @@
41
63
  "@bytekit/docs": "0.0.1"
42
64
  },
43
65
  "scripts": {
44
- "prebuild": "tsx scripts/build-docs-bundle.ts",
45
- "build": "tsc && mkdir -p dist/docs-bundle && cp src/docs-bundle/docs-bundle.json dist/docs-bundle/docs-bundle.json",
46
- "typecheck": "tsc --noEmit",
47
- "test": "vitest run"
66
+ "prebuild": "pnpm check:scrape-contract && tsx scripts/build-docs-bundle.ts",
67
+ "build": "rm -rf dist tsconfig.tsbuildinfo && tsc && mkdir -p dist/docs-bundle && cp src/docs-bundle/docs-bundle.json dist/docs-bundle/docs-bundle.json",
68
+ "typecheck": "pnpm check:scrape-contract && tsc --noEmit && tsc --noEmit -p tsconfig.scripts.json",
69
+ "test": "pnpm check:scrape-contract && vitest run && pnpm test:package",
70
+ "generate:scrape-contract": "tsx scripts/sync-scrape-contract.ts",
71
+ "check:scrape-contract": "tsx scripts/sync-scrape-contract.ts --check",
72
+ "test:package": "tsx scripts/test-package-boundary.ts"
48
73
  }
49
74
  }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=build-docs-bundle.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-docs-bundle.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/build-docs-bundle.test.ts"],"names":[],"mappings":""}
@@ -1,133 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { slugToSection, isIndexPage, slugToUrlPath, parseLlmsTxt, extractTitle, } from '../docs-bundle/helpers.js';
3
- describe('slugToSection', () => {
4
- it('maps guides/* to Guides', () => {
5
- expect(slugToSection(['guides', 'authentication'])).toBe('Guides');
6
- expect(slugToSection(['guides', 'scraping'])).toBe('Guides');
7
- });
8
- it('maps api/* to API Reference', () => {
9
- expect(slugToSection(['api', 'scrape', 'createscrape'])).toBe('API Reference');
10
- expect(slugToSection(['api', 'monitors', 'createmonitor'])).toBe('API Reference');
11
- });
12
- it('maps sdk/python/* to SDK Reference', () => {
13
- expect(slugToSection(['sdk', 'python', 'scrape'])).toBe('SDK Reference');
14
- });
15
- it('maps sdk/typescript/* to SDK Reference', () => {
16
- expect(slugToSection(['sdk', 'typescript'])).toBe('SDK Reference');
17
- });
18
- it('maps top-level pages to General', () => {
19
- expect(slugToSection(['introduction'])).toBe('General');
20
- expect(slugToSection(['quickstart'])).toBe('General');
21
- });
22
- });
23
- describe('isIndexPage', () => {
24
- it('identifies the root index page', () => {
25
- expect(isIndexPage([])).toBe(true);
26
- expect(isIndexPage(['index'])).toBe(true);
27
- });
28
- it('does not flag non-index pages', () => {
29
- expect(isIndexPage(['introduction'])).toBe(false);
30
- expect(isIndexPage(['guides', 'authentication'])).toBe(false);
31
- expect(isIndexPage(['api', 'scrape', 'createscrape'])).toBe(false);
32
- });
33
- });
34
- describe('slugToUrlPath', () => {
35
- it('joins slug parts with /', () => {
36
- expect(slugToUrlPath(['guides', 'authentication'])).toBe('guides/authentication');
37
- expect(slugToUrlPath(['api', 'scrape', 'createscrape'])).toBe('api/scrape/createscrape');
38
- });
39
- it('handles single-segment slugs', () => {
40
- expect(slugToUrlPath(['introduction'])).toBe('introduction');
41
- });
42
- });
43
- describe('parseLlmsTxt', () => {
44
- const sampleLlmsTxt = `# ByteKit Documentation
45
-
46
- > Index of all public docs pages.
47
-
48
- - ByteKit: https://bytekit.com/docs
49
- - Introduction: https://bytekit.com/docs/introduction
50
- - Quick start: https://bytekit.com/docs/quickstart
51
- - Authentication: https://bytekit.com/docs/guides/authentication
52
- - Create a scrape: https://bytekit.com/docs/api/scrape/createscrape`;
53
- it('extracts slug arrays from llms.txt content', () => {
54
- const slugs = parseLlmsTxt(sampleLlmsTxt);
55
- expect(slugs).toContainEqual(['introduction']);
56
- expect(slugs).toContainEqual(['quickstart']);
57
- expect(slugs).toContainEqual(['guides', 'authentication']);
58
- expect(slugs).toContainEqual(['api', 'scrape', 'createscrape']);
59
- });
60
- it('excludes the root /docs page (empty path)', () => {
61
- const slugs = parseLlmsTxt(sampleLlmsTxt);
62
- // Root /docs resolves to an empty afterDocs string — filtered out by parseLlmsTxt.
63
- expect(slugs).not.toContainEqual([]);
64
- });
65
- it('returns an empty array for empty input', () => {
66
- expect(parseLlmsTxt('')).toEqual([]);
67
- });
68
- it('ignores lines without a URL', () => {
69
- const text = '# header\n\nSome prose line\n- no-url-here';
70
- expect(parseLlmsTxt(text)).toEqual([]);
71
- });
72
- it('handles page titles that contain colons', () => {
73
- // llms.txt format is "- <title>: <url>". Titles can contain colons themselves
74
- // (e.g. "Authentication: API keys"). parseLlmsTxt extracts the first URL token,
75
- // making it robust against colons in titles.
76
- const text = '- Authentication: API keys: https://bytekit.com/docs/guides/authentication';
77
- const slugs = parseLlmsTxt(text);
78
- expect(slugs).toEqual([['guides', 'authentication']]);
79
- });
80
- // The #2059 llms.txt format links to the raw-markdown route (/docs/api/md/<slug>)
81
- // and appends an em-dash description: "- <title>: <md-url> — <description>".
82
- describe('#2059 md-route line format', () => {
83
- it('derives the slug from an md-route URL that carries a description', () => {
84
- const text = '- Create a scrape: https://bytekit.com/docs/api/md/api/scrape/createscrape — Scrape a URL to markdown';
85
- expect(parseLlmsTxt(text)).toEqual([['api', 'scrape', 'createscrape']]);
86
- });
87
- it('derives the slug from an md-route URL with no description', () => {
88
- const text = '- Authentication: https://bytekit.com/docs/api/md/guides/authentication';
89
- expect(parseLlmsTxt(text)).toEqual([['guides', 'authentication']]);
90
- });
91
- it('excludes the docs-index line that keeps an HTML URL', () => {
92
- // The index page (page.url === '/') has no md route, so llms.txt keeps its
93
- // HTML URL (siteUrl + basePath + '/'), which resolves to an empty slug.
94
- const text = '- ByteKit: https://bytekit.com/docs/';
95
- expect(parseLlmsTxt(text)).not.toContainEqual([]);
96
- expect(parseLlmsTxt(text)).toEqual([]);
97
- });
98
- it('parses a full #2059-format index with mixed description presence', () => {
99
- const text = [
100
- '# ByteKit Documentation',
101
- '',
102
- '> Index of all public docs pages.',
103
- '',
104
- '- ByteKit: https://bytekit.com/docs/',
105
- '- Introduction: https://bytekit.com/docs/api/md/introduction — Overview',
106
- '- Quick start: https://bytekit.com/docs/api/md/quickstart',
107
- '- Create a scrape: https://bytekit.com/docs/api/md/api/scrape/createscrape — Scrape a URL',
108
- ].join('\n');
109
- const slugs = parseLlmsTxt(text);
110
- expect(slugs).toContainEqual(['introduction']);
111
- expect(slugs).toContainEqual(['quickstart']);
112
- expect(slugs).toContainEqual(['api', 'scrape', 'createscrape']);
113
- expect(slugs).not.toContainEqual([]);
114
- // No slug should retain the md-route prefix segments.
115
- expect(slugs).not.toContainEqual(['api', 'md', 'introduction']);
116
- });
117
- });
118
- });
119
- describe('extractTitle', () => {
120
- it('extracts text from a level-1 heading', () => {
121
- expect(extractTitle('# Authentication\n\nSome content')).toBe('Authentication');
122
- });
123
- it('returns trimmed heading text', () => {
124
- expect(extractTitle('# Spaces \n\ncontent')).toBe('Spaces');
125
- });
126
- it('returns first line as-is when no heading prefix', () => {
127
- expect(extractTitle('No heading here\n\ncontent')).toBe('No heading here');
128
- });
129
- it('handles empty string', () => {
130
- expect(extractTitle('')).toBe('');
131
- });
132
- });
133
- //# sourceMappingURL=build-docs-bundle.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-docs-bundle.test.js","sourceRoot":"","sources":["../../src/__tests__/build-docs-bundle.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,aAAa,EACb,WAAW,EACX,aAAa,EACb,YAAY,EACZ,YAAY,GACb,MAAM,2BAA2B,CAAC;AAEnC,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,EAAE,CAAC,yBAAyB,EAAE,GAAG,EAAE;QACjC,MAAM,CAAC,aAAa,CAAC,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACnE,MAAM,CAAC,aAAa,CAAC,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC/D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE;QACrC,MAAM,CAAC,aAAa,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAC/E,MAAM,CAAC,aAAa,CAAC,CAAC,KAAK,EAAE,UAAU,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IACpF,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AAG,CAAC,cAAc,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC;QAClE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC9C,MAAM,CAAC,YAAY,CAAC,kCAAkC,CAAC,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAClF,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;QACtC,MAAM,CAAC,YAAY,CAAC,wBAAwB,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAChE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QACzD,MAAM,CAAC,YAAY,CAAC,4BAA4B,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAC7E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sBAAsB,EAAE,GAAG,EAAE;QAC9B,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=cli.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/cli.test.ts"],"names":[],"mappings":""}
@@ -1,41 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { resolveApiKey, API_KEY_REQUIRED_MESSAGE, HELP_TEXT } from '../cli.js';
3
- describe('resolveApiKey precedence', () => {
4
- // Covers: DoD-3 — the --api-key flag overrides BOTH env vars.
5
- it('prefers the --api-key flag over both env vars', () => {
6
- expect(resolveApiKey({ flag: 'flagkey', env: { BYTEKIT_API_KEY: 'bk', RAPIDCRAWL_API_KEY: 'rc' } })).toBe('flagkey');
7
- });
8
- // Covers: DoD-2 — BYTEKIT_API_KEY beats the legacy RAPIDCRAWL_API_KEY when no flag.
9
- it('prefers BYTEKIT_API_KEY over RAPIDCRAWL_API_KEY when no flag is given', () => {
10
- expect(resolveApiKey({ env: { BYTEKIT_API_KEY: 'bk', RAPIDCRAWL_API_KEY: 'rc' } })).toBe('bk');
11
- });
12
- // Covers: DoD-4 — inverse case: a user with only RAPIDCRAWL_API_KEY still resolves a key
13
- // (legacy fallback stays working).
14
- it('falls back to RAPIDCRAWL_API_KEY when it is the only signal', () => {
15
- expect(resolveApiKey({ env: { RAPIDCRAWL_API_KEY: 'rc' } })).toBe('rc');
16
- });
17
- it('returns undefined when no flag and no env var is set', () => {
18
- expect(resolveApiKey({ env: {} })).toBeUndefined();
19
- });
20
- it('ignores an empty-string flag and falls through to the env vars', () => {
21
- // parseArgs yields undefined for an absent flag; an explicit empty value is
22
- // not a usable key, so precedence should fall through.
23
- expect(resolveApiKey({ flag: undefined, env: { BYTEKIT_API_KEY: 'bk' } })).toBe('bk');
24
- });
25
- });
26
- describe('cli user-facing strings', () => {
27
- // Covers: DoD-2 — the "API key required" error names BYTEKIT_API_KEY (the new signal).
28
- it('error message names BYTEKIT_API_KEY', () => {
29
- expect(API_KEY_REQUIRED_MESSAGE).toContain('BYTEKIT_API_KEY');
30
- });
31
- // Covers: DoD-5 (brand) + DoD-1 (bin) — help text carries the ByteKit brand,
32
- // documents the resolution order, and names the bytekit-mcp bin. (The absence
33
- // of the legacy brand string is enforced globally by the DoD grep gate, so it
34
- // is not re-asserted here — spelling it out would itself trip the gate.)
35
- it('help text documents BYTEKIT_API_KEY, the bytekit-mcp bin, and the ByteKit brand', () => {
36
- expect(HELP_TEXT).toContain('BYTEKIT_API_KEY');
37
- expect(HELP_TEXT).toContain('bytekit-mcp');
38
- expect(HELP_TEXT).toContain('ByteKit');
39
- });
40
- });
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,EAAE,CAAC,gEAAgE,EAAE,GAAG,EAAE;QACxE,4EAA4E;QAC5E,uDAAuD;QACvD,MAAM,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxF,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACvC,uFAAuF;IACvF,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAC7C,MAAM,CAAC,wBAAwB,CAAC,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;IAChE,CAAC,CAAC,CAAC;IAEH,6EAA6E;IAC7E,8EAA8E;IAC9E,8EAA8E;IAC9E,yEAAyE;IACzE,EAAE,CAAC,iFAAiF,EAAE,GAAG,EAAE;QACzF,MAAM,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;QAC/C,MAAM,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;QAC3C,MAAM,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=client.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/client.test.ts"],"names":[],"mappings":""}