@hunt-labs/bytekit-mcp 0.1.1 → 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 +0 -1
  4. package/dist/cli.js +0 -1
  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 -73
  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
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@
4
4
  * Creates an McpServer instance with all tools, resources, and prompts registered.
5
5
  * Used by both the CLI (stdio transport) and the gateway (HTTP transport).
6
6
  */
7
+ import { createRequire } from 'node:module';
7
8
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
8
9
  // Tools
9
10
  import { scrapeUrlTool } from './tools/scrape-url.js';
@@ -21,6 +22,16 @@ import { screenshotResource } from './resources/screenshot.js';
21
22
  import { summarizeWebpagePrompt } from './prompts/summarize-webpage.js';
22
23
  import { extractStructuredDataPrompt } from './prompts/extract-structured-data.js';
23
24
  import { researchTopicPrompt } from './prompts/research-topic.js';
25
+ // Resolve the version from package.json at runtime so the handshake can never drift
26
+ // from the published manifest (issue #2419 — 0.1.1 advertised "0.1.0" because the
27
+ // literal was bumped independently of package.json). `../package.json` resolves to the
28
+ // package root from BOTH src/index.ts (dev/vitest) and dist/index.js (published
29
+ // tarball), so no build-time codegen is needed. Same pattern as packages/cli.
30
+ const require = createRequire(import.meta.url);
31
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
32
+ const pkg = require('../package.json');
33
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
34
+ const packageVersion = typeof pkg.version === 'string' ? pkg.version : '0.0.0';
24
35
  /**
25
36
  * Server identity advertised over the MCP `initialize` handshake. Exported so
26
37
  * the name/version contract is unit-testable without a live server (issue #2066;
@@ -28,7 +39,7 @@ import { researchTopicPrompt } from './prompts/research-topic.js';
28
39
  */
29
40
  export const serverInfo = {
30
41
  name: 'bytekit',
31
- version: '0.1.0',
42
+ version: packageVersion,
32
43
  };
33
44
  export function createServer(client) {
34
45
  const server = new McpServer({
@@ -55,4 +66,3 @@ export function createServer(client) {
55
66
  }
56
67
  // Re-export client for convenience
57
68
  export { BytekitClient } from './client.js';
58
- //# sourceMappingURL=index.js.map
@@ -6,4 +6,3 @@ export declare function truncateContent(text: string, maxBytes?: number, content
6
6
  text: string;
7
7
  truncated: boolean;
8
8
  };
9
- //# sourceMappingURL=truncate.d.ts.map
@@ -24,4 +24,3 @@ export function truncateContent(text, maxBytes = MAX_BYTES, contentUrl) {
24
24
  : '\n\n---\n[Content truncated at 100KB]';
25
25
  return { text: truncated + suffix, truncated: true };
26
26
  }
27
- //# sourceMappingURL=truncate.js.map
@@ -1,3 +1,2 @@
1
1
  import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
2
  export declare function extractStructuredDataPrompt(server: McpServer): void;
3
- //# sourceMappingURL=extract-structured-data.d.ts.map
@@ -28,4 +28,3 @@ export function extractStructuredDataPrompt(server) {
28
28
  ],
29
29
  }));
30
30
  }
31
- //# sourceMappingURL=extract-structured-data.js.map
@@ -1,3 +1,2 @@
1
1
  import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
2
  export declare function researchTopicPrompt(server: McpServer): void;
3
- //# sourceMappingURL=research-topic.d.ts.map
@@ -37,4 +37,3 @@ export function researchTopicPrompt(server) {
37
37
  };
38
38
  });
39
39
  }
40
- //# sourceMappingURL=research-topic.js.map
@@ -1,3 +1,2 @@
1
1
  import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
2
  export declare function summarizeWebpagePrompt(server: McpServer): void;
3
- //# sourceMappingURL=summarize-webpage.d.ts.map
@@ -25,4 +25,3 @@ export function summarizeWebpagePrompt(server) {
25
25
  ],
26
26
  }));
27
27
  }
28
- //# sourceMappingURL=summarize-webpage.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 accountResource(server: McpServer, client: BytekitClient): void;
4
- //# sourceMappingURL=account.d.ts.map
@@ -13,4 +13,3 @@ export function accountResource(server, client) {
13
13
  };
14
14
  });
15
15
  }
16
- //# sourceMappingURL=account.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 screenshotResource(server: McpServer, client: BytekitClient): void;
4
- //# sourceMappingURL=screenshot.d.ts.map
@@ -15,4 +15,3 @@ export function screenshotResource(server, client) {
15
15
  };
16
16
  });
17
17
  }
18
- //# sourceMappingURL=screenshot.js.map
@@ -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.1",
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":""}