@browsa/mcp 0.6.0 → 0.7.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 +1 -1
  2. package/dist/server.js +124 -15
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -143,7 +143,7 @@ Everything else from 0.5 is in groups you turn on with `BROWSA_MCP_TOOLS` (comma
143
143
  | `schedules` | `create_schedule`, `list_schedules` |
144
144
  | `webhooks` | `list_webhooks`, `create_webhook`, `delete_webhook` |
145
145
  | `cdp` | `start_browser`, `stop_browser` (a CDP address, to drive the browser from your own code) |
146
- | `captcha` | `solve_captcha_task` (Browsa's captcha API, for pages outside a Browsa browser) |
146
+ | `captcha` | `solve_captcha_task` (Browsa's captcha API, for pages outside a Browsa browser; the answer says what the solve cost), `list_captcha_types` (every type with its parameters, price and measured pass rate), `report_captcha_result` (tell Browsa whether the site took a solution; reports are recorded and used to improve solving) |
147
147
  | `admin` | `credits`, `list_browsers`, `list_identities`, `proxy_network`, `list_llm_keys`, `list_models` |
148
148
  | `all` | every group |
149
149
 
package/dist/server.js CHANGED
@@ -6,7 +6,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
6
6
  import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
7
7
 
8
8
  // src/config.ts
9
- var VERSION = "0.6.0";
9
+ var VERSION = "0.7.0";
10
10
  var API_KEY = process.env.BROWSA_API_KEY;
11
11
  var BASE_URL = (process.env.BROWSA_BASE_URL || "https://browsa.io").replace(/\/+$/, "");
12
12
  var BASE_URL_SET = !!process.env.BROWSA_BASE_URL;
@@ -20,7 +20,7 @@ var GROUPS = {
20
20
  schedules: ["create_schedule", "list_schedules"],
21
21
  webhooks: ["list_webhooks", "create_webhook", "delete_webhook"],
22
22
  cdp: ["start_browser", "stop_browser"],
23
- captcha: ["solve_captcha_task"],
23
+ captcha: ["solve_captcha_task", "list_captcha_types", "report_captcha_result"],
24
24
  admin: ["credits", "list_browsers", "list_identities", "proxy_network", "list_llm_keys", "list_models"]
25
25
  };
26
26
  var CORE_TOOLS = ["open", "observe", "act", "read", "screenshot", "secrets", "handoff", "flow", "close"];
@@ -979,7 +979,7 @@ var REASONING_PROP = {
979
979
  var legacyTools = [
980
980
  {
981
981
  name: "run_task",
982
- 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.",
982
+ 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. When the run creates a login (a signup), the result may list it in `saved_secrets` (saved as a workspace secret, never the value).",
983
983
  inputSchema: {
984
984
  type: "object",
985
985
  required: ["task"],
@@ -1015,6 +1015,16 @@ var legacyTools = [
1015
1015
  type: "string",
1016
1016
  description: "Id of a persistent identity (agt_..., from list_identities). If set, reuses that browser identity (cookies, history, fingerprint stay sticky). Omit for a fresh burner."
1017
1017
  },
1018
+ secret_ids: {
1019
+ type: "array",
1020
+ items: { type: "string" },
1021
+ maxItems: 20,
1022
+ description: "Names or ids of workspace secrets the task may type; refer to them in the task as secrets.NAME (or secrets.NAME.username, .password, .totp)."
1023
+ },
1024
+ save_secrets: {
1025
+ type: "boolean",
1026
+ description: "Set false to stop the run from saving a login it creates as a workspace secret (on by default)."
1027
+ },
1018
1028
  timeout_minutes: {
1019
1029
  type: "integer",
1020
1030
  description: "Max wall-clock minutes to wait before returning. Default 10.",
@@ -1251,6 +1261,29 @@ var legacyTools = [
1251
1261
  timeout_seconds: { type: "number", description: "How long to wait for the solution. Default 180, at most 600." }
1252
1262
  }
1253
1263
  }
1264
+ },
1265
+ {
1266
+ name: "list_captcha_types",
1267
+ description: "List the captcha task types Browsa's captcha API accepts: whether each is live or off, its required and optional parameters, its price per solve and, where measured, its pass rate with the date of the run. Call it before solve_captcha_task when unsure of a type name or of a parameter: names are case-sensitive. Uses no credits.",
1268
+ inputSchema: {
1269
+ type: "object",
1270
+ properties: {
1271
+ type: { type: "string", description: "Only this type, with the description of every parameter." },
1272
+ live_only: { type: "boolean", description: "Leave out the types that are switched off." }
1273
+ }
1274
+ }
1275
+ },
1276
+ {
1277
+ name: "report_captcha_result",
1278
+ description: "Tell Browsa whether the site accepted a solution from solve_captcha_task: correct=true records that it worked, correct=false that the site refused it. Reports are recorded and used to improve solving. A task can be reported once, within 15 minutes of the solve. Report only what the site itself answered.",
1279
+ inputSchema: {
1280
+ type: "object",
1281
+ required: ["task_id", "correct"],
1282
+ properties: {
1283
+ task_id: { type: "string", description: "task_id from solve_captcha_task." },
1284
+ correct: { type: "boolean", description: "true when the site accepted the solution, false when it refused it." }
1285
+ }
1286
+ }
1254
1287
  }
1255
1288
  ];
1256
1289
  function ok(payload) {
@@ -1355,6 +1388,23 @@ function llmResultFields(job) {
1355
1388
  if (!r || typeof r !== "object") return {};
1356
1389
  return { llm_tier: r.llm_tier, reasoning: r.reasoning, usage: r.usage, llm_cost_usd: r.llm_cost_usd };
1357
1390
  }
1391
+ function savedSecretFields(job) {
1392
+ const r = job.raw?.result;
1393
+ if (!r || typeof r !== "object") return {};
1394
+ const saved = Array.isArray(r.saved_secrets) ? r.saved_secrets.filter((s) => s && typeof s === "object").map((s) => ({
1395
+ name: s.name,
1396
+ id: s.id,
1397
+ type: s.type,
1398
+ origins: s.origins,
1399
+ ...s.username_masked ? { username_masked: s.username_masked } : {},
1400
+ existing: s.existing === true
1401
+ })) : [];
1402
+ const notSaved = r.secrets_not_saved && typeof r.secrets_not_saved === "object" && r.secrets_not_saved.code ? { code: r.secrets_not_saved.code, message: r.secrets_not_saved.message } : void 0;
1403
+ return {
1404
+ ...saved.length ? { saved_secrets: saved } : {},
1405
+ ...notSaved ? { secrets_not_saved: notSaved } : {}
1406
+ };
1407
+ }
1358
1408
  async function listLlmKeys() {
1359
1409
  const body = await apiGet("/v1/llm-keys");
1360
1410
  return {
@@ -1456,7 +1506,7 @@ var CAPTCHA_ALIASES = {
1456
1506
  recaptchav2classification: ["ReCaptchaV2Classification", "ReCaptchaV2Classification"]
1457
1507
  };
1458
1508
  async function captchaCall(method, payload) {
1459
- const resp = await fetch(`${CAPTCHA_URL}/${method}`, {
1509
+ const resp = await fetch(`${CAPTCHA_URL}/${method}`, payload === null ? { method: "GET", headers: { Accept: "application/json", "User-Agent": "browsa-mcp" }, signal: AbortSignal.timeout(3e4) } : {
1460
1510
  method: "POST",
1461
1511
  headers: { "Content-Type": "application/json", Accept: "application/json", "User-Agent": "browsa-mcp" },
1462
1512
  body: JSON.stringify({ clientKey: API_KEY, ...payload }),
@@ -1477,22 +1527,33 @@ async function solveCaptchaTask(args) {
1477
1527
  const failed = (b) => fail(b.errorDescription || b.errorCode, {
1478
1528
  code: b.errorCode,
1479
1529
  task_id: b.taskId,
1480
- charged: false,
1481
- ...b.errorCode === "ERROR_TASK_NOT_SUPPORTED" ? { measured_types: "https://browsa.io/captcha" } : {}
1530
+ charged: b.charged === true,
1531
+ ...b.fix ? { fix: b.fix } : {},
1532
+ ...b.errorCode === "ERROR_TASK_NOT_SUPPORTED" ? { measured_types: "https://browsa.io/captcha", next: "call list_captcha_types for the type names and their parameters" } : {}
1482
1533
  });
1483
- const created = await captchaCall("createTask", { task });
1484
- if (created.errorId) return failed(created);
1485
1534
  const started = Date.now();
1486
- if (created.status === "ready" && created.solution) {
1487
- return ok({ task_id: created.taskId, type: task.type, solution: created.solution, seconds: 0 });
1488
- }
1489
1535
  const deadline = started + timeoutMs;
1536
+ const hold = () => Math.max(0, Math.min(CAPTCHA_WAIT_S, Math.floor((deadline - Date.now()) / 1e3)));
1537
+ const solved = (b) => ok({
1538
+ task_id: created.taskId,
1539
+ type: task.type,
1540
+ solution: b.solution,
1541
+ seconds: typeof b.solveSeconds === "number" ? b.solveSeconds : Math.round((Date.now() - started) / 100) / 10,
1542
+ ...b.cost ? { cost: b.cost } : {},
1543
+ next: "when the site has answered, call report_captcha_result with correct=true or correct=false"
1544
+ });
1545
+ const created = await captchaCall("createTask", { task, ...hold() ? { waitSeconds: hold() } : {} });
1546
+ if (created.errorId) return failed(created);
1547
+ if (created.status === "ready" && created.solution) return solved(created);
1490
1548
  while (Date.now() < deadline) {
1491
- await new Promise((r2) => setTimeout(r2, Math.min(CAPTCHA_POLL_MS, Math.max(0, deadline - Date.now()))));
1492
- const r = await captchaCall("getTaskResult", { taskId: created.taskId });
1549
+ const wait = hold();
1550
+ if (!wait) await new Promise((r2) => setTimeout(r2, Math.min(CAPTCHA_POLL_MS, Math.max(0, deadline - Date.now()))));
1551
+ const asked = Date.now();
1552
+ const r = await captchaCall("getTaskResult", { taskId: created.taskId, ...wait ? { waitSeconds: wait } : {} });
1493
1553
  if (r.errorId) return failed(r);
1494
- if (r.status === "ready") {
1495
- return ok({ task_id: created.taskId, type: task.type, solution: r.solution, seconds: Math.round((Date.now() - started) / 100) / 10 });
1554
+ if (r.status === "ready") return solved(r);
1555
+ if (wait && Date.now() - asked < 1e3) {
1556
+ await new Promise((res) => setTimeout(res, Math.min(CAPTCHA_POLL_MS, Math.max(0, deadline - Date.now()))));
1496
1557
  }
1497
1558
  }
1498
1559
  return fail(
@@ -1501,6 +1562,45 @@ async function solveCaptchaTask(args) {
1501
1562
  );
1502
1563
  }
1503
1564
  var CAPTCHA_POLL_MS = Number(process.env.BROWSA_CAPTCHA_POLL_MS) || 3e3;
1565
+ var CAPTCHA_WAIT_S = 20;
1566
+ async function listCaptchaTypes(args) {
1567
+ const r = await captchaCall("types", null);
1568
+ if (r.errorId || !Array.isArray(r.types)) return fail(r.errorDescription || "the type catalogue is not available", { code: r.errorCode });
1569
+ const names = (ps) => (ps ?? []).map((p) => p.name);
1570
+ const measured = (t) => (t.measured ?? []).map((m) => ({ what: m.name, passes: `${m.passes} of ${m.attempts}`, median_seconds: m.medianSeconds, measured_on: m.measuredOn, exit: m.exit }));
1571
+ if (typeof args.type === "string" && args.type) {
1572
+ const want = args.type.toLowerCase();
1573
+ const t = r.types.find((x) => String(x.type).toLowerCase() === want);
1574
+ if (!t) return fail(`no type named ${args.type}`, { types: r.types.map((x) => x.type) });
1575
+ return ok({ ...t, measured: measured(t) });
1576
+ }
1577
+ const types = r.types.filter((t) => !args.live_only || t.status === "live").map((t) => ({
1578
+ type: t.type,
1579
+ what: t.summary,
1580
+ status: t.status,
1581
+ ...t.offReason ? { off_reason: t.offReason } : {},
1582
+ required: [...names(t.required), ...(t.requiredOneOf ?? []).map((g) => names(g).join(" or "))],
1583
+ optional: names(t.optional),
1584
+ proxy: t.proxy,
1585
+ credits_per_solve: t.price?.creditsPerSolve,
1586
+ measured: measured(t)
1587
+ }));
1588
+ return ok({ types, note: "Names are case-sensitive. A failed solve is not charged. Pass `type` for one type's parameter descriptions." });
1589
+ }
1590
+ async function reportCaptchaResult(args) {
1591
+ if (typeof args.task_id !== "string" || !args.task_id) return fail("task_id is required");
1592
+ if (typeof args.correct !== "boolean") return fail("correct must be true or false");
1593
+ const r = await captchaCall(args.correct ? "reportCorrect" : "reportIncorrect", { taskId: args.task_id });
1594
+ if (r.errorId) {
1595
+ return fail(r.errorDescription || r.errorCode, {
1596
+ code: r.errorCode,
1597
+ task_id: args.task_id,
1598
+ ...r.fix ? { fix: r.fix } : {},
1599
+ ...typeof r.refunded === "boolean" ? { refunded: r.refunded } : {}
1600
+ });
1601
+ }
1602
+ return ok({ task_id: args.task_id, outcome: r.outcome, refunded: r.refunded === true, refund: r.refund, message: r.message });
1603
+ }
1504
1604
  async function callLegacy(name, args) {
1505
1605
  let choice = null;
1506
1606
  try {
@@ -1521,6 +1621,9 @@ async function callLegacy(name, args) {
1521
1621
  initialUrl: args.initial_url,
1522
1622
  ja3Profile: args.ja3_profile,
1523
1623
  profileId: args.profile_id,
1624
+ // Sent as is (snake_case) and only when given.
1625
+ secret_ids: Array.isArray(args.secret_ids) && args.secret_ids.length ? args.secret_ids : void 0,
1626
+ save_secrets: typeof args.save_secrets === "boolean" ? args.save_secrets : void 0,
1524
1627
  timeoutMs: (args.timeout_minutes ?? 10) * 6e4
1525
1628
  })
1526
1629
  );
@@ -1536,6 +1639,7 @@ async function callLegacy(name, args) {
1536
1639
  llm_key_masked: job.raw?.llm_key_masked,
1537
1640
  llm_key_source: job.raw?.llm_key_source,
1538
1641
  ...llmResultFields(job),
1642
+ ...savedSecretFields(job),
1539
1643
  final_result: job.finalResult,
1540
1644
  error: job.errorMessage,
1541
1645
  error_code: job.errorCode
@@ -1551,6 +1655,7 @@ async function callLegacy(name, args) {
1551
1655
  live_url: job.liveUrl,
1552
1656
  input_question: job.inputQuestion,
1553
1657
  ...llmResultFields(job),
1658
+ ...savedSecretFields(job),
1554
1659
  final_result: job.finalResult,
1555
1660
  error: job.errorMessage,
1556
1661
  error_code: job.errorCode,
@@ -1665,6 +1770,10 @@ async function callLegacy(name, args) {
1665
1770
  return ok(robotRunView(await apiGet(`/v1/robot-runs/${encodeURIComponent(String(args.run_id))}`)));
1666
1771
  case "solve_captcha_task":
1667
1772
  return await solveCaptchaTask(args);
1773
+ case "list_captcha_types":
1774
+ return await listCaptchaTypes(args);
1775
+ case "report_captcha_result":
1776
+ return await reportCaptchaResult(args);
1668
1777
  default:
1669
1778
  return fail(`unknown tool: ${name}`);
1670
1779
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@browsa/mcp",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "mcpName": "io.browsa/browsa",
5
5
  "description": "MCP server for Browsa: real cloud browsers (Phantom) for Claude, Cursor, VS Code and any MCP client: compact page views, real input, secrets by reference, hand-off and no-model replays",
6
6
  "license": "MIT",