@crawlbrulee/mcp 0.1.1 → 0.4.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.
Files changed (3) hide show
  1. package/README.md +79 -23
  2. package/dist/index.js +212 -63
  3. package/package.json +3 -3
package/README.md CHANGED
@@ -7,7 +7,7 @@ The official [Model Context Protocol](https://modelcontextprotocol.io) server fo
7
7
  - Stdio transport for terminal-based agents.
8
8
  - Strict, fully-described tool schemas — agents see what every parameter does without reading docs.
9
9
 
10
- > **Status:** v0.1.0 (beta). Tool surface is stabilizing — expect minor changes between 0.x releases.
10
+ > **Status:** v0.4.0 (beta). Tool surface is stabilizing — expect minor changes between 0.x releases.
11
11
 
12
12
  ---
13
13
 
@@ -16,7 +16,7 @@ The official [Model Context Protocol](https://modelcontextprotocol.io) server fo
16
16
  ```bash
17
17
  # Claude Code
18
18
  claude mcp add crawlbrulee \
19
- --env CRAWLBRULEE_API_KEY=cble_... \
19
+ --env CRAWLBRULEE_API_KEY=cwbl_... \
20
20
  -- npx -y @crawlbrulee/mcp
21
21
 
22
22
  # Cursor — add to ~/.cursor/mcp.json:
@@ -25,7 +25,7 @@ claude mcp add crawlbrulee \
25
25
  "crawlbrulee": {
26
26
  "command": "npx",
27
27
  "args": ["-y", "@crawlbrulee/mcp"],
28
- "env": { "CRAWLBRULEE_API_KEY": "cble_..." }
28
+ "env": { "CRAWLBRULEE_API_KEY": "cwbl_..." }
29
29
  }
30
30
  }
31
31
  }
@@ -72,11 +72,67 @@ HTML, raw HTML, links, images, screenshot, page metadata).
72
72
  }
73
73
  ```
74
74
 
75
- **Output** — full scrape result. Screenshots are returned as signed download URLs the agent can fetch separately.
75
+ **Output** — full scrape result. Page metadata (title, OG tags, etc.) is returned under `metadata`. Extracted `images` are returned as absolute URLs — query strings are preserved, and relative `src`s are resolved against the page URL. Screenshots are returned as signed download URLs the agent can fetch separately; in rare cases a screenshot can't be captured, and when that happens the `screenshot` field is simply left out while the rest of your requested outputs are still returned. The result also carries a top-level `response_meta.usage` block:
76
+
77
+ ```jsonc
78
+ {
79
+ "url": "https://example.com",
80
+ "markdown": "...",
81
+ "metadata": { "title": "Example Domain" },
82
+ "response_meta": {
83
+ "usage": {
84
+ "credits": 1, // credits charged — 0 on a cache hit
85
+ "proxy": "basic", // resolved tier actually used: "none" | "basic" | "advanced" (never "auto")
86
+ "cache_hit": false, // whether the result was served from cache
87
+ },
88
+ },
89
+ }
90
+ ```
91
+
92
+ ### `scrape_async`
93
+
94
+ Submit a scrape job to run **asynchronously** and get back a `job_id` immediately, instead of holding the connection open. Use this for long-running scrapes (heavy JS rendering, full-page screenshots of long pages); for a quick one-shot fetch prefer the synchronous `scrape` tool. Then poll `scrape_status` until the job is `done` and fetch the page with `scrape_result`.
95
+
96
+ Takes the same input as `scrape` plus an optional per-job completion `webhook`:
97
+
98
+ ```jsonc
99
+ {
100
+ "url": "https://example.com",
101
+ "extract": { "markdown": true },
102
+ "webhook": {
103
+ // Endpoint that receives one signed `scrape.complete` POST when the job
104
+ // finishes. http/https (HTTPS required in production), max 2048 chars.
105
+ "url": "https://hooks.example.com/cwbl",
106
+ // Opaque correlation object echoed back verbatim in the delivery's
107
+ // `data.metadata`. Serializes to at most 2048 bytes.
108
+ "metadata": { "ref": "order-42" },
109
+ },
110
+ }
111
+ ```
112
+
113
+ **Output** — `{ "job_id": "..." }`.
114
+
115
+ When a `webhook` is attached, crawlbrulee delivers a single signed `scrape.complete` POST to your endpoint once the job reaches a terminal state, with your `metadata` echoed under `data.metadata` and the job's usage under `data.response_meta.usage` — so you can react to completion (and reconcile cost) without polling. Verify the `X-Cwbl-Signature` header with the SDK's `verifyWebhookSignature` (configure the signing secret in the dashboard under Account → Webhooks).
116
+
117
+ ### `scrape_status`
118
+
119
+ Look up the current lifecycle status of an async job: `pending`, `running`, `done`, or `failed` (with an `error` message when failed). Once the job is `done` the response also carries a `response_meta.usage` block (`credits`, resolved `proxy` tier, `cache_hit`). Poll until `done`, then call `scrape_result`.
120
+
121
+ ```jsonc
122
+ { "job_id": "..." }
123
+ ```
124
+
125
+ ### `scrape_result`
126
+
127
+ Fetch the extracted content of a completed async job — the same result shape as the synchronous `scrape` tool (including `metadata` and `response_meta.usage`). Errors if the job is still `pending`/`running`, so check `scrape_status` first.
128
+
129
+ ```jsonc
130
+ { "job_id": "..." }
131
+ ```
76
132
 
77
133
  ### `map`
78
134
 
79
- Build (or fetch a cached) link-map for a website. Combines sitemap discovery with homepage link extraction. Use this to enumerate a site before scraping selected pages.
135
+ Build (or fetch a cached) link-map for a website. Combines sitemap discovery with homepage link extraction. Use this to enumerate a site before scraping selected pages. The response's `response_meta` carries `pagination`, `truncation`, and a `usage` block (`credits`, resolved `proxy` tier, `cache_hit`).
80
136
 
81
137
  ```jsonc
82
138
  {
@@ -109,23 +165,23 @@ Every tool returns an MCP error envelope (`isError: true`) when the API call fai
109
165
 
110
166
  Agents can branch on the `errorName` code. The set comes from the SDK's `ApiErrorName` union plus two synthetic codes added by this MCP (`missing_api_key`, `internal_error`):
111
167
 
112
- | Code | Meaning |
113
- | ------------------------ | ------------------------------------------------------------- |
114
- | `missing_api_key` | `CRAWLBRULEE_API_KEY` is not set in the MCP host's env. |
115
- | `invalid_credentials` | Server rejected the API key (revoked, wrong env, etc.). |
116
- | `too_many_requests` | Rate limit hit — back off and retry. |
117
- | `usage_allocation_error` | Plan credit / concurrency cap exceeded. Show `usage` to user. |
118
- | `validation_error` | Input failed server validation. |
119
- | `invalid_url` | Target URL was rejected before fetching. |
120
- | `blocked_url` | Target URL is on the blocklist. |
121
- | `antibot_blocked` | Origin's anti-bot defenses blocked the fetch. |
122
- | `scrape_error` | Origin returned an error during scraping. |
123
- | `not_found` | Async job ID unknown (reserved for future async tools). |
124
- | `request_timeout` | Network / read timeout. Safe to retry. |
125
- | `client_closed_request` | Caller cancelled before completion. |
126
- | `internal_server_error` | Unhandled server-side failure. |
127
- | `crawlbrulee_error` | SDK error without a typed name. |
128
- | `internal_error` | Bug in this MCP — please open an issue. |
168
+ | Code | Meaning |
169
+ | ------------------------ | ------------------------------------------------------------------------------ |
170
+ | `missing_api_key` | `CRAWLBRULEE_API_KEY` is not set in the MCP host's env. |
171
+ | `invalid_credentials` | Server rejected the API key (revoked, wrong env, etc.). |
172
+ | `too_many_requests` | Rate limit hit — back off and retry. |
173
+ | `usage_allocation_error` | Plan credit / concurrency cap exceeded. Show `usage` to user. |
174
+ | `validation_error` | Input failed server validation. |
175
+ | `invalid_url` | Target URL was rejected before fetching. |
176
+ | `blocked_url` | Target URL is on the blocklist. |
177
+ | `antibot_blocked` | Origin's anti-bot defenses blocked the fetch. |
178
+ | `scrape_error` | Origin returned an error during scraping. |
179
+ | `not_found` | Async job ID unknown (e.g. bad `job_id` to `scrape_status` / `scrape_result`). |
180
+ | `request_timeout` | Network / read timeout. Safe to retry. |
181
+ | `client_closed_request` | Caller cancelled before completion. |
182
+ | `internal_server_error` | Unhandled server-side failure. |
183
+ | `crawlbrulee_error` | SDK error without a typed name. |
184
+ | `internal_error` | Bug in this MCP — please open an issue. |
129
185
 
130
186
  ---
131
187
 
@@ -143,7 +199,7 @@ pnpm verify # all of the above
143
199
  Run the built MCP locally:
144
200
 
145
201
  ```bash
146
- CRAWLBRULEE_API_KEY=cble_... node ./dist/index.js
202
+ CRAWLBRULEE_API_KEY=cwbl_... node ./dist/index.js
147
203
  ```
148
204
 
149
205
  It will block waiting for an MCP client on stdio. Combine with the [MCP Inspector](https://github.com/modelcontextprotocol/inspector) for interactive debugging.
package/dist/index.js CHANGED
@@ -25,7 +25,7 @@ async function runTool(fn) {
25
25
  return toToolError(err);
26
26
  }
27
27
  }
28
- var MISSING_API_KEY_REMEDIATION = `${ENV_API_KEY} is not set on the MCP host. Add --env ${ENV_API_KEY}=cble_... to your "claude mcp add" command (or the equivalent env block in your MCP client config), then restart the host.`;
28
+ var MISSING_API_KEY_REMEDIATION = `${ENV_API_KEY} is not set on the MCP host. Add --env ${ENV_API_KEY}=cwbl_... to your "claude mcp add" command (or the equivalent env block in your MCP client config), then restart the host.`;
29
29
  function toToolError(err) {
30
30
  if (isCrawlbruleeError(err)) {
31
31
  if (isMissingApiKeyError(err)) {
@@ -108,13 +108,13 @@ function refineScrapeScreenshotActionsBefore(value, ctx) {
108
108
  // src/schemas/ApiScrapeRequest.ts
109
109
  var DEFAULT_API_SCRAPE_CACHE_MAX_AGE_SECONDS = 2 * 24 * 60 * 60;
110
110
  var API_PROXY_TIER_VALUES = ["basic", "advanced", "auto", "none"];
111
- var Schema_ApiProxyType = z.enum(API_PROXY_TIER_VALUES).default("basic").describe(
112
- "Proxy tier: basic, advanced, auto (automatic selection), or none (no proxy \u2014 non-production only)"
111
+ var Schema_ApiProxyType = z.enum(API_PROXY_TIER_VALUES).default("auto").describe(
112
+ "Proxy tier: basic, advanced, auto, or none (no proxy \u2014 non-production only). Defaults to auto (automatic selection: basic tier first, escalates to advanced on failure)."
113
113
  );
114
114
  var Schema_ApiScrapeViewport = z.object({
115
- width: z.number().int().nonnegative().describe("Viewport width in pixels"),
116
- height: z.number().int().nonnegative().describe("Viewport height in pixels"),
117
- device_scale_factor: z.number().nonnegative().optional().describe("Device pixel ratio (e.g. 2 for Retina)")
115
+ width: z.number().int().min(16).max(1e4).describe("Viewport width in pixels (16\u201310000)"),
116
+ height: z.number().int().min(16).max(1e4).describe("Viewport height in pixels (16\u201310000)"),
117
+ device_scale_factor: z.number().min(1).max(4).optional().describe("Device pixel ratio (1\u20134, fractional allowed; e.g. 2 for Retina). Defaults to 1.")
118
118
  }).strict().describe("Custom browser viewport dimensions");
119
119
  var Schema_ApiScrapeFormatScreenshot = z.object({
120
120
  type: Schema_ApiScrapeScreenshotType.describe("Screenshot capture mode"),
@@ -149,8 +149,11 @@ var Schema_ApiScrapeLocation = z.object({
149
149
  locale: z.string().min(2).max(35).optional().describe(
150
150
  "BCP-47 locale (2-35 chars, e.g. 'en-US', 'de-DE', 'pt-BR') driving Accept-Language and navigator.language"
151
151
  ),
152
- country: z.string().regex(/^[a-zA-Z]{2}$/, "country must be a 2-letter ISO 3166-1 alpha-2 code").optional().describe(
153
- "ISO 3166-1 alpha-2 (e.g. 'us', 'de', 'br'; case-insensitive) driving the emulated browser timezone"
152
+ country: z.string().regex(
153
+ /^([a-zA-Z]{2}|europe)$/i,
154
+ "country must be a 2-letter ISO 3166-1 alpha-2 code, 'eu', or 'europe'"
155
+ ).optional().describe(
156
+ "ISO 3166-1 alpha-2 (e.g. 'us', 'de', 'br'; case-insensitive) driving the emulated browser timezone and proxy exit country. Also accepts 'eu' (random EU member state) or 'europe' (random European state incl. UK and non-EU)."
154
157
  )
155
158
  }).strict().describe("Optional locale + country emulation for the scrape");
156
159
  var Schema_ApiScrapeRequest = z.object({
@@ -167,8 +170,11 @@ var Schema_ApiScrapeRequest = z.object({
167
170
 
168
171
  // src/schemas/ApiMapRequest.ts
169
172
  var Schema_ApiMapLocation = z.object({
170
- country: z.string().regex(/^[a-zA-Z]{2}$/, "country must be a 2-letter ISO 3166-1 alpha-2 code").optional().describe(
171
- "ISO 3166-1 alpha-2 (e.g. 'us', 'de', 'br'; case-insensitive) hint for proxy egress country"
173
+ country: z.string().regex(
174
+ /^([a-zA-Z]{2}|europe)$/i,
175
+ "country must be a 2-letter ISO 3166-1 alpha-2 code, 'eu', or 'europe'"
176
+ ).optional().describe(
177
+ "ISO 3166-1 alpha-2 (e.g. 'us', 'de', 'br'; case-insensitive) hint for proxy egress country. Also accepts 'eu' (random EU member state) or 'europe' (random European state incl. UK and non-EU)."
172
178
  )
173
179
  }).strict().describe("Optional country emulation for the map");
174
180
  var DEFAULT_API_MAP_CACHE_MAX_AGE_SECONDS = 7 * 24 * 60 * 60;
@@ -186,7 +192,7 @@ var Schema_ApiMapCache = z.object({
186
192
  }).describe("Cache settings for the map request");
187
193
  var Schema_ApiMapRequest = z.object({
188
194
  url: z.string().describe("The website URL to map"),
189
- proxy: Schema_ApiProxyType.default("basic").describe("Proxy tier to use for fetching"),
195
+ proxy: Schema_ApiProxyType.default("auto").describe("Proxy tier to use for fetching"),
190
196
  sitemap_only: z.boolean().default(false).describe("Only use sitemap.xml \u2014 skip homepage link extraction"),
191
197
  types: Schema_ApiMapTypes.optional().describe("Filter which link types to include"),
192
198
  cache: Schema_ApiMapCache.optional().describe("Cache settings for this request"),
@@ -195,50 +201,6 @@ var Schema_ApiMapRequest = z.object({
195
201
  limit: z.number().int().positive().max(MAX_API_MAP_PAGE_LIMIT).default(DEFAULT_API_MAP_PAGE_LIMIT).describe("Number of URLs to return per page"),
196
202
  location: Schema_ApiMapLocation.optional()
197
203
  });
198
- var Schema_ApiMapLinkItem = z.object({
199
- url: z.string().describe("The discovered URL")
200
- });
201
- var Schema_ApiMapPagination = z.object({
202
- page: z.number().int().positive().describe("Current page number"),
203
- limit: z.number().int().positive().describe("Number of items per page"),
204
- total: z.number().int().nonnegative().describe("Total number of URLs in the map"),
205
- total_pages: z.number().int().nonnegative().describe("Total number of pages available"),
206
- has_more: z.boolean().describe("Whether more pages are available")
207
- });
208
- var Schema_ApiMapTruncation = z.object({
209
- storage_capped: z.boolean().describe("Whether the stored map was capped by the max_urls limit"),
210
- response_capped: z.boolean().describe("Whether the response was capped by pagination"),
211
- total_before_max_urls: z.number().int().nonnegative().describe("Total URLs found before applying the max_urls cap"),
212
- total_detected_before_storage_cap: z.number().int().nonnegative().describe("Total URLs detected during discovery before the storage cap was applied")
213
- });
214
- var Schema_ApiMapResult = z.object({
215
- links: z.array(Schema_ApiMapLinkItem).describe("List of discovered URLs for the current page"),
216
- meta: z.object({
217
- pagination: Schema_ApiMapPagination.describe("Pagination details for the result set"),
218
- truncation: Schema_ApiMapTruncation.describe(
219
- "Information about whether the results were truncated"
220
- )
221
- }).describe("Response metadata including pagination and truncation info")
222
- });
223
-
224
- // src/tools/map.ts
225
- var DESCRIPTION = [
226
- "Build (or fetch a cached) link-map for a website by combining sitemap discovery with homepage",
227
- "link extraction. Returns paginated lists of discovered URLs. Filterable by link type",
228
- "(internal / external / subdomain). Use this to enumerate a site before scraping selected pages."
229
- ].join(" ");
230
- function registerMapTool(server, getClient) {
231
- server.registerTool(
232
- "map",
233
- {
234
- title: "Map a website",
235
- description: DESCRIPTION,
236
- inputSchema: Schema_ApiMapRequest.shape,
237
- outputSchema: Schema_ApiMapResult.shape
238
- },
239
- (args) => runTool(async () => await getClient().map(args))
240
- );
241
- }
242
204
  var Schema_ApiViewport = z.object({
243
205
  width: z.number().describe("Viewport width in pixels"),
244
206
  height: z.number().describe("Viewport height in pixels"),
@@ -272,6 +234,19 @@ var Schema_ApiPageLink = z.object({
272
234
  href: z.string().describe("The link URL as it appears on the page (absolute or relative)"),
273
235
  internal: z.boolean().describe("Whether the link points to the same domain")
274
236
  });
237
+ var API_RESOLVED_PROXY_TIER_VALUES = ["none", "basic", "advanced"];
238
+ var Schema_ApiUsageMeta = z.object({
239
+ credits: z.number().int().nonnegative().describe("Credits charged for this request. `0` on a cache hit (no fresh fetch was billed)."),
240
+ proxy: z.enum(API_RESOLVED_PROXY_TIER_VALUES).describe(
241
+ "The proxy tier the request actually ran on (resolved value \u2014 never `auto`; `auto` is resolved server-side to `none`, `basic`, or `advanced`)."
242
+ ),
243
+ cache_hit: z.boolean().describe("Whether the result was served from cache (`true`) or freshly fetched (`false`).")
244
+ });
245
+ var Schema_ApiResponseMeta = z.object({
246
+ usage: Schema_ApiUsageMeta.describe(
247
+ "Usage accounting for this request: credits charged, resolved proxy tier, and cache-hit flag."
248
+ )
249
+ });
275
250
  var Schema_ApiScrapeMeta = z.object({
276
251
  title: z.string().optional().describe("Page title from the <title> tag"),
277
252
  description: z.string().optional().describe("Meta description"),
@@ -313,15 +288,76 @@ var Schema_ApiScrapeSuccessResponse = z.object({
313
288
  ),
314
289
  warnings: z.array(z.string()).optional().describe(
315
290
  "Non-error notices about the scrape (e.g. `screenshot_truncated` when a long page exceeded the scrolling-screenshot height cap). Stable string codes \u2014 clients can switch on them. Currently surfaced only on fresh scrapes; cache hits omit warnings."
291
+ ),
292
+ response_meta: Schema_ApiResponseMeta.describe(
293
+ "Request-level metadata. `response_meta.usage` reports credits charged (0 on a cache hit), the resolved proxy tier, and the cache-hit flag."
316
294
  )
317
295
  });
318
296
 
297
+ // src/schemas/ApiMapResponse.ts
298
+ var Schema_ApiMapLinkItem = z.object({
299
+ url: z.string().describe("The discovered URL")
300
+ });
301
+ var Schema_ApiMapPagination = z.object({
302
+ page: z.number().int().positive().describe("Current page number"),
303
+ limit: z.number().int().positive().describe("Number of items per page"),
304
+ total: z.number().int().nonnegative().describe("Total number of URLs in the map"),
305
+ total_pages: z.number().int().nonnegative().describe("Total number of pages available"),
306
+ has_more: z.boolean().describe("Whether more pages are available")
307
+ });
308
+ var Schema_ApiMapTruncation = z.object({
309
+ storage_capped: z.boolean().describe("Whether the stored map was capped by the max_urls limit"),
310
+ response_capped: z.boolean().describe("Whether the response was capped by pagination"),
311
+ total_before_max_urls: z.number().int().nonnegative().describe("Total URLs found before applying the max_urls cap"),
312
+ total_detected_before_storage_cap: z.number().int().nonnegative().describe("Total URLs detected during discovery before the storage cap was applied")
313
+ });
314
+ var Schema_ApiMapResult = z.object({
315
+ links: z.array(Schema_ApiMapLinkItem).describe("List of discovered URLs for the current page"),
316
+ response_meta: z.object({
317
+ pagination: Schema_ApiMapPagination.describe("Pagination details for the result set"),
318
+ truncation: Schema_ApiMapTruncation.describe(
319
+ "Information about whether the results were truncated"
320
+ ),
321
+ usage: Schema_ApiUsageMeta.describe(
322
+ "Usage accounting for this map request: credits charged (0 on a cache hit), the resolved proxy tier, and the cache-hit flag."
323
+ )
324
+ }).describe("Response metadata including pagination, truncation, and usage info")
325
+ });
326
+
327
+ // src/tools/map.ts
328
+ var DESCRIPTION = [
329
+ "Build (or fetch a cached) link-map for a website by combining sitemap discovery with homepage",
330
+ "link extraction. Returns paginated lists of discovered URLs. Filterable by link type",
331
+ "(internal / external / subdomain). Use this to enumerate a site before scraping selected pages."
332
+ ].join(" ");
333
+ function registerMapTool(server, getClient) {
334
+ server.registerTool(
335
+ "map",
336
+ {
337
+ title: "Map a website",
338
+ description: DESCRIPTION,
339
+ inputSchema: Schema_ApiMapRequest.shape,
340
+ outputSchema: Schema_ApiMapResult.shape
341
+ },
342
+ (args) => (
343
+ // The vendored response schema tracks the new wire contract: the envelope is
344
+ // `response_meta` (with a `usage` block), whereas the published SDK's `MapResponse`
345
+ // type still has the older `meta` envelope (no `usage`). The field is both renamed
346
+ // and widened, so a plain cast won't type-check — bridge through `unknown` until the
347
+ // SDK catches up. The runtime payload already matches the vendored shape.
348
+ runTool(async () => await getClient().map(args))
349
+ )
350
+ );
351
+ }
352
+
319
353
  // src/tools/scrape.ts
320
354
  var DESCRIPTION2 = [
321
355
  "Fetch a single URL via the crawlbrulee scraping API and return the requested content",
322
- "(markdown, cleaned HTML, raw HTML, links, images, screenshot, page metadata).",
356
+ "(markdown, cleaned HTML, raw HTML, links, images, screenshot, page metadata in `metadata`).",
323
357
  "Use this for one-shot page extraction. For full-site discovery use the `map` tool first.",
324
- "Screenshot URLs in the response are signed download links \u2014 the agent can fetch them when needed."
358
+ "Screenshot URLs in the response are signed download links \u2014 the agent can fetch them when needed.",
359
+ "The response also carries `response_meta.usage` = { credits (0 on a cache hit), proxy (the resolved",
360
+ "tier \u2014 never `auto`), cache_hit } so you can see what the request cost."
325
361
  ].join(" ");
326
362
  function registerScrapeTool(server, getClient) {
327
363
  server.registerTool(
@@ -335,6 +371,116 @@ function registerScrapeTool(server, getClient) {
335
371
  (args) => runTool(async () => await getClient().scrape(args))
336
372
  );
337
373
  }
374
+ var Schema_AsyncScrapeWebhook = z.object({
375
+ url: z.string().url().max(2048).describe(
376
+ "Endpoint that receives a single signed POST when the job reaches a terminal state. Must be an http/https URL (HTTPS is required in production) of at most 2048 characters. The body is a `scrape.complete` envelope signed with your organization webhook secret on the X-Cwbl-Signature header."
377
+ ),
378
+ metadata: z.record(z.string(), z.unknown()).optional().describe(
379
+ "Opaque correlation object echoed verbatim in the webhook payload\u2019s data.metadata. Must serialize to at most 2048 bytes (UTF-8 JSON). Use it to route deliveries without keeping your own job_id mapping."
380
+ )
381
+ }).strict().describe("Optional per-job completion webhook delivered when this async job finishes");
382
+ var Schema_ApiScrapeAsyncRequest = Schema_ApiScrapeRequest.extend({
383
+ webhook: Schema_AsyncScrapeWebhook.optional().describe(
384
+ "Completion webhook delivered when this async job finishes. Async-only: the synchronous `scrape` tool does not accept it."
385
+ )
386
+ });
387
+ var ASYNC_JOB_STATUS_VALUES = ["pending", "running", "done", "failed"];
388
+ var Schema_AsyncJobId = z.object({
389
+ job_id: z.string().describe("Job identifier returned by the `scrape_async` tool")
390
+ });
391
+ var Schema_ApiScrapeAsyncResponse = z.object({
392
+ job_id: z.string().describe("Job identifier \u2014 pass it to the `scrape_status` / `scrape_result` tools")
393
+ });
394
+ var Schema_ApiScrapeStatusResponse = z.object({
395
+ job_id: z.string().describe("The job identifier"),
396
+ status: z.enum(ASYNC_JOB_STATUS_VALUES).describe("Current state of the job (pending, running, done, failed)"),
397
+ created_at: z.string().describe("ISO-8601 UTC timestamp when the job was created"),
398
+ error: z.string().optional().describe("Error message if the job ended in `failed`"),
399
+ response_meta: Schema_ApiResponseMeta.optional().describe(
400
+ "Usage accounting for the finished job. Present only once the job is `done`; `response_meta.usage` reports credits charged (0 on a cache hit), the resolved proxy tier, and the cache-hit flag."
401
+ )
402
+ });
403
+
404
+ // src/tools/scrapeAsync.ts
405
+ var DESCRIPTION3 = [
406
+ "Submit a scrape job to run ASYNCHRONOUSLY and return a `job_id` immediately,",
407
+ "instead of holding the connection open. Use this for long-running scrapes",
408
+ "(heavy JS rendering, full-page screenshots of long pages) \u2014 for a quick one-shot",
409
+ "fetch prefer the synchronous `scrape` tool, which blocks and returns the page directly.",
410
+ "Poll the job with `scrape_status` and fetch the page with `scrape_result` once done.",
411
+ "Optionally attach a per-job completion `webhook`: crawlbrulee delivers a single",
412
+ "signed `scrape.complete` POST to your endpoint when the job finishes (HTTPS required",
413
+ "in production), and echoes your opaque `webhook.metadata` back in the delivery",
414
+ "(under `data.metadata`, alongside `data.response_meta.usage`)."
415
+ ].join(" ");
416
+ function registerScrapeAsyncTool(server, getClient) {
417
+ server.registerTool(
418
+ "scrape_async",
419
+ {
420
+ title: "Scrape a URL asynchronously",
421
+ description: DESCRIPTION3,
422
+ inputSchema: Schema_ApiScrapeAsyncRequest.shape,
423
+ outputSchema: Schema_ApiScrapeAsyncResponse.shape
424
+ },
425
+ (args) => runTool(
426
+ async () => await getClient().scrapeAsync(args)
427
+ )
428
+ );
429
+ }
430
+
431
+ // src/tools/scrapeResult.ts
432
+ var DESCRIPTION4 = [
433
+ "Fetch the extracted content of a completed async scrape job (the same result shape as the",
434
+ "synchronous `scrape` tool: markdown, cleaned HTML, raw HTML, links, images, screenshot,",
435
+ "page metadata in `metadata`, and `response_meta.usage`). Errors if the job is still",
436
+ "`pending`/`running` \u2014 check `scrape_status` first (status `done`) before calling this.",
437
+ "Screenshot URLs are signed download links."
438
+ ].join(" ");
439
+ function registerScrapeResultTool(server, getClient) {
440
+ server.registerTool(
441
+ "scrape_result",
442
+ {
443
+ title: "Get an async scrape job result",
444
+ description: DESCRIPTION4,
445
+ inputSchema: Schema_AsyncJobId.shape,
446
+ outputSchema: Schema_ApiScrapeSuccessResponse.shape
447
+ },
448
+ (args) => runTool(
449
+ async () => await getClient().getScrapeResult(args.job_id)
450
+ )
451
+ );
452
+ }
453
+
454
+ // src/tools/scrapeStatus.ts
455
+ var DESCRIPTION5 = [
456
+ "Look up the current lifecycle status of an async scrape job submitted via `scrape_async`.",
457
+ "Returns the job state (`pending`, `running`, `done`, `failed`), with an `error` message",
458
+ "when it failed and a `response_meta.usage` block (credits, resolved proxy tier, cache_hit) once it is",
459
+ "`done`. Poll this until the status is `done`, then call `scrape_result` to fetch",
460
+ "the page. If you registered a completion webhook on submit you can skip polling and react",
461
+ "to the delivery instead."
462
+ ].join(" ");
463
+ function registerScrapeStatusTool(server, getClient) {
464
+ server.registerTool(
465
+ "scrape_status",
466
+ {
467
+ title: "Check an async scrape job status",
468
+ description: DESCRIPTION5,
469
+ inputSchema: Schema_AsyncJobId.shape,
470
+ outputSchema: Schema_ApiScrapeStatusResponse.shape
471
+ },
472
+ (args) => (
473
+ // The vendored status schema tracks the live wire contract, which has been
474
+ // uniformly snake_case (job_id, created_at) since 2026-06-13. The published
475
+ // SDK's `AsyncJobStatusResponse` type still encodes the pre-June camelCase
476
+ // names, so a plain cast won't type-check — bridge through `unknown` until
477
+ // the SDK catches up. The runtime payload already matches the vendored shape.
478
+ runTool(
479
+ async () => await getClient().getScrapeStatus(args.job_id)
480
+ )
481
+ )
482
+ );
483
+ }
338
484
  var Schema_ApiUsageResponse = z.object({
339
485
  total_credits: z.number().int().nonnegative().describe(
340
486
  "Total credits available for the current billing cycle (plan base + purchased + gifted)."
@@ -357,7 +503,7 @@ var Schema_ApiUsageResponse = z.object({
357
503
  });
358
504
 
359
505
  // src/tools/usage.ts
360
- var DESCRIPTION3 = [
506
+ var DESCRIPTION6 = [
361
507
  "Return the current billing-cycle usage for the authenticated organization:",
362
508
  "total / used / available credits, used quota percent, max concurrency, and cycle reset time.",
363
509
  "Call this before launching large scrape jobs to confirm available credit."
@@ -367,7 +513,7 @@ function registerUsageTool(server, getClient) {
367
513
  "usage",
368
514
  {
369
515
  title: "Get current usage",
370
- description: DESCRIPTION3,
516
+ description: DESCRIPTION6,
371
517
  inputSchema: {},
372
518
  outputSchema: Schema_ApiUsageResponse.shape
373
519
  },
@@ -378,12 +524,12 @@ var Schema_ApiWhoamiResponse = z.object({
378
524
  organization_name: z.string().describe("Display name of the organization that owns the token."),
379
525
  token_name: z.string().describe("User-assigned name of the API token authenticating the request."),
380
526
  token_preview: z.string().describe(
381
- "Truncated preview of the API token (e.g. `cble_\u2026xyz`). Safe to display; does not authenticate."
527
+ "Truncated preview of the API token (e.g. `cwbl_\u2026xyz`). Safe to display; does not authenticate."
382
528
  )
383
529
  });
384
530
 
385
531
  // src/tools/whoami.ts
386
- var DESCRIPTION4 = [
532
+ var DESCRIPTION7 = [
387
533
  "Return the organization name, token name, and truncated token preview for the API key",
388
534
  "currently configured on the MCP server. Useful for confirming which account is in use",
389
535
  "before performing credit-consuming operations."
@@ -393,7 +539,7 @@ function registerWhoamiTool(server, getClient) {
393
539
  "whoami",
394
540
  {
395
541
  title: "Identify the API token",
396
- description: DESCRIPTION4,
542
+ description: DESCRIPTION7,
397
543
  inputSchema: {},
398
544
  outputSchema: Schema_ApiWhoamiResponse.shape
399
545
  },
@@ -403,12 +549,15 @@ function registerWhoamiTool(server, getClient) {
403
549
 
404
550
  // src/version.ts
405
551
  var SERVER_NAME = "crawlbrulee";
406
- var SERVER_VERSION = "0.1.0";
552
+ var SERVER_VERSION = "0.3.0";
407
553
 
408
554
  // src/server.ts
409
555
  function buildServer(clientFactory = createDefaultClientFactory()) {
410
556
  const server = new McpServer({ name: SERVER_NAME, version: SERVER_VERSION });
411
557
  registerScrapeTool(server, clientFactory);
558
+ registerScrapeAsyncTool(server, clientFactory);
559
+ registerScrapeStatusTool(server, clientFactory);
560
+ registerScrapeResultTool(server, clientFactory);
412
561
  registerMapTool(server, clientFactory);
413
562
  registerUsageTool(server, clientFactory);
414
563
  registerWhoamiTool(server, clientFactory);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crawlbrulee/mcp",
3
- "version": "0.1.1",
3
+ "version": "0.4.0",
4
4
  "description": "Official MCP server for the crawlbrulee API — scrape and map URLs from MCP-aware agents (Claude Code, Codex, Cursor).",
5
5
  "keywords": [
6
6
  "crawlbrulee",
@@ -55,7 +55,7 @@
55
55
  "prepublishOnly": "pnpm verify"
56
56
  },
57
57
  "dependencies": {
58
- "@crawlbrulee/sdk": "^0.1.0",
58
+ "@crawlbrulee/sdk": "^0.6.0",
59
59
  "@modelcontextprotocol/sdk": "^1.29.0",
60
60
  "zod": "^4.0.0"
61
61
  },
@@ -67,6 +67,6 @@
67
67
  "tsup": "^8.3.0",
68
68
  "typescript": "^5.7.0",
69
69
  "typescript-eslint": "^8.20.0",
70
- "vitest": "^2.1.0"
70
+ "vitest": "^3.2.6"
71
71
  }
72
72
  }