alterlab-mcp-server 1.7.0 → 1.9.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.
- package/README.md +75 -33
- package/dist/auth.d.ts +30 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +423 -0
- package/dist/auth.js.map +1 -0
- package/dist/client.d.ts +23 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +61 -3
- package/dist/client.js.map +1 -1
- package/dist/config.d.ts +21 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +85 -8
- package/dist/config.js.map +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +6 -4
- package/dist/errors.js.map +1 -1
- package/dist/format.d.ts +20 -2
- package/dist/format.d.ts.map +1 -1
- package/dist/format.js +187 -9
- package/dist/format.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +66 -2
- package/dist/index.js.map +1 -1
- package/dist/tools/balance.d.ts.map +1 -1
- package/dist/tools/balance.js +4 -2
- package/dist/tools/balance.js.map +1 -1
- package/dist/tools/batch.d.ts +1221 -25
- package/dist/tools/batch.d.ts.map +1 -1
- package/dist/tools/batch.js +123 -34
- package/dist/tools/batch.js.map +1 -1
- package/dist/tools/common.d.ts +313 -0
- package/dist/tools/common.d.ts.map +1 -0
- package/dist/tools/common.js +336 -0
- package/dist/tools/common.js.map +1 -0
- package/dist/tools/crawl.d.ts +165 -10
- package/dist/tools/crawl.d.ts.map +1 -1
- package/dist/tools/crawl.js +191 -43
- package/dist/tools/crawl.js.map +1 -1
- package/dist/tools/estimate.d.ts +21 -6
- package/dist/tools/estimate.d.ts.map +1 -1
- package/dist/tools/estimate.js +28 -35
- package/dist/tools/estimate.js.map +1 -1
- package/dist/tools/extract.d.ts +5 -5
- package/dist/tools/extract.d.ts.map +1 -1
- package/dist/tools/extract.js +16 -12
- package/dist/tools/extract.js.map +1 -1
- package/dist/tools/job.d.ts +13 -0
- package/dist/tools/job.d.ts.map +1 -0
- package/dist/tools/job.js +62 -0
- package/dist/tools/job.js.map +1 -0
- package/dist/tools/map.d.ts +5 -2
- package/dist/tools/map.d.ts.map +1 -1
- package/dist/tools/map.js +16 -5
- package/dist/tools/map.js.map +1 -1
- package/dist/tools/scrape.d.ts +431 -49
- package/dist/tools/scrape.d.ts.map +1 -1
- package/dist/tools/scrape.js +267 -135
- package/dist/tools/scrape.js.map +1 -1
- package/dist/tools/screenshot.d.ts +33 -0
- package/dist/tools/screenshot.d.ts.map +1 -1
- package/dist/tools/screenshot.js +60 -10
- package/dist/tools/screenshot.js.map +1 -1
- package/dist/tools/search.d.ts +11 -5
- package/dist/tools/search.d.ts.map +1 -1
- package/dist/tools/search.js +22 -6
- package/dist/tools/search.js.map +1 -1
- package/dist/tools/sessions.d.ts +180 -12
- package/dist/tools/sessions.d.ts.map +1 -1
- package/dist/tools/sessions.js +75 -21
- package/dist/tools/sessions.js.map +1 -1
- package/dist/tools/simple_batch.d.ts +28 -0
- package/dist/tools/simple_batch.d.ts.map +1 -0
- package/dist/tools/simple_batch.js +142 -0
- package/dist/tools/simple_batch.js.map +1 -0
- package/dist/tools/usage.d.ts +7 -0
- package/dist/tools/usage.d.ts.map +1 -0
- package/dist/tools/usage.js +42 -0
- package/dist/tools/usage.js.map +1 -0
- package/dist/types.d.ts +219 -21
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +5 -3
- package/server.json +40 -4
package/dist/tools/scrape.js
CHANGED
|
@@ -1,53 +1,63 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.scrapeDescription = exports.scrapeSchema = void 0;
|
|
4
|
+
exports.buildScrapeRequest = buildScrapeRequest;
|
|
5
|
+
exports.buildEstimateRequest = buildEstimateRequest;
|
|
4
6
|
exports.handleScrape = handleScrape;
|
|
5
7
|
const zod_1 = require("zod");
|
|
6
8
|
const errors_js_1 = require("../errors.js");
|
|
7
9
|
const format_js_1 = require("../format.js");
|
|
10
|
+
const common_js_1 = require("./common.js");
|
|
8
11
|
exports.scrapeSchema = zod_1.z.object({
|
|
9
|
-
url: zod_1.z.string().url().describe("URL to scrape"),
|
|
12
|
+
url: zod_1.z.string().url().max(2083).describe("URL to scrape"),
|
|
10
13
|
method: zod_1.z
|
|
11
|
-
.enum(["GET", "POST"
|
|
14
|
+
.enum(["GET", "POST"])
|
|
12
15
|
.default("GET")
|
|
13
16
|
.describe("HTTP method for the request. Default GET (standard page scraping). " +
|
|
14
|
-
"Use POST for GraphQL endpoints, form submissions, REST API calls. " +
|
|
15
|
-
"
|
|
16
|
-
"When using POST/PUT/PATCH, provide body with the request payload."),
|
|
17
|
+
"Use POST for GraphQL endpoints, form submissions, and REST API calls. " +
|
|
18
|
+
"When using POST, provide body with the request payload. POST costs 1.5x base tier price."),
|
|
17
19
|
body: zod_1.z
|
|
18
20
|
.string()
|
|
19
21
|
.optional()
|
|
20
|
-
.describe("Request body for POST
|
|
22
|
+
.describe("Request body for POST requests. " +
|
|
21
23
|
"For GraphQL: JSON string with 'query' and optional 'variables' fields " +
|
|
22
24
|
'(e.g., \'{"query": "{ user { id name } }"}\').' +
|
|
23
25
|
"For REST APIs: JSON-encoded payload string. " +
|
|
24
26
|
"For form submissions: URL-encoded key=value pairs (e.g., 'name=Alice&email=alice@example.com'). " +
|
|
25
|
-
"Omit for GET
|
|
26
|
-
|
|
27
|
-
.
|
|
27
|
+
"Omit for GET requests."),
|
|
28
|
+
content_type: common_js_1.contentTypeEnum
|
|
29
|
+
.optional()
|
|
30
|
+
.describe("Content-Type header for the request body. " +
|
|
31
|
+
"Defaults to 'application/json' when body is provided. " +
|
|
32
|
+
"Use 'application/graphql' for raw GraphQL queries. " +
|
|
33
|
+
"Use 'application/x-www-form-urlencoded' for HTML form submissions. " +
|
|
34
|
+
"Requires body to be set."),
|
|
35
|
+
headers: zod_1.z
|
|
36
|
+
.record(zod_1.z.string(), zod_1.z.string())
|
|
37
|
+
.optional()
|
|
38
|
+
.describe("Custom HTTP headers to send to the target URL. " +
|
|
39
|
+
"Hop-by-hop headers (Connection, Transfer-Encoding, Host, etc.) are not allowed."),
|
|
40
|
+
mode: common_js_1.modeEnum
|
|
28
41
|
.default("auto")
|
|
29
42
|
.describe("Scraping mode: auto (recommended), html, js (headless browser), pdf, or ocr"),
|
|
30
43
|
formats: zod_1.z
|
|
31
|
-
.array(
|
|
44
|
+
.array(common_js_1.allFormatEnum)
|
|
32
45
|
.default(["markdown"])
|
|
33
|
-
.describe("Output formats.
|
|
34
|
-
"'json_v2' returns a structured section tree (headings + content blocks). " +
|
|
35
|
-
"'rag' returns chunked text optimized for retrieval-augmented generation. " +
|
|
36
|
-
"'content' returns body_markdown + content_hash + images + links for AI/KB pipelines."),
|
|
46
|
+
.describe("Output formats. " + common_js_1.FORMATS_DESCRIPTION),
|
|
37
47
|
extraction_schema: zod_1.z
|
|
38
48
|
.record(zod_1.z.unknown())
|
|
39
49
|
.optional()
|
|
40
50
|
.describe("JSON schema for structured extraction. " +
|
|
41
|
-
"The API extracts fields matching this schema from the scraped page using LLM. " +
|
|
42
|
-
"Result is returned in
|
|
51
|
+
"The API extracts fields matching this schema from the scraped page using LLM (+$0.001). " +
|
|
52
|
+
"Result is returned in extraction_result. " +
|
|
43
53
|
'Example: { "title": "string", "price": "number", "in_stock": "boolean" }'),
|
|
44
54
|
extraction_model: zod_1.z
|
|
45
55
|
.string()
|
|
56
|
+
.max(256)
|
|
46
57
|
.nullish()
|
|
47
58
|
.describe("Per-request LLM model override in provider-specific format (e.g. 'gpt-4o', 'claude-opus-4-5-20251101', 'llama3-70b-8192'). " +
|
|
48
59
|
"Overrides the model saved in your BYOK key settings for this request only."),
|
|
49
|
-
extraction_provider:
|
|
50
|
-
.enum(["openai", "anthropic", "openrouter", "groq"])
|
|
60
|
+
extraction_provider: common_js_1.extractionProviderEnum
|
|
51
61
|
.optional()
|
|
52
62
|
.describe("LLM provider to use for extraction. Selects the matching BYOK key registered at " +
|
|
53
63
|
"/dashboard/settings/llm-keys. When omitted, the most recently used registered key " +
|
|
@@ -59,179 +69,301 @@ exports.scrapeSchema = zod_1.z.object({
|
|
|
59
69
|
.describe("Natural language extraction instruction. Describes what fields to extract from the page. " +
|
|
60
70
|
"Mutually exclusive with extraction_schema. " +
|
|
61
71
|
'Example: "Extract the product name, price, and availability".'),
|
|
62
|
-
extraction_profile:
|
|
63
|
-
.enum([
|
|
64
|
-
"auto",
|
|
65
|
-
"product",
|
|
66
|
-
"article",
|
|
67
|
-
"job_posting",
|
|
68
|
-
"faq",
|
|
69
|
-
"recipe",
|
|
70
|
-
"event",
|
|
71
|
-
"ecommerce_homepage",
|
|
72
|
-
"directory_listing",
|
|
73
|
-
])
|
|
72
|
+
extraction_profile: common_js_1.extractionProfileEnum
|
|
74
73
|
.optional()
|
|
75
74
|
.describe("Pre-built extraction schema template. " +
|
|
76
|
-
"auto: detect best template. product: e-commerce product details. " +
|
|
75
|
+
"auto: detect best template (API default). product: e-commerce product details. " +
|
|
77
76
|
"article: news/blog article fields. job_posting: job listing fields. " +
|
|
78
77
|
"faq: FAQ entries. recipe: recipe ingredients and instructions. " +
|
|
79
78
|
"event: event details. ecommerce_homepage: homepage product listings. " +
|
|
80
|
-
"directory_listing: directory/listing page entries."
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
.default(false)
|
|
84
|
-
.describe("Render JavaScript using headless browser (forces Tier 4 minimum — no separate add-on charge). " +
|
|
85
|
-
"Required for JS-heavy sites. Set to 'auto' for smart detection (probes each page, " +
|
|
86
|
-
"only renders JS-heavy pages with browser — saves 30-60% on mixed sites)."),
|
|
87
|
-
use_proxy: zod_1.z
|
|
88
|
-
.boolean()
|
|
89
|
-
.default(false)
|
|
90
|
-
.describe("Route through premium proxy (+$0.0002). Helps bypass geo-restrictions and anti-bot"),
|
|
91
|
-
proxy_country: zod_1.z
|
|
92
|
-
.string()
|
|
79
|
+
"directory_listing: directory/listing page entries. " +
|
|
80
|
+
"Mutually exclusive with extraction_template."),
|
|
81
|
+
extraction_template: common_js_1.extractionProfileEnum
|
|
93
82
|
.optional()
|
|
94
|
-
.describe("
|
|
95
|
-
|
|
83
|
+
.describe("Shorthand alias for extraction_profile — selects the same pre-built template. " +
|
|
84
|
+
"Mutually exclusive with extraction_profile."),
|
|
85
|
+
template: zod_1.z
|
|
96
86
|
.string()
|
|
97
87
|
.optional()
|
|
98
|
-
.describe("
|
|
99
|
-
|
|
88
|
+
.describe("DEPRECATED alias for extraction_template, kept for backward compatibility. " +
|
|
89
|
+
"Sent to the API as extraction_template; prefer extraction_template."),
|
|
90
|
+
evidence: zod_1.z
|
|
91
|
+
.boolean()
|
|
92
|
+
.optional()
|
|
93
|
+
.describe("Include provenance/evidence snippets alongside extracted fields. " +
|
|
94
|
+
"Each extracted value will include the source text passage it was derived from. " +
|
|
95
|
+
"Requires extraction_schema or extraction_prompt."),
|
|
96
|
+
filter_content: zod_1.z
|
|
97
|
+
.boolean()
|
|
98
|
+
.optional()
|
|
99
|
+
.describe("Apply quality filtering to extracted content. When false (default), returns all parsed content " +
|
|
100
|
+
"without quality thresholds (lossless mode). When true, filters low-quality boilerplate."),
|
|
101
|
+
promote_schema_org: zod_1.z
|
|
102
|
+
.boolean()
|
|
103
|
+
.optional()
|
|
104
|
+
.describe("Use Schema.org JSON-LD/Microdata as the primary structured-data source when present (API default true). " +
|
|
105
|
+
"Promotes machine-readable metadata embedded in the page over LLM extraction. " +
|
|
106
|
+
"Most effective on e-commerce, recipe, and news article pages."),
|
|
107
|
+
cache: zod_1.z
|
|
108
|
+
.boolean()
|
|
109
|
+
.optional()
|
|
110
|
+
.describe("Enable caching for this request. When true, repeat requests with identical parameters may " +
|
|
111
|
+
"return cached results. Only use for idempotent requests (GET pages, read-only POSTs)."),
|
|
112
|
+
cache_ttl: zod_1.z
|
|
100
113
|
.number()
|
|
101
|
-
.
|
|
102
|
-
.
|
|
103
|
-
.
|
|
104
|
-
.
|
|
114
|
+
.int()
|
|
115
|
+
.min(60)
|
|
116
|
+
.max(86400)
|
|
117
|
+
.optional()
|
|
118
|
+
.describe("Cache TTL in seconds (60–86400). Defaults to 3600 (60 min) when cache=true. " +
|
|
119
|
+
"Requires cache=true."),
|
|
120
|
+
force_refresh: zod_1.z
|
|
121
|
+
.boolean()
|
|
122
|
+
.optional()
|
|
123
|
+
.describe("Bypass the cache and always fetch a fresh copy of the page. " +
|
|
124
|
+
"Use when you need real-time content and a cached result would be stale."),
|
|
125
|
+
include_raw_html: zod_1.z
|
|
126
|
+
.boolean()
|
|
127
|
+
.default(false)
|
|
128
|
+
.describe("Include raw HTML in the response alongside formatted content"),
|
|
105
129
|
max_response_bytes: zod_1.z
|
|
106
130
|
.number()
|
|
107
131
|
.int()
|
|
108
132
|
.min(0)
|
|
109
133
|
.max(52_428_800)
|
|
110
|
-
.default(5_242_880)
|
|
111
134
|
.optional()
|
|
112
135
|
.describe("Soft cap on raw response body size in bytes. " +
|
|
113
136
|
"When the downloaded HTML exceeds this value it is truncated before extraction. " +
|
|
114
137
|
"Default: 5 MB (5242880). Set to 0 for no limit. Maximum: 50 MB (52428800). " +
|
|
115
138
|
"Useful for very large pages where you only need the beginning of the content."),
|
|
116
|
-
|
|
117
|
-
.boolean()
|
|
118
|
-
.default(false)
|
|
119
|
-
.describe("Include raw HTML in the response alongside formatted content"),
|
|
120
|
-
session_id: zod_1.z
|
|
121
|
-
.string()
|
|
122
|
-
.uuid()
|
|
123
|
-
.optional()
|
|
124
|
-
.describe("UUID of a stored session for authenticated scraping. " +
|
|
125
|
-
"Use alterlab_list_sessions to find available sessions. " +
|
|
126
|
-
"The session's cookies will be injected into the request."),
|
|
127
|
-
cookies: zod_1.z
|
|
128
|
-
.record(zod_1.z.string(), zod_1.z.string())
|
|
129
|
-
.optional()
|
|
130
|
-
.describe("Inline cookies as key-value pairs for authenticated scraping " +
|
|
131
|
-
'(e.g., {"session_token": "abc123"}). ' +
|
|
132
|
-
"Use this for one-off requests; use session_id for reusable sessions."),
|
|
133
|
-
scroll_to_load: zod_1.z
|
|
134
|
-
.boolean()
|
|
135
|
-
.default(false)
|
|
136
|
-
.describe("Scroll page to trigger lazy-loaded content (requires render_js). " +
|
|
137
|
-
"Performs explicit viewport-height scrolls to load dynamic content. Adds ~2-3s latency."),
|
|
138
|
-
scroll_count: zod_1.z
|
|
139
|
+
timeout: zod_1.z
|
|
139
140
|
.number()
|
|
140
141
|
.int()
|
|
141
142
|
.min(1)
|
|
142
|
-
.max(
|
|
143
|
-
.default(
|
|
143
|
+
.max(300)
|
|
144
|
+
.default(90)
|
|
145
|
+
.describe("Request timeout in seconds (1-300)"),
|
|
146
|
+
wait_for: zod_1.z
|
|
147
|
+
.string()
|
|
144
148
|
.optional()
|
|
145
|
-
.describe("
|
|
146
|
-
|
|
149
|
+
.describe("CSS selector to wait for before extracting content (e.g., '#main-content')"),
|
|
150
|
+
wait_until: zod_1.z
|
|
151
|
+
.string()
|
|
152
|
+
.optional()
|
|
153
|
+
.describe("Page load event to wait for before extracting (networkidle, domcontentloaded or load; API default networkidle)"),
|
|
154
|
+
screenshot: zod_1.z
|
|
147
155
|
.boolean()
|
|
148
|
-
.
|
|
149
|
-
.describe("
|
|
150
|
-
|
|
156
|
+
.optional()
|
|
157
|
+
.describe("Capture a full-page screenshot (+$0.0002, requires render_js). The URL is returned as screenshot_url. " +
|
|
158
|
+
"Use alterlab_screenshot to get the image inline."),
|
|
159
|
+
enable_scroll: zod_1.z
|
|
151
160
|
.boolean()
|
|
152
|
-
.
|
|
153
|
-
.describe("
|
|
154
|
-
"
|
|
155
|
-
|
|
161
|
+
.nullish()
|
|
162
|
+
.describe("Force scrolling for lazy-load images. true: always scroll (+5-10s), false: never scroll, " +
|
|
163
|
+
"omit: auto (scroll unless social media site)."),
|
|
164
|
+
pdf_format: zod_1.z
|
|
165
|
+
.string()
|
|
166
|
+
.optional()
|
|
167
|
+
.describe("Output format for mode='pdf' extraction (API default 'markdown')"),
|
|
168
|
+
ocr_language: zod_1.z
|
|
169
|
+
.string()
|
|
170
|
+
.optional()
|
|
171
|
+
.describe("Tesseract language code for OCR (API default 'eng')"),
|
|
172
|
+
sync_policy: zod_1.z
|
|
173
|
+
.enum(["auto", "wait_until_deadline"])
|
|
174
|
+
.optional()
|
|
175
|
+
.describe("Synchronous wait policy. 'auto' (default) may return an early 202 with a job_id for predicted T3/T4 jobs; " +
|
|
176
|
+
"'wait_until_deadline' keeps the connection open until the terminal result or the safe sync deadline (~85s)."),
|
|
177
|
+
embeddings: zod_1.z
|
|
156
178
|
.object({
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
.
|
|
160
|
-
.optional()
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
language: zod_1.z
|
|
164
|
-
.string()
|
|
165
|
-
.min(2)
|
|
166
|
-
.max(5)
|
|
167
|
-
.optional()
|
|
168
|
-
.describe("ISO 639-1 language code (e.g., 'en', 'de', 'ja'). " +
|
|
169
|
-
"Sets the Accept-Language header and browser locale."),
|
|
179
|
+
enabled: zod_1.z.boolean().optional(),
|
|
180
|
+
model: zod_1.z
|
|
181
|
+
.enum(["text-embedding-3-small", "text-embedding-3-large"])
|
|
182
|
+
.optional(),
|
|
183
|
+
chunk_size: zod_1.z.number().int().min(64).max(8191).optional(),
|
|
184
|
+
chunk_overlap: zod_1.z.number().int().min(0).max(2048).optional(),
|
|
170
185
|
})
|
|
171
186
|
.optional()
|
|
172
|
-
.describe("
|
|
173
|
-
"
|
|
187
|
+
.describe("Chunk the scraped text and embed it with OpenAI models (+$0.001 per page). " +
|
|
188
|
+
"Set enabled=true; model, chunk_size (64-8191) and chunk_overlap (0-2048) are optional."),
|
|
189
|
+
...common_js_1.advancedShape,
|
|
190
|
+
location: common_js_1.locationSchema.optional(),
|
|
191
|
+
prefer_cost: zod_1.z
|
|
192
|
+
.boolean()
|
|
193
|
+
.optional()
|
|
194
|
+
.describe("Optimize for lowest cost — try cheaper tiers first before escalating. " +
|
|
195
|
+
"Shorthand for cost_controls.prefer_cost. Mutually exclusive intent with prefer_speed."),
|
|
196
|
+
prefer_speed: zod_1.z
|
|
197
|
+
.boolean()
|
|
198
|
+
.optional()
|
|
199
|
+
.describe("Optimize for speed — skip to a reliable tier immediately instead of escalating from Tier 1. " +
|
|
200
|
+
"Shorthand for cost_controls.prefer_speed. Mutually exclusive intent with prefer_cost."),
|
|
201
|
+
fail_fast: zod_1.z
|
|
202
|
+
.boolean()
|
|
203
|
+
.optional()
|
|
204
|
+
.describe("Fail immediately if the page requires an expensive tier (browser/captcha) instead of auto-escalating. " +
|
|
205
|
+
"Shorthand for cost_controls.fail_fast. Returns an error with the required tier instead of upgrading."),
|
|
206
|
+
cost_controls: common_js_1.costControlsSchema.optional(),
|
|
207
|
+
estimate_first: zod_1.z
|
|
208
|
+
.boolean()
|
|
209
|
+
.default(false)
|
|
210
|
+
.describe("Run a cost estimate before scraping and include it in the response. " +
|
|
211
|
+
"Adds one lightweight API call (~50ms) with no credit charge. " +
|
|
212
|
+
"The estimated tier, cost, and confidence are prepended to the scrape result. " +
|
|
213
|
+
"Useful for unfamiliar or potentially expensive sites — see cost before committing."),
|
|
174
214
|
});
|
|
175
|
-
exports.scrapeDescription = "
|
|
176
|
-
"
|
|
215
|
+
exports.scrapeDescription = "Get data from any website, bypass Cloudflare and anti-bot protection, scrape JavaScript-rendered pages, " +
|
|
216
|
+
"or fetch content from dynamic single-page apps. " +
|
|
217
|
+
"Turn any URL into clean, LLM-ready markdown — or get text, HTML, JSON, and structured sections. " +
|
|
218
|
+
"Automatically bypasses anti-bot protection (Cloudflare, Akamai, DataDome, PerimeterX, hCaptcha) " +
|
|
219
|
+
"with intelligent tier escalation — no manual configuration needed. " +
|
|
220
|
+
"Cost-efficient: tier 1 (curl) is $0.0002/page, tier 2 (http) $0.0003, tier 3 (stealth) $0.002, " +
|
|
221
|
+
"tier 3.5 (lightjs) $0.0025, tier 4 (browser) $0.004; you only pay for the tier that succeeds. " +
|
|
222
|
+
"Add-ons: screenshot +$0.0002, generate_pdf +$0.0004, ocr +$0.001, use_proxy +$0.0002, " +
|
|
223
|
+
"LLM extraction +$0.001, embeddings +$0.001; method='POST' costs 1.5x. " +
|
|
177
224
|
"Returns markdown by default — optimized for LLM context. " +
|
|
178
|
-
"Supports GET (default) and POST
|
|
225
|
+
"Supports GET (default) and POST via the method parameter. " +
|
|
179
226
|
"Use method='POST' with body for GraphQL APIs, REST endpoints, and form submissions. " +
|
|
180
|
-
"
|
|
181
|
-
"Use
|
|
227
|
+
"Use content_type to set the POST body Content-Type (json, urlencoded, graphql, plain). " +
|
|
228
|
+
"Use headers to send custom HTTP headers to the target. " +
|
|
229
|
+
"Use render_js=true to scrape dynamic pages, JavaScript-heavy sites (React, Angular, Vue, SPAs). " +
|
|
182
230
|
"Use render_js='auto' for mixed sites to detect JS needs per-page (saves 30-60%). " +
|
|
183
|
-
"Use
|
|
231
|
+
"Use actions (click, fill, press, scroll, wait_for, evaluate, ...) to drive the page before extraction. " +
|
|
232
|
+
"Use use_proxy=true for geo-restricted or heavily protected sites; use_own_proxy for your own proxy integration. " +
|
|
233
|
+
"Use sticky_session to reuse cookies and exit IP across calls. " +
|
|
234
|
+
"Use skip_tls_verification only for sites with broken certificates. " +
|
|
184
235
|
"Use formats=['json_v2'] for a structured section tree (headings + content blocks). " +
|
|
185
236
|
"Use formats=['rag'] for chunked text optimized for RAG pipelines. " +
|
|
237
|
+
"Use formats=['raw'] for the raw response body without extraction. " +
|
|
186
238
|
"Use formats=['content'] for AI/KB pipelines — returns body_markdown, content_hash, images, links. " +
|
|
187
|
-
"Use extraction_schema to extract structured fields from the page using LLM
|
|
188
|
-
"Use extraction_prompt for natural language extraction instructions
|
|
189
|
-
"Use extraction_profile
|
|
190
|
-
"Use
|
|
191
|
-
"
|
|
192
|
-
"Use
|
|
193
|
-
"Use
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
239
|
+
"Use extraction_schema to extract structured fields from the page using LLM. " +
|
|
240
|
+
"Use extraction_prompt for natural language extraction instructions. " +
|
|
241
|
+
"Use extraction_profile or extraction_template for pre-built templates (product, article, job_posting, etc.). " +
|
|
242
|
+
"Use evidence=true to include source passages alongside extracted fields. " +
|
|
243
|
+
"Use embeddings to chunk and embed the scraped text. " +
|
|
244
|
+
"Use cache=true and cache_ttl to enable response caching. " +
|
|
245
|
+
"Use cost_controls to cap spending, pin a tier, or set a time budget. " +
|
|
246
|
+
"Supports authenticated scraping via session_id, inline cookies or session_headers. " +
|
|
247
|
+
"Use scroll_to_load=true for infinite-scroll pages. " +
|
|
248
|
+
"Use location.country to scrape geo-targeted content from any region. " +
|
|
249
|
+
"Use prefer_cost=true to minimize credit spend (starts from cheapest tier). " +
|
|
250
|
+
"Use prefer_speed=true to skip to a fast reliable tier immediately. " +
|
|
251
|
+
"Use fail_fast=true to error instead of auto-escalating to expensive tiers. " +
|
|
252
|
+
"Use force_refresh=true to bypass cache and always fetch live content. " +
|
|
253
|
+
"Use promote_schema_org=true to prefer Schema.org JSON-LD over LLM extraction on structured pages. " +
|
|
254
|
+
"Use estimate_first=true to run a free cost estimate before scraping (prepended to the result). " +
|
|
255
|
+
"If a long-running scrape returns a job_id instead of content, the job continues server-side.";
|
|
256
|
+
/** Merge the top-level prefer_cost/prefer_speed/fail_fast shorthands into cost_controls (explicit cost_controls wins). */
|
|
257
|
+
function buildCostControls(params) {
|
|
258
|
+
const merged = (0, common_js_1.compact)({
|
|
259
|
+
prefer_cost: params.prefer_cost,
|
|
260
|
+
prefer_speed: params.prefer_speed,
|
|
261
|
+
fail_fast: params.fail_fast,
|
|
262
|
+
...(params.cost_controls ?? {}),
|
|
263
|
+
});
|
|
264
|
+
return Object.keys(merged).length > 0 ? merged : undefined;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Translate flat tool parameters into the API's UnifiedScrapeRequest body.
|
|
268
|
+
* Exported for tests.
|
|
269
|
+
*/
|
|
270
|
+
function buildScrapeRequest(params) {
|
|
271
|
+
const advanced = (0, common_js_1.pickAdvanced)(params, common_js_1.ADVANCED_KEYS);
|
|
272
|
+
advanced.markdown = params.formats.includes("markdown");
|
|
273
|
+
if (params.screenshot !== undefined)
|
|
274
|
+
advanced.screenshot = params.screenshot;
|
|
275
|
+
return {
|
|
276
|
+
...(0, common_js_1.compact)({
|
|
197
277
|
url: params.url,
|
|
198
278
|
method: params.method,
|
|
199
279
|
body: params.body,
|
|
280
|
+
content_type: params.content_type,
|
|
281
|
+
headers: params.headers,
|
|
200
282
|
mode: params.mode,
|
|
201
283
|
formats: params.formats,
|
|
202
284
|
sync: true,
|
|
285
|
+
sync_policy: params.sync_policy,
|
|
203
286
|
timeout: params.timeout,
|
|
204
287
|
max_response_bytes: params.max_response_bytes,
|
|
205
288
|
include_raw_html: params.include_raw_html,
|
|
206
289
|
wait_for: params.wait_for,
|
|
207
|
-
|
|
208
|
-
|
|
290
|
+
wait_until: params.wait_until,
|
|
291
|
+
screenshot: params.screenshot,
|
|
292
|
+
enable_scroll: params.enable_scroll ?? undefined,
|
|
293
|
+
pdf_format: params.pdf_format,
|
|
294
|
+
ocr_language: params.ocr_language,
|
|
209
295
|
location: params.location,
|
|
210
296
|
extraction_schema: params.extraction_schema,
|
|
211
297
|
extraction_prompt: params.extraction_prompt,
|
|
212
298
|
extraction_model: params.extraction_model ?? undefined,
|
|
213
299
|
extraction_provider: params.extraction_provider,
|
|
214
300
|
extraction_profile: params.extraction_profile,
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
})
|
|
301
|
+
extraction_template: params.extraction_template ??
|
|
302
|
+
params.template,
|
|
303
|
+
evidence: params.evidence,
|
|
304
|
+
filter_content: params.filter_content,
|
|
305
|
+
cache: params.cache,
|
|
306
|
+
cache_ttl: params.cache_ttl,
|
|
307
|
+
force_refresh: params.force_refresh,
|
|
308
|
+
promote_schema_org: params.promote_schema_org,
|
|
309
|
+
embeddings: params.embeddings,
|
|
310
|
+
cost_controls: buildCostControls(params),
|
|
311
|
+
}),
|
|
312
|
+
advanced,
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Cost-estimate request for the same scrape. The estimate endpoint prices from
|
|
317
|
+
* url, mode, method, formats and the cost-bearing advanced flags only.
|
|
318
|
+
*/
|
|
319
|
+
function buildEstimateRequest(params) {
|
|
320
|
+
return {
|
|
321
|
+
...(0, common_js_1.compact)({
|
|
322
|
+
url: params.url,
|
|
323
|
+
mode: params.mode,
|
|
324
|
+
method: params.method,
|
|
325
|
+
formats: params.formats,
|
|
326
|
+
}),
|
|
327
|
+
advanced: (0, common_js_1.compact)({
|
|
328
|
+
render_js: params.render_js,
|
|
329
|
+
use_proxy: params.use_proxy,
|
|
330
|
+
use_own_proxy: params.use_own_proxy,
|
|
331
|
+
screenshot: params.screenshot,
|
|
332
|
+
generate_pdf: params.generate_pdf,
|
|
333
|
+
ocr: params.ocr,
|
|
334
|
+
}),
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
async function handleScrape(client, params) {
|
|
338
|
+
// Optional pre-flight cost estimate — runs before the scrape, no credits charged.
|
|
339
|
+
// On failure, degrade gracefully: prepend a warning and continue with the scrape.
|
|
340
|
+
let estimatePrefix = "";
|
|
341
|
+
if (params.estimate_first) {
|
|
342
|
+
try {
|
|
343
|
+
const estimate = await client.estimate(buildEstimateRequest(params));
|
|
344
|
+
estimatePrefix = (0, format_js_1.formatEstimateInline)(estimate) + "\n";
|
|
345
|
+
}
|
|
346
|
+
catch {
|
|
347
|
+
estimatePrefix =
|
|
348
|
+
"> **Pre-flight estimate**: unavailable (estimate API call failed — proceeding with scrape).\n\n";
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
try {
|
|
352
|
+
const response = await client.scrape(buildScrapeRequest(params));
|
|
353
|
+
const balanceWarningSuffix = (0, format_js_1.formatBalanceWarning)(client.getLastBalanceWarning());
|
|
226
354
|
return {
|
|
227
|
-
content: [{ type: "text", text: (0, format_js_1.formatScrapeResponse)(response) }],
|
|
355
|
+
content: [{ type: "text", text: estimatePrefix + (0, format_js_1.formatScrapeResponse)(response) + balanceWarningSuffix }],
|
|
228
356
|
};
|
|
229
357
|
}
|
|
230
358
|
catch (error) {
|
|
231
|
-
|
|
232
|
-
|
|
359
|
+
const balanceWarningSuffix = (0, format_js_1.formatBalanceWarning)(client.getLastBalanceWarning());
|
|
360
|
+
const result = isApiError(error)
|
|
361
|
+
? (0, errors_js_1.formatErrorResult)(error, { url: params.url })
|
|
362
|
+
: (0, errors_js_1.formatErrorResult)(error, { url: params.url });
|
|
363
|
+
if (balanceWarningSuffix && result.content[0]?.type === "text") {
|
|
364
|
+
result.content[0].text += balanceWarningSuffix;
|
|
233
365
|
}
|
|
234
|
-
return
|
|
366
|
+
return result;
|
|
235
367
|
}
|
|
236
368
|
}
|
|
237
369
|
function isApiError(error) {
|
package/dist/tools/scrape.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scrape.js","sourceRoot":"","sources":["../../src/tools/scrape.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"scrape.js","sourceRoot":"","sources":["../../src/tools/scrape.ts"],"names":[],"mappings":";;;AAwVA,gDA6CC;AAMD,oDA4BC;AAED,oCAkCC;AA3cD,6BAAwB;AAGxB,4CAAgE;AAChE,4CAAgG;AAEhG,2CAaqB;AAER,QAAA,YAAY,GAAG,OAAC,CAAC,MAAM,CAAC;IACnC,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,eAAe,CAAC;IACzD,MAAM,EAAE,OAAC;SACN,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;SACrB,OAAO,CAAC,KAAK,CAAC;SACd,QAAQ,CACP,qEAAqE;QACnE,wEAAwE;QACx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,CAAC,qBAAqB,EAAE,CAAC,CAAC;QAClF,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,IAAA,gCAAoB,EAAC,QAAQ,CAAC,GAAG,oBAAoB,EAAE,CAAC;SAC1G,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,oBAAoB,GAAG,IAAA,gCAAoB,EAAC,MAAM,CAAC,qBAAqB,EAAE,CAAC,CAAC;QAClF,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC;YAC9B,CAAC,CAAC,IAAA,6BAAiB,EAAC,KAAK,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC;YAC/C,CAAC,CAAC,IAAA,6BAAiB,EAAC,KAAc,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;QAC3D,IAAI,oBAAoB,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,KAAK,MAAM,EAAE,CAAC;YAC9D,MAAM,CAAC,OAAO,CAAC,CAAC,CAAoC,CAAC,IAAI,IAAI,oBAAoB,CAAC;QACrF,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CAAC,KAAc;IAChC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,QAAQ,IAAI,KAAK;QACjB,OAAQ,KAAkB,CAAC,MAAM,KAAK,QAAQ,CAC/C,CAAC;AACJ,CAAC"}
|
|
@@ -5,14 +5,47 @@ export declare const screenshotSchema: z.ZodObject<{
|
|
|
5
5
|
url: z.ZodString;
|
|
6
6
|
wait_for: z.ZodOptional<z.ZodString>;
|
|
7
7
|
wait_until: z.ZodDefault<z.ZodEnum<["networkidle", "domcontentloaded", "load"]>>;
|
|
8
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
9
|
+
use_proxy: z.ZodOptional<z.ZodBoolean>;
|
|
10
|
+
proxy_country: z.ZodOptional<z.ZodString>;
|
|
11
|
+
session_id: z.ZodOptional<z.ZodString>;
|
|
12
|
+
cookies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
13
|
+
location: z.ZodOptional<z.ZodObject<{
|
|
14
|
+
country: z.ZodOptional<z.ZodString>;
|
|
15
|
+
language: z.ZodOptional<z.ZodString>;
|
|
16
|
+
}, "strip", z.ZodTypeAny, {
|
|
17
|
+
country?: string | undefined;
|
|
18
|
+
language?: string | undefined;
|
|
19
|
+
}, {
|
|
20
|
+
country?: string | undefined;
|
|
21
|
+
language?: string | undefined;
|
|
22
|
+
}>>;
|
|
8
23
|
}, "strip", z.ZodTypeAny, {
|
|
9
24
|
url: string;
|
|
10
25
|
wait_until: "networkidle" | "domcontentloaded" | "load";
|
|
26
|
+
timeout?: number | undefined;
|
|
11
27
|
wait_for?: string | undefined;
|
|
28
|
+
location?: {
|
|
29
|
+
country?: string | undefined;
|
|
30
|
+
language?: string | undefined;
|
|
31
|
+
} | undefined;
|
|
32
|
+
use_proxy?: boolean | undefined;
|
|
33
|
+
proxy_country?: string | undefined;
|
|
34
|
+
session_id?: string | undefined;
|
|
35
|
+
cookies?: Record<string, string> | undefined;
|
|
12
36
|
}, {
|
|
13
37
|
url: string;
|
|
38
|
+
timeout?: number | undefined;
|
|
14
39
|
wait_for?: string | undefined;
|
|
15
40
|
wait_until?: "networkidle" | "domcontentloaded" | "load" | undefined;
|
|
41
|
+
location?: {
|
|
42
|
+
country?: string | undefined;
|
|
43
|
+
language?: string | undefined;
|
|
44
|
+
} | undefined;
|
|
45
|
+
use_proxy?: boolean | undefined;
|
|
46
|
+
proxy_country?: string | undefined;
|
|
47
|
+
session_id?: string | undefined;
|
|
48
|
+
cookies?: Record<string, string> | undefined;
|
|
16
49
|
}>;
|
|
17
50
|
export declare const screenshotDescription: string;
|
|
18
51
|
export declare function handleScreenshot(client: AlterLabClient, params: z.infer<typeof screenshotSchema>): Promise<CallToolResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screenshot.d.ts","sourceRoot":"","sources":["../../src/tools/screenshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"screenshot.d.ts","sourceRoot":"","sources":["../../src/tools/screenshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAMnD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmC3B,CAAC;AAEH,eAAO,MAAM,qBAAqB,QAQ0F,CAAC;AAE7H,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,GACvC,OAAO,CAAC,cAAc,CAAC,CAiFzB"}
|