firecrawl-mcp 3.21.2 → 3.21.3
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/dist/index.js +73 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2880,6 +2880,61 @@ async function keylessPost(path2, body, session) {
|
|
|
2880
2880
|
}
|
|
2881
2881
|
return json;
|
|
2882
2882
|
}
|
|
2883
|
+
async function getCrawlStatusWithOrigin(client, jobId) {
|
|
2884
|
+
const res = await client.http.get(
|
|
2885
|
+
`/v2/crawl/${encodeURIComponent(jobId)}`,
|
|
2886
|
+
ORIGIN_HEADERS2
|
|
2887
|
+
);
|
|
2888
|
+
const body = res?.data ?? {};
|
|
2889
|
+
const initialDocs = Array.isArray(body.data) ? body.data : [];
|
|
2890
|
+
if (!body.next) {
|
|
2891
|
+
return {
|
|
2892
|
+
id: jobId,
|
|
2893
|
+
status: body.status,
|
|
2894
|
+
completed: body.completed ?? 0,
|
|
2895
|
+
total: body.total ?? 0,
|
|
2896
|
+
creditsUsed: body.creditsUsed,
|
|
2897
|
+
expiresAt: body.expiresAt,
|
|
2898
|
+
next: body.next ?? null,
|
|
2899
|
+
data: initialDocs
|
|
2900
|
+
};
|
|
2901
|
+
}
|
|
2902
|
+
const docs = initialDocs.slice();
|
|
2903
|
+
let current = body.next;
|
|
2904
|
+
while (current) {
|
|
2905
|
+
const pageRes = await client.http.get(current, ORIGIN_HEADERS2);
|
|
2906
|
+
const payload = pageRes?.data ?? {};
|
|
2907
|
+
if (!payload.success) break;
|
|
2908
|
+
const pageData = Array.isArray(payload.data) ? payload.data : payload.data?.pages || [];
|
|
2909
|
+
docs.push(...pageData);
|
|
2910
|
+
current = payload.next ?? (Array.isArray(payload.data) ? null : payload.data?.next) ?? null;
|
|
2911
|
+
}
|
|
2912
|
+
return {
|
|
2913
|
+
id: jobId,
|
|
2914
|
+
status: body.status,
|
|
2915
|
+
completed: body.completed ?? 0,
|
|
2916
|
+
total: body.total ?? 0,
|
|
2917
|
+
creditsUsed: body.creditsUsed,
|
|
2918
|
+
expiresAt: body.expiresAt,
|
|
2919
|
+
next: null,
|
|
2920
|
+
data: docs
|
|
2921
|
+
};
|
|
2922
|
+
}
|
|
2923
|
+
async function waitForCrawlCompletionWithOrigin(client, jobId, pollInterval = 2, timeout) {
|
|
2924
|
+
const startedAt = Date.now();
|
|
2925
|
+
while (true) {
|
|
2926
|
+
const status = await getCrawlStatusWithOrigin(client, jobId);
|
|
2927
|
+
if (["completed", "failed", "cancelled"].includes(String(status.status ?? ""))) {
|
|
2928
|
+
return status;
|
|
2929
|
+
}
|
|
2930
|
+
if (timeout != null && Date.now() - startedAt > timeout * 1e3) {
|
|
2931
|
+
throw new Error(`Crawl job ${jobId} did not complete within ${timeout}s`);
|
|
2932
|
+
}
|
|
2933
|
+
await new Promise(
|
|
2934
|
+
(resolve) => setTimeout(resolve, Math.max(1e3, pollInterval * 1e3))
|
|
2935
|
+
);
|
|
2936
|
+
}
|
|
2937
|
+
}
|
|
2883
2938
|
var feedbackIssueSchema = z4.string().trim().min(1).max(80).regex(
|
|
2884
2939
|
/^[a-z0-9][a-z0-9_-]*$/,
|
|
2885
2940
|
"Issue codes must use lowercase letters, numbers, underscores, or hyphens"
|
|
@@ -3255,11 +3310,26 @@ server.addTool({
|
|
|
3255
3310
|
if (webhook) opts.webhook = webhook;
|
|
3256
3311
|
delete opts.webhookHeaders;
|
|
3257
3312
|
const cleaned = removeEmptyTopLevel(opts);
|
|
3313
|
+
const pollInterval = typeof cleaned.pollInterval === "number" ? cleaned.pollInterval : 2;
|
|
3314
|
+
const timeout = typeof cleaned.timeout === "number" ? cleaned.timeout : void 0;
|
|
3315
|
+
delete cleaned.pollInterval;
|
|
3316
|
+
delete cleaned.timeout;
|
|
3258
3317
|
log.info("Starting crawl", { url: String(url) });
|
|
3259
|
-
const
|
|
3318
|
+
const started = await client.http.post("/v2/crawl", {
|
|
3319
|
+
url: String(url),
|
|
3260
3320
|
...cleaned,
|
|
3261
3321
|
origin: ORIGIN
|
|
3262
3322
|
});
|
|
3323
|
+
const crawlId = started?.data?.id;
|
|
3324
|
+
if (!crawlId) {
|
|
3325
|
+
return asText2(started?.data ?? {});
|
|
3326
|
+
}
|
|
3327
|
+
const res = await waitForCrawlCompletionWithOrigin(
|
|
3328
|
+
client,
|
|
3329
|
+
crawlId,
|
|
3330
|
+
pollInterval,
|
|
3331
|
+
timeout
|
|
3332
|
+
);
|
|
3263
3333
|
return asText2(res);
|
|
3264
3334
|
}
|
|
3265
3335
|
});
|
|
@@ -3292,11 +3362,8 @@ Check the status of a crawl job.
|
|
|
3292
3362
|
execute: async (args2, { session }) => {
|
|
3293
3363
|
const client = getClient(session);
|
|
3294
3364
|
const id = args2.id;
|
|
3295
|
-
const res = await client
|
|
3296
|
-
|
|
3297
|
-
ORIGIN_HEADERS2
|
|
3298
|
-
);
|
|
3299
|
-
return asText2(res?.data ?? {});
|
|
3365
|
+
const res = await getCrawlStatusWithOrigin(client, id);
|
|
3366
|
+
return asText2(res);
|
|
3300
3367
|
}
|
|
3301
3368
|
});
|
|
3302
3369
|
server.addTool({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "firecrawl-mcp",
|
|
3
|
-
"version": "3.21.
|
|
3
|
+
"version": "3.21.3",
|
|
4
4
|
"description": "MCP server for Firecrawl — search, scrape, and interact with the web. Supports both cloud and self-hosted instances. Features include web search, scraping, page interaction, batch processing, and LLM-powered content analysis.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"mcpName": "io.github.firecrawl/firecrawl-mcp-server",
|