@browsa/mcp 0.3.2 → 0.5.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 +9 -3
- package/dist/server.js +196 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
**Drive real browsers from Claude Desktop, Cursor, Cline, and any MCP-compatible client.**
|
|
9
9
|
|
|
10
|
-
MCP (Model Context Protocol) server for [Browsa](https://browsa.io): turn any LLM into a real-browser agent with one config line. The agent gets a fresh cloud
|
|
10
|
+
MCP (Model Context Protocol) server for [Browsa](https://browsa.io): turn any LLM into a real-browser agent with one config line. The agent gets a fresh cloud browser running Phantom, Browsa's own browser, and a live view link so you can watch it work.
|
|
11
11
|
|
|
12
12
|
[](https://www.npmjs.com/package/@browsa/mcp)
|
|
13
13
|
|
|
@@ -16,8 +16,9 @@ MCP (Model Context Protocol) server for [Browsa](https://browsa.io): turn any LL
|
|
|
16
16
|
Most "AI agent" setups stop at the LLM. We give the LLM a real browser. Through MCP, Claude can now:
|
|
17
17
|
- Navigate, fill forms, click, scroll, scrape
|
|
18
18
|
- Return results as structured JSON
|
|
19
|
-
- Use your own HTTP or SOCKS5 proxy per browser, or
|
|
19
|
+
- Use your own HTTP or SOCKS5 proxy per browser (free), or Browsa's built-in proxy network: datacenter or residential, billed per GB from credits (see `proxy_network`)
|
|
20
20
|
- Stay logged in across calls via persistent identities
|
|
21
|
+
- Run your robots (saved browser jobs) and read their rows
|
|
21
22
|
|
|
22
23
|
No code from you: just configure Claude Desktop (or Cursor / Cline / Zed) once, and ask in natural language.
|
|
23
24
|
|
|
@@ -75,6 +76,7 @@ Any MCP-spec-compliant client. Point at `npx -y @browsa/mcp` and set `BROWSA_API
|
|
|
75
76
|
| `BROWSA_LLM` | no | Default LLM, e.g. `anthropic:claude-sonnet-5-5`, or a hosted tier such as `browsa-fast`. Unset: the saved key's provider default model (`claude-opus-5-5` with `BROWSA_LLM_API_KEY`) |
|
|
76
77
|
| `BROWSA_COUNTRY` | no | Default egress country (e.g. `US`) |
|
|
77
78
|
| `BROWSA_BASE_URL` | no | Override prod URL (staging / self-hosted) |
|
|
79
|
+
| `BROWSA_CAPTCHA_URL` | no | Captcha API for `solve_captcha_task`. Default: https://captcha.browsa.io (`BROWSA_BASE_URL` + `/captcha-api` when that is set) |
|
|
78
80
|
|
|
79
81
|
### Which LLM key a task uses
|
|
80
82
|
|
|
@@ -111,7 +113,7 @@ When the job has them, `run_task` and `get_job` results include `usage` (`input_
|
|
|
111
113
|
| `run_task` | Run a browser-driven task. Returns the final result, `outcome` and steps. Optional `llm`, `reasoning`, `llm_key_id`. |
|
|
112
114
|
| `get_job` | Poll a long-running task. Optional server-side `wait_seconds`. |
|
|
113
115
|
| `cancel_job` | Cancel a running task. |
|
|
114
|
-
| `respond_to_job` | Answer an `input_required` prompt (
|
|
116
|
+
| `respond_to_job` | Answer an `input_required` prompt (a decision, or a CAPTCHA the task could not solve itself: see https://browsa.io/captcha). |
|
|
115
117
|
| `start_browser` | Start a real cloud browser and get its CDP URL, to drive yourself with Playwright or Puppeteer. |
|
|
116
118
|
| `stop_browser` | Stop a browser from `start_browser` and release it. |
|
|
117
119
|
| `proxy_network` | Whether Browsa's built-in proxy network is on, its tiers, countries and price. Read-only and free. |
|
|
@@ -125,6 +127,10 @@ When the job has them, `run_task` and `get_job` results include `usage` (`input_
|
|
|
125
127
|
| `list_job_files` | Output files a task wrote. |
|
|
126
128
|
| `list_llm_keys` | Saved LLM keys: id, provider, masked key, default flag, status. Read-only; never returns a secret. |
|
|
127
129
|
| `list_models` | Hosted tiers (model, default reasoning, credits per task) and own-key providers. Read-only and free. |
|
|
130
|
+
| `list_robots` | Your robots: input rows, schedule, settings, health, last run and `price_credits` (per successful row; failed rows are free). |
|
|
131
|
+
| `run_robot` | Run a robot on its saved rows or on rows you pass. Optional `wait_seconds` (up to 300) returns the rows. |
|
|
132
|
+
| `get_robot_run` | One robot run: status, credits, and a row per input with its output or typed error. |
|
|
133
|
+
| `solve_captcha_task` | Solve one captcha through Browsa's captcha API (`createTask` / `getTaskResult`): a reCAPTCHA or Turnstile token, image text or grid tiles, for code outside a Browsa browser. Charged only when solved. Measured types: https://browsa.io/captcha |
|
|
128
134
|
|
|
129
135
|
## Why MCP-first matters
|
|
130
136
|
|
package/dist/server.js
CHANGED
|
@@ -8,8 +8,10 @@ import {
|
|
|
8
8
|
ListToolsRequestSchema
|
|
9
9
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
10
10
|
import { Client, BrowsaError } from "browsa";
|
|
11
|
+
var VERSION = "0.5.0";
|
|
11
12
|
var API_KEY = process.env.BROWSA_API_KEY;
|
|
12
13
|
var BASE_URL = process.env.BROWSA_BASE_URL;
|
|
14
|
+
var CAPTCHA_URL = (process.env.BROWSA_CAPTCHA_URL || (BASE_URL ? `${BASE_URL.replace(/\/+$/, "")}/captcha-api` : "https://captcha.browsa.io")).replace(/\/+$/, "");
|
|
13
15
|
var DEFAULT_LLM = process.env.BROWSA_LLM || void 0;
|
|
14
16
|
var BYOK_DEFAULT_LLM = "claude-opus-5-5";
|
|
15
17
|
var DEFAULT_LLM_KEY = process.env.BROWSA_LLM_API_KEY || void 0;
|
|
@@ -23,7 +25,7 @@ if (!API_KEY) {
|
|
|
23
25
|
}
|
|
24
26
|
var client = API_KEY ? new Client({ apiKey: API_KEY, ...BASE_URL ? { baseUrl: BASE_URL } : {} }) : null;
|
|
25
27
|
var server = new Server(
|
|
26
|
-
{ name: "browsa", version:
|
|
28
|
+
{ name: "browsa", version: VERSION },
|
|
27
29
|
{ capabilities: { tools: {} } }
|
|
28
30
|
);
|
|
29
31
|
var REASONING_PROP = {
|
|
@@ -34,7 +36,7 @@ var REASONING_PROP = {
|
|
|
34
36
|
var tools = [
|
|
35
37
|
{
|
|
36
38
|
name: "run_task",
|
|
37
|
-
description: "Run a browser-driven AI task on a fresh
|
|
39
|
+
description: "Run a browser-driven AI task on a fresh Phantom cloud browser. Returns the final result, the outcome and the total steps. `status: completed` only means the run ended: read `outcome`. `outcome: failed` with `status: completed` means the agent finished but could not do the task, and `final_result` says what stopped it. Use this when the user asks for anything web-shaped: scrape, fill, click, extract, login, place an order, search, summarize a page, etc. The browser is a real macOS-Chrome-fingerprinted Phantom browser with built-in captcha solving (the measured types are listed at https://browsa.io/captcha) and behavioral humanization. Default timeout: 10 minutes.",
|
|
38
40
|
inputSchema: {
|
|
39
41
|
type: "object",
|
|
40
42
|
required: ["task"],
|
|
@@ -306,6 +308,57 @@ var tools = [
|
|
|
306
308
|
required: ["job_id"],
|
|
307
309
|
properties: { job_id: { type: "string", description: "The job id from run_task / create_task." } }
|
|
308
310
|
}
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
name: "list_robots",
|
|
314
|
+
description: "List this workspace's robots: saved browser jobs over a recorded recipe, each with its input rows, schedule, model/proxy/browser settings, health (pass rate, last failure) and last run. price_credits is what one successful row costs (the recipe's price, the same as the agent task); failed rows are free. Robots are made at https://app.browsa.io (Robots) or with the API.",
|
|
315
|
+
inputSchema: {
|
|
316
|
+
type: "object",
|
|
317
|
+
properties: { limit: { type: "number", description: "At most this many robots (default 50)." } }
|
|
318
|
+
}
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
name: "run_robot",
|
|
322
|
+
description: "Run a robot over all its input rows (or the rows you pass, for this run only). Replays the recorded recipe on Phantom with no model, so it is fast. Costs the robot's price_credits per successful row; failed rows are free. Returns the run; with wait_seconds it waits for the rows and returns them.",
|
|
323
|
+
inputSchema: {
|
|
324
|
+
type: "object",
|
|
325
|
+
required: ["robot_id"],
|
|
326
|
+
properties: {
|
|
327
|
+
robot_id: { type: "string", description: "From list_robots." },
|
|
328
|
+
inputs: {
|
|
329
|
+
type: "array",
|
|
330
|
+
items: { type: "object" },
|
|
331
|
+
description: `Rows for this run only, e.g. [{"url": "https://..."}]. Omit to use the robot's saved rows.`
|
|
332
|
+
},
|
|
333
|
+
wait_seconds: { type: "number", description: "Wait up to this long for the run to finish (0 to 300, default 0)." }
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
name: "get_robot_run",
|
|
339
|
+
description: "Read one robot run: status (queued, running, completed, partial, failed), credits charged, and a row per input with its output, typed error (blocked, needs_login, site_changed, invalid_output, timeout) and the fields a monitor flagged as changed.",
|
|
340
|
+
inputSchema: {
|
|
341
|
+
type: "object",
|
|
342
|
+
required: ["run_id"],
|
|
343
|
+
properties: { run_id: { type: "string", description: "From run_robot or list_robots (last_run.id)." } }
|
|
344
|
+
}
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
name: "solve_captcha_task",
|
|
348
|
+
description: "Solve one captcha through Browsa's captcha API (createTask / getTaskResult, the format CapSolver, Anti-Captcha and CapMonster share) and return its solution: a token to submit with the site's form, the text in an image, or the grid tiles to click. Use it when code or a page outside a Browsa browser needs a captcha answer; inside run_task the browser solves captchas itself. Charged only when solved. Measured pass rates per type: https://browsa.io/captcha. Token tasks can take up to about 2 minutes.",
|
|
349
|
+
inputSchema: {
|
|
350
|
+
type: "object",
|
|
351
|
+
required: ["task"],
|
|
352
|
+
properties: {
|
|
353
|
+
task: {
|
|
354
|
+
type: "object",
|
|
355
|
+
description: "The createTask task. `type` is one of: ImageToTextTask {body: base64 image} -> {text}; ReCaptchaV2Classification {image: base64, question: '/m/...' id or words} -> {objects}; ReCaptchaV2TaskProxyLess / ReCaptchaV2EnterpriseTaskProxyLess {websiteURL, websiteKey, isInvisible?} -> {gRecaptchaResponse}; ReCaptchaV3TaskProxyLess / ReCaptchaV3EnterpriseTaskProxyLess {websiteURL, websiteKey, pageAction?} -> {gRecaptchaResponse}; AntiTurnstileTaskProxyLess {websiteURL, websiteKey, metadata?: {action?, cdata?}} -> {token}. Without ProxyLess the task also needs proxy: 'http://user:pass@host:port'. Other services' names (RecaptchaV2TaskProxyless, TurnstileTaskProxyless) are accepted.",
|
|
356
|
+
properties: { type: { type: "string" } },
|
|
357
|
+
required: ["type"]
|
|
358
|
+
},
|
|
359
|
+
timeout_seconds: { type: "number", description: "How long to wait for the solution. Default 180, at most 600." }
|
|
360
|
+
}
|
|
361
|
+
}
|
|
309
362
|
}
|
|
310
363
|
];
|
|
311
364
|
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools }));
|
|
@@ -374,7 +427,7 @@ function llmKeyError(e, choice) {
|
|
|
374
427
|
async function proxyNetwork() {
|
|
375
428
|
const base = (BASE_URL || "https://browsa.io").replace(/\/+$/, "");
|
|
376
429
|
const resp = await fetch(`${base}/v1/proxy-network`, {
|
|
377
|
-
headers: { "X-API-Key": API_KEY, Accept: "application/json", "User-Agent":
|
|
430
|
+
headers: { "X-API-Key": API_KEY, Accept: "application/json", "User-Agent": `browsa-mcp/${VERSION}` }
|
|
378
431
|
});
|
|
379
432
|
const body = await resp.json().catch(() => ({}));
|
|
380
433
|
if (resp.status === 404) return { enabled: false, tiers: [] };
|
|
@@ -399,7 +452,7 @@ function proxyUsage(raw) {
|
|
|
399
452
|
async function apiGet(path) {
|
|
400
453
|
const base = (BASE_URL || "https://browsa.io").replace(/\/+$/, "");
|
|
401
454
|
const resp = await fetch(`${base}${path}`, {
|
|
402
|
-
headers: { "X-API-Key": API_KEY, Accept: "application/json", "User-Agent":
|
|
455
|
+
headers: { "X-API-Key": API_KEY, Accept: "application/json", "User-Agent": `browsa-mcp/${VERSION}` }
|
|
403
456
|
});
|
|
404
457
|
const body = await resp.json().catch(() => ({}));
|
|
405
458
|
if (!resp.ok) {
|
|
@@ -415,7 +468,7 @@ async function apiPost(path, payload, timeoutMs = 9e4) {
|
|
|
415
468
|
"X-API-Key": API_KEY,
|
|
416
469
|
Accept: "application/json",
|
|
417
470
|
"Content-Type": "application/json",
|
|
418
|
-
"User-Agent":
|
|
471
|
+
"User-Agent": `browsa-mcp/${VERSION}`
|
|
419
472
|
},
|
|
420
473
|
body: JSON.stringify(payload),
|
|
421
474
|
signal: AbortSignal.timeout(timeoutMs)
|
|
@@ -481,6 +534,132 @@ async function listLlmKeys() {
|
|
|
481
534
|
manage_at: LLM_KEYS_URL
|
|
482
535
|
};
|
|
483
536
|
}
|
|
537
|
+
var ROBOT_RUN_DONE = ["completed", "partial", "failed"];
|
|
538
|
+
var ROBOT_POLL_MS = Number(process.env.BROWSA_ROBOT_POLL_MS) || 3e3;
|
|
539
|
+
function robotSummary(r) {
|
|
540
|
+
const h = r?.health ?? {};
|
|
541
|
+
const s = r?.schedule;
|
|
542
|
+
const lr = r?.last_run;
|
|
543
|
+
return {
|
|
544
|
+
id: r?.id,
|
|
545
|
+
name: r?.name,
|
|
546
|
+
status: r?.status,
|
|
547
|
+
paused_reason: r?.paused_reason ?? null,
|
|
548
|
+
recipe_id: r?.recipe_id ?? null,
|
|
549
|
+
inputs_count: r?.inputs_count ?? (Array.isArray(r?.inputs) ? r.inputs.length : 0),
|
|
550
|
+
price_credits: h.price_credits ?? null,
|
|
551
|
+
pass_rate: h.pass_rate ?? null,
|
|
552
|
+
last_failure: h.last_failure ?? null,
|
|
553
|
+
schedule: s ? { interval_seconds: s.interval_seconds, at: s.at ?? null, tz: s.tz ?? null, next_run_at: s.next_run_at ?? null, enabled: s.enabled } : null,
|
|
554
|
+
settings: r?.settings ?? { model: null, proxy: null, browser: null },
|
|
555
|
+
alerts_unread: r?.alerts_unread ?? 0,
|
|
556
|
+
last_run: lr ? { id: lr.id, status: lr.status, rows_ok: lr.rows_ok, rows_failed: lr.rows_failed, credits: lr.credits, finished_at: lr.finished_at ?? null } : null
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
function robotRunView(run) {
|
|
560
|
+
const out = {
|
|
561
|
+
id: run?.id,
|
|
562
|
+
robot_id: run?.robot_id,
|
|
563
|
+
status: run?.status,
|
|
564
|
+
trigger: run?.trigger,
|
|
565
|
+
rows_total: run?.rows_total,
|
|
566
|
+
rows_ok: run?.rows_ok,
|
|
567
|
+
rows_failed: run?.rows_failed,
|
|
568
|
+
rows_pending: run?.rows_pending,
|
|
569
|
+
credits: run?.credits,
|
|
570
|
+
stop_reason: run?.stop_reason ?? null,
|
|
571
|
+
finished_at: run?.finished_at ?? null
|
|
572
|
+
};
|
|
573
|
+
if (Array.isArray(run?.rows)) {
|
|
574
|
+
out.rows = run.rows.map((r) => ({
|
|
575
|
+
row: r.row,
|
|
576
|
+
input: r.input,
|
|
577
|
+
status: r.status,
|
|
578
|
+
output: r.output ?? null,
|
|
579
|
+
...r.error_code ? { error_code: r.error_code, error_message: r.error_message } : {},
|
|
580
|
+
credits: r.credits,
|
|
581
|
+
...Array.isArray(r.changed_fields) && r.changed_fields.length ? { changed_fields: r.changed_fields } : {}
|
|
582
|
+
}));
|
|
583
|
+
}
|
|
584
|
+
return out;
|
|
585
|
+
}
|
|
586
|
+
async function runRobot(args) {
|
|
587
|
+
const id = String(args.robot_id || "");
|
|
588
|
+
if (!id) return fail("robot_id is required");
|
|
589
|
+
const body = {};
|
|
590
|
+
if (Array.isArray(args.inputs)) body.inputs = args.inputs;
|
|
591
|
+
let run = await apiPost(`/v1/robots/${encodeURIComponent(id)}/run`, body, 3e4);
|
|
592
|
+
const waitMs = Math.min(Math.max(Number(args.wait_seconds) || 0, 0), 300) * 1e3;
|
|
593
|
+
const deadline = Date.now() + waitMs;
|
|
594
|
+
while (waitMs > 0 && !ROBOT_RUN_DONE.includes(run?.status) && Date.now() < deadline) {
|
|
595
|
+
await new Promise((r) => setTimeout(r, Math.min(ROBOT_POLL_MS, Math.max(0, deadline - Date.now()))));
|
|
596
|
+
run = await apiGet(`/v1/robot-runs/${encodeURIComponent(run.id)}`);
|
|
597
|
+
}
|
|
598
|
+
return ok(robotRunView(run));
|
|
599
|
+
}
|
|
600
|
+
var CAPTCHA_ALIASES = {
|
|
601
|
+
recaptchav2taskproxyless: ["ReCaptchaV2TaskProxyLess", "ReCaptchaV2TaskProxyLess"],
|
|
602
|
+
nocaptchataskproxyless: ["ReCaptchaV2TaskProxyLess", "ReCaptchaV2TaskProxyLess"],
|
|
603
|
+
recaptchav2task: ["ReCaptchaV2TaskProxyLess", "ReCaptchaV2Task"],
|
|
604
|
+
recaptchav2enterprisetaskproxyless: ["ReCaptchaV2EnterpriseTaskProxyLess", "ReCaptchaV2EnterpriseTaskProxyLess"],
|
|
605
|
+
recaptchav2enterprisetask: ["ReCaptchaV2EnterpriseTaskProxyLess", "ReCaptchaV2EnterpriseTask"],
|
|
606
|
+
recaptchav3taskproxyless: ["ReCaptchaV3TaskProxyLess", "ReCaptchaV3TaskProxyLess"],
|
|
607
|
+
recaptchav3task: ["ReCaptchaV3TaskProxyLess", "ReCaptchaV3Task"],
|
|
608
|
+
recaptchav3enterprisetaskproxyless: ["ReCaptchaV3EnterpriseTaskProxyLess", "ReCaptchaV3EnterpriseTaskProxyLess"],
|
|
609
|
+
recaptchav3enterprisetask: ["ReCaptchaV3EnterpriseTaskProxyLess", "ReCaptchaV3EnterpriseTask"],
|
|
610
|
+
turnstiletaskproxyless: ["AntiTurnstileTaskProxyLess", "AntiTurnstileTaskProxyLess"],
|
|
611
|
+
antiturnstiletaskproxyless: ["AntiTurnstileTaskProxyLess", "AntiTurnstileTaskProxyLess"],
|
|
612
|
+
turnstiletask: ["AntiTurnstileTaskProxyLess", "AntiTurnstileTask"],
|
|
613
|
+
antiturnstiletask: ["AntiTurnstileTaskProxyLess", "AntiTurnstileTask"],
|
|
614
|
+
imagetotexttask: ["ImageToTextTask", "ImageToTextTask"],
|
|
615
|
+
recaptchav2classification: ["ReCaptchaV2Classification", "ReCaptchaV2Classification"]
|
|
616
|
+
};
|
|
617
|
+
async function captchaCall(method, payload) {
|
|
618
|
+
const resp = await fetch(`${CAPTCHA_URL}/${method}`, {
|
|
619
|
+
method: "POST",
|
|
620
|
+
headers: { "Content-Type": "application/json", Accept: "application/json", "User-Agent": `browsa-mcp/${VERSION}` },
|
|
621
|
+
body: JSON.stringify({ clientKey: API_KEY, ...payload }),
|
|
622
|
+
signal: AbortSignal.timeout(3e4)
|
|
623
|
+
});
|
|
624
|
+
const body = await resp.json().catch(() => null);
|
|
625
|
+
if (!body || typeof body !== "object" || !("errorId" in body)) {
|
|
626
|
+
throw new BrowsaError(`captcha API: unexpected answer (HTTP ${resp.status})`, { code: `HTTP_${resp.status}`, status: resp.status });
|
|
627
|
+
}
|
|
628
|
+
return body;
|
|
629
|
+
}
|
|
630
|
+
async function solveCaptchaTask(args) {
|
|
631
|
+
const task = { ...args.task ?? {} };
|
|
632
|
+
if (typeof task.type !== "string" || !task.type) return fail("task.type is required");
|
|
633
|
+
const pair = CAPTCHA_ALIASES[task.type.toLowerCase()];
|
|
634
|
+
if (pair) task.type = task.proxy || task.proxyAddress ? pair[1] : pair[0];
|
|
635
|
+
const timeoutMs = Math.min(Math.max(Number(args.timeout_seconds) || 180, 5), 600) * 1e3;
|
|
636
|
+
const failed = (b) => fail(b.errorDescription || b.errorCode, {
|
|
637
|
+
code: b.errorCode,
|
|
638
|
+
task_id: b.taskId,
|
|
639
|
+
charged: false,
|
|
640
|
+
...b.errorCode === "ERROR_TASK_NOT_SUPPORTED" ? { measured_types: "https://browsa.io/captcha" } : {}
|
|
641
|
+
});
|
|
642
|
+
const created = await captchaCall("createTask", { task });
|
|
643
|
+
if (created.errorId) return failed(created);
|
|
644
|
+
const started = Date.now();
|
|
645
|
+
if (created.status === "ready" && created.solution) {
|
|
646
|
+
return ok({ task_id: created.taskId, type: task.type, solution: created.solution, seconds: 0 });
|
|
647
|
+
}
|
|
648
|
+
const deadline = started + timeoutMs;
|
|
649
|
+
while (Date.now() < deadline) {
|
|
650
|
+
await new Promise((r2) => setTimeout(r2, Math.min(CAPTCHA_POLL_MS, Math.max(0, deadline - Date.now()))));
|
|
651
|
+
const r = await captchaCall("getTaskResult", { taskId: created.taskId });
|
|
652
|
+
if (r.errorId) return failed(r);
|
|
653
|
+
if (r.status === "ready") {
|
|
654
|
+
return ok({ task_id: created.taskId, type: task.type, solution: r.solution, seconds: Math.round((Date.now() - started) / 100) / 10 });
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
return fail(
|
|
658
|
+
`no solution after ${Math.round(timeoutMs / 1e3)}s; the task may still finish (charged only if solved)`,
|
|
659
|
+
{ code: "TIMEOUT", task_id: created.taskId }
|
|
660
|
+
);
|
|
661
|
+
}
|
|
662
|
+
var CAPTCHA_POLL_MS = Number(process.env.BROWSA_CAPTCHA_POLL_MS) || 3e3;
|
|
484
663
|
server.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
485
664
|
const name = req.params.name;
|
|
486
665
|
const args = req.params.arguments ?? {};
|
|
@@ -642,6 +821,18 @@ server.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
|
642
821
|
return ok(await proxyNetwork());
|
|
643
822
|
case "list_models":
|
|
644
823
|
return ok(await listModels());
|
|
824
|
+
case "list_robots": {
|
|
825
|
+
const lim = Number(args.limit) > 0 ? `?limit=${Math.floor(Number(args.limit))}` : "";
|
|
826
|
+
const body = await apiGet(`/v1/robots${lim}`);
|
|
827
|
+
return ok({ robots: (body?.robots ?? []).map(robotSummary) });
|
|
828
|
+
}
|
|
829
|
+
case "run_robot":
|
|
830
|
+
return await runRobot(args);
|
|
831
|
+
case "get_robot_run":
|
|
832
|
+
if (!args.run_id) return fail("run_id is required");
|
|
833
|
+
return ok(robotRunView(await apiGet(`/v1/robot-runs/${encodeURIComponent(String(args.run_id))}`)));
|
|
834
|
+
case "solve_captcha_task":
|
|
835
|
+
return await solveCaptchaTask(args);
|
|
645
836
|
default:
|
|
646
837
|
return fail(`unknown tool: ${name}`);
|
|
647
838
|
}
|
package/package.json
CHANGED