@crawlbrulee/mcp 0.10.0 → 0.12.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 +29 -3
  2. package/dist/index.js +67 -23
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -13,7 +13,7 @@ the official [mcp](https://modelcontextprotocol.io) server for the [crawlbrulee]
13
13
  this readme covers the mcp server itself — its tools and how to wire it into a host. for how the api behaves — endpoints, parameters, and error semantics — please see our
14
14
  [api docs](https://crawlbrulee.com/docs).
15
15
 
16
- > **status:** v0.10.0 (beta). tool surface is stabilizing — expect minor changes between 0.x releases.
16
+ > **status:** v0.12.0 (beta). tool surface is stabilizing — expect minor changes between 0.x releases.
17
17
 
18
18
  **get a free api key** → [dashboard.crawlbrulee.com](https://dashboard.crawlbrulee.com)
19
19
 
@@ -75,7 +75,7 @@ html, raw html, links, images, screenshot, page metadata).
75
75
  },
76
76
  "require_js": false,
77
77
  "proxy": "basic",
78
- "exclude_selectors": ["nav", "footer"],
78
+ "cleanup": { "ads_and_popups": true, "exclude_selectors": ["nav", "footer"] },
79
79
  "cache": { "max_age": 3600 },
80
80
  "location": { "locale": "en-US", "country": "US" },
81
81
  }
@@ -158,7 +158,13 @@ fetch the extracted content of a completed async job — the same result shape a
158
158
 
159
159
  ### `map`
160
160
 
161
- 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`, billed `engine`, resolved `proxy` tier). map responses do not include screenshot-slice accounting.
161
+ 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. each link is just `{ url }`.
162
+
163
+ `max_urls` (default `5000`, max `100000`) is a discovery budget, not a trim at the end — discovery stops as soon as that many urls are found, so a smaller value is a faster, cheaper crawl. `limit` (default `5000`, max `10000`) only pages the answer.
164
+
165
+ returned urls are normalized the same way `scrape` normalizes its returned `url`, so map-then-scrape stays on one host. results are ordered with the most useful links first.
166
+
167
+ the response's `response_meta` carries `pagination`, `truncation`, and a `usage` block (`credits`, billed `engine`, resolved `proxy` tier). map responses do not include screenshot-slice accounting.
162
168
 
163
169
  ```jsonc
164
170
  {
@@ -171,6 +177,24 @@ build (or fetch a cached) link-map for a website. combines sitemap discovery wit
171
177
  }
172
178
  ```
173
179
 
180
+ a map stopped by your own `max_urls` returns exactly that many links with `response_capped: false` — the signal that the site has more is `truncation.discovery_cap_reason`:
181
+
182
+ ```jsonc
183
+ {
184
+ "truncation": {
185
+ "storage_capped": false,
186
+ "response_capped": false,
187
+ "total_before_max_urls": 5000,
188
+ "total_detected_before_storage_cap": 5000,
189
+ "discovery_capped": true, // discovery stopped before reading every sitemap file
190
+ "sitemaps_skipped": 3, // files skipped or only partly read
191
+ "discovery_cap_reason": "max_urls", // retry with a higher max_urls; other reasons won't help
192
+ },
193
+ }
194
+ ```
195
+
196
+ `discovery_cap_reason` is one of `max_urls`, `time`, `file_budget`, `depth`, `file_size`, or `null` when nothing stopped discovery. only `max_urls` is worth a retry — the rest mean the site itself is big, slow or deep.
197
+
174
198
  see the [map endpoint](https://crawlbrulee.com/docs/map) for discovery rules and pagination semantics.
175
199
 
176
200
  ### `usage`
@@ -204,6 +228,8 @@ agents can branch on the `errorName` code. the set comes from the sdk's `ApiErro
204
228
  | `invalid_url` | target url was rejected before fetching. |
205
229
  | `blocked_url` | target url is on the blocklist. |
206
230
  | `antibot_blocked` | origin's anti-bot defenses blocked the fetch. |
231
+ | `too_many_redirects` | origin redirected the fetch in a loop (HTTP 422). the target's doing — don't retry blindly. |
232
+ | `page_too_large` | the page's html was too large to process (HTTP 422). terminal — never retry it. |
207
233
  | `scrape_error` | origin returned an error during scraping. |
208
234
  | `unsupported_screenshot_output` | screenshot-only request on a content type that can't be screenshotted (HTTP 422). not billed. |
209
235
  | `not_found` | async job ID unknown (e.g. bad `job_id` to `scrape_status` / `scrape_result`). |
package/dist/index.js CHANGED
@@ -84,7 +84,6 @@ function textErrorResult(text) {
84
84
  const MAX_SCRAPE_SCREENSHOT_TOTAL_WAIT_MS = 2e4;
85
85
  const MAX_SCRAPE_SCREENSHOT_TOTAL_SCROLL_PIXELS = 5e4;
86
86
  const DEFAULT_SCRAPE_SCREENSHOT_DEVICE_MODE = "desktop";
87
- const DEFAULT_SCRAPE_SCREENSHOT_CLEANUP = { ads_and_popups: true };
88
87
  function getScrapeScreenshotBeforeActionTotals(actions) {
89
88
  let totalWaitMs = 0;
90
89
  let totalAbsoluteScrollPixels = 0;
@@ -101,11 +100,25 @@ function getScrapeScreenshotBeforeActionTotals(actions) {
101
100
  };
102
101
  }
103
102
 
103
+ //#endregion
104
+ //#region src/schemas/ScrapeCleanupSchemas.ts
105
+ /**
106
+ * Mirrors `packages/core/src/model/common/ScrapeCleanup*` in the server repo.
107
+ * Kept in step by hand — this package deliberately does not import from the
108
+ * monorepo. If the server's shape changes, change it here too.
109
+ */
110
+ const DEFAULT_SCRAPE_CLEANUP = { ads_and_popups: true };
111
+ const MAX_SCRAPE_EXCLUDE_SELECTORS = 100;
112
+ const MAX_SCRAPE_EXCLUDE_SELECTOR_LENGTH = 500;
113
+ const Schema_ApiScrapeCleanup = z.object({
114
+ ads_and_popups: z.boolean().default(DEFAULT_SCRAPE_CLEANUP.ads_and_popups).describe("Remove ads, cookie banners, consent dialogs and chat widgets. Defaults to true. Also affects the screenshot. Set it to false to capture the page as-is, or to get past a site that refuses to serve an ad-blocking client."),
115
+ exclude_selectors: z.array(z.string().max(500)).max(100).optional().describe("CSS selectors whose elements are removed before anything is captured. Affects the extracted content and the screenshot, never raw_html. Use it for a banner or widget that ads_and_popups does not recognise. Sending any selector here makes the request skip the cache.")
116
+ }).strict().describe("What is removed from the page before any output is built. Applies to markdown, cleaned_html, links and images on every engine, and to the screenshot. Never applies to raw_html, which is always the page before we removed anything.");
117
+
104
118
  //#endregion
105
119
  //#region src/schemas/ScrapeScreenshotSchemas.ts
106
120
  const Schema_ApiScrapeScreenshotType = z.enum(["viewport", "full_page"]).describe("Screenshot mode: viewport (visible area) or full_page (entire page)");
107
121
  const Schema_ScrapeScreenshotDeviceMode = z.enum(["desktop", "mobile"]).describe("Device mode to emulate for viewport sizing");
108
- const Schema_ScrapeScreenshotCleanup = z.object({ ads_and_popups: z.boolean().default(DEFAULT_SCRAPE_SCREENSHOT_CLEANUP.ads_and_popups).describe("Remove ads, cookie banners, and popups before capturing") }).strict().describe("Page cleanup options applied before screenshot capture");
109
122
  const Schema_ScrapeScreenshotBeforeAction = z.discriminatedUnion("type", [z.object({
110
123
  type: z.literal("wait").describe("Wait for a duration before capturing"),
111
124
  ms: z.number().int().nonnegative().describe("Milliseconds to wait")
@@ -149,7 +162,6 @@ const Schema_ApiScrapeFormatScreenshot = z.object({
149
162
  type: Schema_ApiScrapeScreenshotType.describe("Screenshot capture mode"),
150
163
  viewport: Schema_ApiScrapeViewport.optional().describe("Custom viewport dimensions; uses device_mode defaults if omitted"),
151
164
  device_mode: Schema_ScrapeScreenshotDeviceMode.default(DEFAULT_SCRAPE_SCREENSHOT_DEVICE_MODE).describe("Emulate desktop or mobile device viewport"),
152
- cleanup: Schema_ScrapeScreenshotCleanup.default(DEFAULT_SCRAPE_SCREENSHOT_CLEANUP).describe("Page cleanup options applied before capturing"),
153
165
  actions_before: z.array(Schema_ScrapeScreenshotBeforeAction).max(5).default([]).describe("Actions to perform before taking the screenshot (wait, scroll)"),
154
166
  actions_after: z.array(Schema_ScrapeScreenshotAfterAction).max(1).default([]).describe("Actions to perform after taking the screenshot (e.g. slice into tiles)")
155
167
  }).strict().superRefine(refineScrapeScreenshotActionsBefore).describe("Screenshot capture configuration");
@@ -168,11 +180,11 @@ const Schema_ApiScrapeLocation = z.object({
168
180
  country: z.string().regex(/^([a-zA-Z]{2}|europe)$/i, "country must be a 2-letter ISO 3166-1 alpha-2 code, 'eu', or 'europe'").optional().describe("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).")
169
181
  }).strict().describe("Optional locale + country emulation for the scrape");
170
182
  const Schema_ApiScrapeRequest = z.object({
171
- url: z.string().describe("The URL to scrape. Known tracking parameters (utm_*, mtm_*, ga_*, pk_*, gclid, fbclid, msclkid, and others) are removed before the page is fetched, so they are neither sent to the target site nor part of the cache key. Every other query parameter is kept verbatim and is part of the cache key."),
183
+ url: z.string().describe("The URL to scrape. Known tracking parameters are removed before the page is fetched, so they are neither sent to the target site nor part of the cache key. Every other query parameter is kept verbatim and is part of the cache key."),
172
184
  extract: Schema_ApiScrapeExtract.prefault({}).describe("Which content formats to extract. Defaults to metadata + cleaned_html."),
173
185
  cache: Schema_ApiScrapeCache.optional().describe("Cache settings for this request"),
174
186
  require_js: z.boolean().default(false).describe("Use a headless browser to render JavaScript before scraping"),
175
- exclude_selectors: z.array(z.string()).optional().describe("CSS selectors to exclude from the extracted content"),
187
+ cleanup: Schema_ApiScrapeCleanup.prefault({ ...DEFAULT_SCRAPE_CLEANUP }),
176
188
  proxy: Schema_ApiProxyType.describe("Proxy tier to use for fetching"),
177
189
  location: Schema_ApiScrapeLocation.optional()
178
190
  }).strict();
@@ -181,31 +193,45 @@ const Schema_ApiScrapeRequest = z.object({
181
193
  //#region src/schemas/ApiMapRequest.ts
182
194
  const Schema_ApiMapLocation = z.object({ country: z.string().regex(/^([a-zA-Z]{2}|europe)$/i, "country must be a 2-letter ISO 3166-1 alpha-2 code, 'eu', or 'europe'").optional().describe("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).") }).strict().describe("Optional country emulation for the map");
183
195
  const DEFAULT_API_MAP_CACHE_MAX_AGE_SECONDS = 10080 * 60;
184
- const DEFAULT_API_MAP_MAX_URLS = 1e5;
196
+ /**
197
+ * How many URLs a /map call discovers and stores when the caller names no
198
+ * limit. Sitemap discovery stops here, so the default is real crawl work, not
199
+ * a slice taken at the end — 5000 covers the whole site for the great majority
200
+ * of roots while keeping an unparameterised call cheap and fast.
201
+ */
202
+ const DEFAULT_API_MAP_MAX_URLS = 5e3;
185
203
  const MAX_API_MAP_MAX_URLS = 1e5;
186
- const DEFAULT_API_MAP_PAGE_LIMIT = 1e4;
204
+ const DEFAULT_API_MAP_PAGE_LIMIT = 5e3;
187
205
  const MAX_API_MAP_PAGE_LIMIT = 1e4;
188
206
  const Schema_ApiMapTypes = z.object({
189
- internal: z.boolean().default(true).describe("Include internal links (same domain)"),
190
- internal_subdomains: z.boolean().default(true).describe("Include links to subdomains of the target domain"),
207
+ internal: z.boolean().default(true).describe("Include internal links (same domain; www and the bare domain are equivalent)"),
208
+ internal_subdomains: z.boolean().default(true).describe("Include links to subdomains of the target domain (other than www)"),
191
209
  external: z.boolean().default(true).describe("Include external links (different domains)")
192
210
  }).describe("Filter which link types to include in the map");
193
211
  const Schema_ApiMapCache = z.object({ max_age: z.union([z.number().int().nonnegative(), z.iso.datetime()]).default(DEFAULT_API_MAP_CACHE_MAX_AGE_SECONDS).describe("Maximum cache age in seconds, or an ISO 8601 datetime cutoff") }).describe("Cache settings for the map request");
194
212
  const Schema_ApiMapRequest = z.object({
195
- url: z.string().describe("The website URL to map. Mapping always targets the site root, so the path, query string and fragment are dropped; known tracking parameters (utm_*, mtm_*, ga_*, pk_*, gclid, fbclid, msclkid, and others) are removed before the request is processed."),
213
+ url: z.string().describe("The website URL to map. Mapping always targets the site root, so the path, query string and fragment are dropped; known tracking parameters are removed before the request is processed."),
196
214
  proxy: Schema_ApiProxyType.default("auto").describe("Proxy tier to use for fetching"),
197
215
  sitemap_only: z.boolean().default(false).describe("Only use sitemap.xml — skip homepage link extraction"),
198
216
  types: Schema_ApiMapTypes.optional().describe("Filter which link types to include"),
199
217
  cache: Schema_ApiMapCache.optional().describe("Cache settings for this request"),
200
- max_urls: z.number().int().positive().max(MAX_API_MAP_MAX_URLS).default(DEFAULT_API_MAP_MAX_URLS).describe("Maximum number of URLs to store in the map"),
218
+ max_urls: z.number().int().positive().max(MAX_API_MAP_MAX_URLS).default(DEFAULT_API_MAP_MAX_URLS).describe("Maximum number of URLs to discover and store in the map. Default 5000, maximum 100000. Sitemap discovery stops as soon as this many URLs have been found, so a smaller value is a faster and lighter crawl, not just a smaller answer."),
201
219
  page: z.number().int().positive().default(1).describe("Page number for paginated results"),
202
- 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"),
220
+ 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. Default 5000, maximum 10000."),
203
221
  location: Schema_ApiMapLocation.optional()
204
222
  });
205
223
 
206
224
  //#endregion
207
225
  //#region src/schemas/ApiMapResponse.ts
208
226
  const API_RESOLVED_PROXY_TIER_VALUES$1 = ["basic", "advanced"];
227
+ /** Which limit stopped sitemap discovery first. The FIRST limit to fire wins. */
228
+ const DISCOVERY_CAP_REASONS = [
229
+ "max_urls",
230
+ "time",
231
+ "file_budget",
232
+ "depth",
233
+ "file_size"
234
+ ];
209
235
  /** Map usage has no screenshot-slice add-on. */
210
236
  const Schema_ApiMapUsageMeta = z.object({
211
237
  credits: z.number().int().nonnegative().describe("Credits charged for this map request"),
@@ -221,10 +247,13 @@ const Schema_ApiMapPagination = z.object({
221
247
  has_more: z.boolean().describe("Whether more pages are available")
222
248
  });
223
249
  const Schema_ApiMapTruncation = z.object({
224
- storage_capped: z.boolean().describe("Whether the stored map was capped by the max_urls limit"),
225
- response_capped: z.boolean().describe("Whether the response was capped by pagination"),
250
+ storage_capped: z.boolean().describe("Whether the stored map hit the 100000-URL storage cap."),
251
+ response_capped: z.boolean().describe("Whether more links were eligible than max_urls, so the list was trimmed. Discovery itself stops at max_urls, so this is normally true only when home-page links pushed the total past it. See discovery_cap_reason for a discovery stop."),
226
252
  total_before_max_urls: z.number().int().nonnegative().describe("Total URLs found before applying the max_urls cap"),
227
- total_detected_before_storage_cap: z.number().int().nonnegative().describe("Total URLs detected during discovery before the storage cap was applied")
253
+ total_detected_before_storage_cap: z.number().int().nonnegative().describe("Total URLs detected during discovery before the storage cap was applied"),
254
+ discovery_capped: z.boolean().describe("Whether sitemap discovery stopped before it had read every sitemap file it found. When true, the site has more pages than this map lists."),
255
+ sitemaps_skipped: z.number().int().nonnegative().describe("How many sitemap files were skipped or only partly read during discovery, because a file was too large, could not be fetched, or the discovery limits were reached."),
256
+ discovery_cap_reason: z.enum(DISCOVERY_CAP_REASONS).nullable().describe("Which limit stopped sitemap discovery first, or null when nothing stopped it. \"max_urls\" means your own max_urls was reached — ask again with a higher one to get more. \"time\" means discovery ran out of its time budget, \"file_budget\" that the site has more sitemap files than one request reads, \"depth\" that its sitemap indexes nest too deeply, and \"file_size\" that a sitemap file was too large to read. Only \"max_urls\" is something you can change from the request.")
228
257
  });
229
258
  const Schema_ApiMapResult = z.object({
230
259
  links: z.array(Schema_ApiMapLinkItem).describe("List of discovered URLs for the current page"),
@@ -239,8 +268,19 @@ const Schema_ApiMapResult = z.object({
239
268
  //#region src/tools/map.ts
240
269
  const DESCRIPTION$6 = [
241
270
  "Build (or fetch a cached) link-map for a website by combining sitemap discovery with homepage",
242
- "link extraction. Returns paginated lists of discovered URLs. Filterable by link type",
243
- "(internal / external / subdomain). Use this to enumerate a site before scraping selected pages.",
271
+ "link extraction. Returns paginated lists of discovered URLs, each item just { url }.",
272
+ "Filterable by link type (internal / external / subdomain). Use this to enumerate a site before",
273
+ "scraping selected pages.",
274
+ "`max_urls` (default 5000, max 100000) is a discovery budget, not a trim at the end: discovery",
275
+ "stops as soon as that many URLs are found, so a smaller value is a faster, cheaper crawl.",
276
+ "A map stopped that way returns exactly `max_urls` links with `response_capped` false — the",
277
+ "signal that the site has more is `response_meta.truncation.discovery_cap_reason`. When that is",
278
+ "\"max_urls\", ask again with a higher `max_urls` to get more; \"time\", \"file_budget\", \"depth\" and",
279
+ "\"file_size\" mean the site itself is big, slow or deep and a retry will not help. `discovery_capped`",
280
+ "says discovery stopped early, `sitemaps_skipped` how many sitemap files were skipped or only",
281
+ "partly read. `limit` (default 5000, max 10000) only pages the answer.",
282
+ "Returned URLs are normalized the same way `scrape` normalizes its returned `url`, so",
283
+ "map-then-scrape stays on one host. Results are ordered with the most useful links first.",
244
284
  "The response carries `response_meta.usage` = { credits, engine, proxy } — the resolved proxy",
245
285
  "tier is never `auto`; map responses do not include screenshot-slice accounting."
246
286
  ].join(" ");
@@ -326,7 +366,7 @@ const Schema_ApiScrapeMeta = z.object({
326
366
  favicon_url: z.string().nullish().describe("Resolved favicon URL for the page (best-effort, from <head> icon hints + manifest)")
327
367
  });
328
368
  const Schema_ApiScrapeSuccessResponse = z.object({
329
- url: z.string().describe("The URL that was actually scraped, after any redirects, in cleaned canonical form (tracking params and fragment removed) — the base that links, images, and internal labels are computed against"),
369
+ url: z.string().describe("The URL that was actually scraped, after any redirects, in normalized form — the base that links, images, and internal labels are computed against"),
330
370
  requested_url: z.string().describe("The URL you requested, echoed verbatim — before any redirects"),
331
371
  content_type: z.string().optional().describe("Content-Type header returned by the server"),
332
372
  unsupported_fields: z.array(z.string()).optional().describe("Extract fields that were requested but are not supported for this content type"),
@@ -352,10 +392,14 @@ const DESCRIPTION$5 = [
352
392
  "never `auto`), screenshot_slices }. `engine` is the billed engine (`text`, `browser`, `screenshot`,",
353
393
  "`cache`); a cache hit is represented by `engine: \"cache\"`.",
354
394
  "so you can see what the request cost.",
355
- "Extraction is capped per page: 30,000 links, 10,000 inline images, 10,000,000 characters of body",
356
- "HTML and 2,000,000 characters of head HTML. A page past a cap is truncated rather than refused,",
357
- "and the response `warnings` array names which one (`links_truncated`, `inline_images_truncated`,",
358
- "`raw_html_truncated`, `metadata_truncated`) — so treat that output as incomplete.",
395
+ "Extraction is capped per page: 30,000 links, 10,000 inline images and 10,000,000 characters of",
396
+ "HTML. A page past a cap is truncated rather than refused, and the response `warnings` array names",
397
+ "which one (`links_truncated`, `inline_images_truncated`, `raw_html_truncated`) — so treat that",
398
+ "output as incomplete.",
399
+ "Use `cleanup` to control what is removed before any output is built: `ads_and_popups` (on by",
400
+ "default) drops ads, cookie banners and chat widgets, and `exclude_selectors` removes anything",
401
+ "else. It shapes markdown, cleaned_html, links, images and the screenshot, and NEVER `raw_html` —",
402
+ "so request `raw_html` when you need the page exactly as it arrived.",
359
403
  "`warnings` also reports a section whose extraction failed outright (`links_unavailable`,",
360
404
  "`inline_images_unavailable`, `metadata_unavailable`): that field comes back omitted or empty",
361
405
  "while the rest of the scrape succeeded, so do NOT conclude the page had no links/images/metadata",
@@ -510,7 +554,7 @@ function registerWhoamiTool(server, getClient) {
510
554
  //#endregion
511
555
  //#region src/version.ts
512
556
  const SERVER_NAME = "crawlbrulee";
513
- const SERVER_VERSION = "0.10.0";
557
+ const SERVER_VERSION = "0.12.0";
514
558
 
515
559
  //#endregion
516
560
  //#region src/server.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crawlbrulee/mcp",
3
- "version": "0.10.0",
3
+ "version": "0.12.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.12.0",
58
+ "@crawlbrulee/sdk": "^0.15.0",
59
59
  "@modelcontextprotocol/sdk": "^1.29.0",
60
60
  "zod": "^4.0.0"
61
61
  },