@browsa/mcp 0.2.1 → 0.3.1
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/LICENSE +1 -1
- package/README.md +35 -8
- package/dist/server.js +254 -13
- package/package.json +9 -2
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<!-- mcp-name: io.browsa/browsa -->
|
|
1
2
|
<p align="center">
|
|
2
3
|
<a href="https://browsa.io"><img src="https://browsa.io/browsa-logo-lockup.png" alt="Browsa" width="340"></a>
|
|
3
4
|
</p>
|
|
@@ -6,7 +7,7 @@
|
|
|
6
7
|
|
|
7
8
|
**Drive real browsers from Claude Desktop, Cursor, Cline, and any MCP-compatible client.**
|
|
8
9
|
|
|
9
|
-
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
|
|
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 Chromium on Browsa's own build, and a live view link so you can watch it work.
|
|
10
11
|
|
|
11
12
|
[](https://www.npmjs.com/package/@browsa/mcp)
|
|
12
13
|
|
|
@@ -14,8 +15,8 @@ MCP (Model Context Protocol) server for [Browsa](https://browsa.io): turn any LL
|
|
|
14
15
|
|
|
15
16
|
Most "AI agent" setups stop at the LLM. We give the LLM a real browser. Through MCP, Claude can now:
|
|
16
17
|
- Navigate, fill forms, click, scroll, scrape
|
|
17
|
-
-
|
|
18
|
-
-
|
|
18
|
+
- Return results as structured JSON
|
|
19
|
+
- Use your own HTTP or SOCKS5 proxy per browser, or a tier of Browsa's built-in network where it is on (see `proxy_network`)
|
|
19
20
|
- Stay logged in across calls via persistent identities
|
|
20
21
|
|
|
21
22
|
No code from you: just configure Claude Desktop (or Cursor / Cline / Zed) once, and ask in natural language.
|
|
@@ -71,33 +72,59 @@ Any MCP-spec-compliant client. Point at `npx -y @browsa/mcp` and set `BROWSA_API
|
|
|
71
72
|
| `BROWSA_API_KEY` | yes | Your `agt_live_*` key from [browsa.io → Keys](https://app.browsa.io/dashboard/keys) |
|
|
72
73
|
| `BROWSA_LLM_KEY_ID` | no | Id of a saved LLM key to use by default (see `list_llm_keys`). Without it, the workspace's default saved key for the model's provider is used |
|
|
73
74
|
| `BROWSA_LLM_API_KEY` | no | A per-task LLM provider key sent with every task. Not needed once a key is saved at [dashboard/llm-keys](https://app.browsa.io/dashboard/llm-keys). Wins over `BROWSA_LLM_KEY_ID` |
|
|
74
|
-
| `BROWSA_LLM` | no | Default LLM, e.g. `anthropic:claude-sonnet-5-5`. Unset: the saved key's provider default model (`claude-opus-5-5` with `BROWSA_LLM_API_KEY`) |
|
|
75
|
+
| `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`) |
|
|
75
76
|
| `BROWSA_COUNTRY` | no | Default egress country (e.g. `US`) |
|
|
76
77
|
| `BROWSA_BASE_URL` | no | Override prod URL (staging / self-hosted) |
|
|
77
78
|
|
|
78
79
|
### Which LLM key a task uses
|
|
79
80
|
|
|
80
|
-
Per call, first match wins: `llm: "browsa"`
|
|
81
|
+
Per call, first match wins: a hosted tier (`llm: "browsa"`, `"browsa-fast"` or `"browsa-smart"`: no key, see [Models](#models)), then `llm_api_key`, then `llm_key_id`, then `BROWSA_LLM_API_KEY`, then `BROWSA_LLM_KEY_ID`. With none of these, no key is sent and the server uses the workspace's default saved key for the provider of `llm` (with `llm` unset: the first default in the order anthropic, openai, google).
|
|
81
82
|
|
|
82
83
|
If no key is saved at all:
|
|
83
84
|
|
|
84
|
-
- **No model named** (no `llm` argument, no `BROWSA_LLM`): `run_task` and `create_schedule` still work with zero config. They retry once on Browsa's hosted model (adds
|
|
85
|
+
- **No model named** (no `llm` argument, no `BROWSA_LLM`): `run_task` and `create_schedule` still work with zero config. They retry once on Browsa's hosted model (which adds credits per task) and the result has a `note` saying so: *"No saved LLM key found, so this ran on Browsa's hosted model (adds credits per task; see list_models). Save a key at https://app.browsa.io/dashboard/llm-keys to use your own."* The same happens if the server has saved keys turned off (`LLM_KEYS_UNAVAILABLE`). A schedule created this way stays on the hosted model; create it again after saving a key.
|
|
85
86
|
- **A model named**: there is no fallback. The tool returns an error (code `LLM_KEY_REQUIRED`) that says to save a key at [app.browsa.io/dashboard/llm-keys](https://app.browsa.io/dashboard/llm-keys), set `BROWSA_LLM_API_KEY`, or pass `llm: "browsa"`.
|
|
86
87
|
|
|
88
|
+
## Models
|
|
89
|
+
|
|
90
|
+
`run_task` and `create_schedule` take `llm` and `reasoning`:
|
|
91
|
+
|
|
92
|
+
| `llm` | What it is |
|
|
93
|
+
|---|---|
|
|
94
|
+
| `"browsa"` | The default hosted model |
|
|
95
|
+
| `"browsa-fast"` | Fastest and lightest |
|
|
96
|
+
| `"browsa-smart"` | For harder tasks |
|
|
97
|
+
| anything else, e.g. `"anthropic:claude-sonnet-5-5"` | A provider model, run with your own key (saved, or `llm_api_key`) |
|
|
98
|
+
|
|
99
|
+
Hosted tiers need no LLM key and add a flat number of credits per task. Which model each tier runs on, and what it costs, are server settings that can change: the `list_models` tool returns them (free, read-only), along with the providers you can bring a key for.
|
|
100
|
+
|
|
101
|
+
`reasoning` is `"low"`, `"medium"` or `"high"`; leave it out for the tier's or the provider's default. Ask in plain language, for example: *"Use browsa-smart with high reasoning to compare the pricing pages of these three sites."*
|
|
102
|
+
|
|
103
|
+
`run_task` and `get_job` results carry `status` and `outcome`. `status: completed` only means the run ended; `outcome: failed` with it means the agent finished but could not do the task, and `outcome_message` and `final_result` say why. `signals` lists what was seen on the way (a bot check, a proxy failure) when there is any.
|
|
104
|
+
|
|
105
|
+
When the job has them, `run_task` and `get_job` results include `usage` (`input_tokens`, `output_tokens`, `cache_read_tokens`, `cache_write_tokens`, `requests`), `llm_tier`, `reasoning` (the level that was applied) and `llm_cost_usd`. `llm_cost_usd` is an estimate from public list prices for runs with your own key; it is `null` when unknown and always `null` for hosted runs, which are paid in credits.
|
|
106
|
+
|
|
87
107
|
## Tools exposed
|
|
88
108
|
|
|
89
109
|
| Tool | What |
|
|
90
110
|
|---|---|
|
|
91
|
-
| `run_task` | Run a browser-driven task. Returns final result
|
|
111
|
+
| `run_task` | Run a browser-driven task. Returns the final result, `outcome` and steps. Optional `llm`, `reasoning`, `llm_key_id`. |
|
|
92
112
|
| `get_job` | Poll a long-running task. Optional server-side `wait_seconds`. |
|
|
93
113
|
| `cancel_job` | Cancel a running task. |
|
|
94
114
|
| `respond_to_job` | Answer an `input_required` prompt (CAPTCHA, decision). |
|
|
115
|
+
| `start_browser` | Start a real cloud browser and get its CDP URL, to drive yourself with Playwright or Puppeteer. |
|
|
116
|
+
| `stop_browser` | Stop a browser from `start_browser` and release it. |
|
|
117
|
+
| `proxy_network` | Whether Browsa's built-in proxy network is on, its tiers, countries and price. Read-only and free. |
|
|
118
|
+
| `observe` | Read the page of a browser from `start_browser` as compact text with element ids. No Playwright needed. |
|
|
119
|
+
| `act` | One action in that browser (click, type, press, select, scroll, navigate, wait and more); returns what changed. |
|
|
120
|
+
| `list_browsers` | List this workspace's browsers and their status. |
|
|
95
121
|
| `credits` | Show credit balance + top-up packs. |
|
|
96
122
|
| `list_webhooks` / `create_webhook` / `delete_webhook` | Webhook CRUD. |
|
|
97
123
|
| `list_identities` | List persistent browser identities (use one via `profile_id` to reuse warmed cookies). |
|
|
98
|
-
| `create_schedule` / `list_schedules` | Recurring tasks. `create_schedule` takes `llm_key_id`; the schedule stores only the key's id. |
|
|
124
|
+
| `create_schedule` / `list_schedules` | Recurring tasks. `create_schedule` takes `llm`, `reasoning` and `llm_key_id`; the schedule stores only the key's id. |
|
|
99
125
|
| `list_job_files` | Output files a task wrote. |
|
|
100
126
|
| `list_llm_keys` | Saved LLM keys: id, provider, masked key, default flag, status. Read-only; never returns a secret. |
|
|
127
|
+
| `list_models` | Hosted tiers (model, default reasoning, credits per task) and own-key providers. Read-only and free. |
|
|
101
128
|
|
|
102
129
|
## Why MCP-first matters
|
|
103
130
|
|
package/dist/server.js
CHANGED
|
@@ -26,13 +26,18 @@ var client = new Client({
|
|
|
26
26
|
...BASE_URL ? { baseUrl: BASE_URL } : {}
|
|
27
27
|
});
|
|
28
28
|
var server = new Server(
|
|
29
|
-
{ name: "browsa", version: "0.
|
|
29
|
+
{ name: "browsa", version: "0.3.1" },
|
|
30
30
|
{ capabilities: { tools: {} } }
|
|
31
31
|
);
|
|
32
|
+
var REASONING_PROP = {
|
|
33
|
+
type: "string",
|
|
34
|
+
enum: ["low", "medium", "high"],
|
|
35
|
+
description: "How much the model reasons. Omit for the tier's or the provider's default."
|
|
36
|
+
};
|
|
32
37
|
var tools = [
|
|
33
38
|
{
|
|
34
39
|
name: "run_task",
|
|
35
|
-
description: "Run a browser-driven AI task on a fresh real Chromium burner. Returns the final result, total steps
|
|
40
|
+
description: "Run a browser-driven AI task on a fresh real Chromium burner. 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 Chromium with built-in CAPTCHA solving (Turnstile, hCaptcha, reCAPTCHA, ALTCHA, FunCaptcha) and behavioral humanization. Default timeout: 10 minutes.",
|
|
36
41
|
inputSchema: {
|
|
37
42
|
type: "object",
|
|
38
43
|
required: ["task"],
|
|
@@ -43,8 +48,9 @@ var tools = [
|
|
|
43
48
|
},
|
|
44
49
|
llm: {
|
|
45
50
|
type: "string",
|
|
46
|
-
description: `LLM identifier, e.g. anthropic:claude-sonnet-5-5, openai:gpt-4o, google:gemini-2.5-flash${DEFAULT_LLM ? ` (default: ${DEFAULT_LLM})` : ""}. Omit to use the workspace's default saved key with its provider's default model; if no key is saved at all, the task runs on Browsa's hosted model and the result says so.
|
|
51
|
+
description: `LLM identifier, e.g. anthropic:claude-sonnet-5-5, openai:gpt-4o, google:gemini-2.5-flash${DEFAULT_LLM ? ` (default: ${DEFAULT_LLM})` : ""}. Omit to use the workspace's default saved key with its provider's default model; if no key is saved at all, the task runs on Browsa's hosted model and the result says so. Hosted tiers need no LLM key and add a flat credit surcharge per task (see list_models): "browsa" (default hosted model), "browsa-fast" (fastest and lightest), "browsa-smart" (for harder tasks). When you name a model, there is no hosted fallback.`
|
|
47
52
|
},
|
|
53
|
+
reasoning: REASONING_PROP,
|
|
48
54
|
llm_key_id: {
|
|
49
55
|
type: "string",
|
|
50
56
|
description: `Id of a saved LLM key of this workspace (see list_llm_keys). Default: ${DEFAULT_LLM_KEY_ID ? "BROWSA_LLM_KEY_ID" : "none"}. Usually not needed: with no key given, the workspace's default saved key for the provider of llm is used.`
|
|
@@ -78,7 +84,7 @@ var tools = [
|
|
|
78
84
|
},
|
|
79
85
|
{
|
|
80
86
|
name: "get_job",
|
|
81
|
-
description: "Fetch the current state of a previously-submitted job by UUID. Returns status (queued|running|completed|failed|input_required; a cancelled job is failed with error_code CANCELLED), step count, final_result text if terminal, and the live_url
|
|
87
|
+
description: "Fetch the current state of a previously-submitted job by UUID. Returns status (queued|running|completed|failed|input_required; a cancelled job is failed with error_code CANCELLED), step count, final_result text if terminal, and the live_url of the browser's live view while it runs. Cheap \u2014 call repeatedly to poll a long-running job started by run_task.",
|
|
82
88
|
inputSchema: {
|
|
83
89
|
type: "object",
|
|
84
90
|
required: ["job_id"],
|
|
@@ -114,6 +120,106 @@ var tools = [
|
|
|
114
120
|
}
|
|
115
121
|
}
|
|
116
122
|
},
|
|
123
|
+
{
|
|
124
|
+
name: "start_browser",
|
|
125
|
+
description: "Start a real cloud browser and return its CDP URL, so you can drive it yourself with Playwright or Puppeteer (connect_over_cdp) instead of handing the work to run_task. Use this when you want to write the browser steps, or need the page open across several of your own tool calls. Billed per browser; always call stop_browser when you are done. Without a proxy the browser uses Browsa's data-center IP.",
|
|
126
|
+
inputSchema: {
|
|
127
|
+
type: "object",
|
|
128
|
+
properties: {
|
|
129
|
+
ttl: { type: "string", description: 'How long to keep it, e.g. "5m" or "1h". Default 10m.' },
|
|
130
|
+
country: { type: "string", description: 'ISO-2 country, e.g. "us". Takes effect only with a proxy.' },
|
|
131
|
+
os_type: { type: "string", description: 'Operating system the browser presents, e.g. "macos", "windows".' },
|
|
132
|
+
profile_id: {
|
|
133
|
+
type: "string",
|
|
134
|
+
description: "Reuse a saved identity (see list_identities) so the browser starts with its cookies and logins."
|
|
135
|
+
},
|
|
136
|
+
proxy: {
|
|
137
|
+
type: "object",
|
|
138
|
+
description: `One of two forms. Your own proxy: give host and port, or server as "host:port" / "socks5://host:port", plus username and password when it needs them. Or a tier of Browsa's built-in proxy network, billed per GB from credits: {"network": "datacenter"} or {"network": "residential", "country": "us"}, with nothing else next to network. The built-in network works only when the proxy_network tool reports enabled: call it first for the tiers, their countries and the price per GB.`,
|
|
139
|
+
properties: {
|
|
140
|
+
network: { type: "string", enum: ["datacenter", "residential"], description: "Built-in network tier. Not together with host, port, server, username, password or type." },
|
|
141
|
+
country: { type: "string", description: 'Lowercase ISO alpha-2 exit country, e.g. "us". Optional.' },
|
|
142
|
+
type: { type: "string", enum: ["http", "https", "socks5"], description: "Own proxy only." },
|
|
143
|
+
host: { type: "string", description: "Own proxy only." },
|
|
144
|
+
port: { type: "integer", description: "Own proxy only." },
|
|
145
|
+
server: { type: "string", description: 'Own proxy only: "host:port" or "scheme://host:port".' },
|
|
146
|
+
username: { type: "string", description: "Own proxy only." },
|
|
147
|
+
password: { type: "string", description: "Own proxy only." }
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
name: "proxy_network",
|
|
155
|
+
description: `Say whether Browsa's built-in proxy network is enabled on this server and, when it is, list its tiers (datacenter, residential) with the exit countries of each and the price per GB in credits. Call this before passing proxy {"network": ...} to start_browser. When enabled is false, only your own proxy can be used.`,
|
|
156
|
+
inputSchema: { type: "object", properties: {} }
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
name: "stop_browser",
|
|
160
|
+
description: "Stop a browser started with start_browser and release it. Always call this when finished; an unused browser keeps running until its ttl expires.",
|
|
161
|
+
inputSchema: {
|
|
162
|
+
type: "object",
|
|
163
|
+
required: ["browser_id"],
|
|
164
|
+
properties: { browser_id: { type: "string", description: "The id returned by start_browser." } }
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
name: "observe",
|
|
169
|
+
description: 'Read the page of a browser started with start_browser, as compact text: one line per element, [id] role "name" state, inside a token budget. Use the ids with the act tool. No Playwright or CDP needed, and no extra charge. Ids stay valid across observe and act calls until the page loads a new document. On a full-page bot check nothing is read and the first lines say so.',
|
|
170
|
+
inputSchema: {
|
|
171
|
+
type: "object",
|
|
172
|
+
required: ["browser_id"],
|
|
173
|
+
properties: {
|
|
174
|
+
browser_id: { type: "string", description: "The id returned by start_browser." },
|
|
175
|
+
scope: { type: "string", enum: ["viewport", "page"], description: "viewport (default): what is in the viewport, the rest counted. page: the whole page." },
|
|
176
|
+
budget: { type: "integer", description: "Approximate tokens for the view. Default 2000." },
|
|
177
|
+
expand: { type: "integer", description: "Id of a container, table, list or select to list in full." },
|
|
178
|
+
tab: { type: "string", description: "Tab id, from the tabs line of an earlier observe. Default: the tab used last." }
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
name: "act",
|
|
184
|
+
description: "Perform one action in a browser started with start_browser and get back what changed (~ changed, + added, - removed), or a new view after a navigation. Input is sent as real mouse and key events. Name the element by id from observe, or by role and name, or click a point with x and y. The first line of the answer says failed, blocked, challenge or stale when the action did not go through. stale: the ids are from a view that no longer exists, nothing was done, and a new view follows.",
|
|
185
|
+
inputSchema: {
|
|
186
|
+
type: "object",
|
|
187
|
+
required: ["browser_id", "action"],
|
|
188
|
+
properties: {
|
|
189
|
+
browser_id: { type: "string", description: "The id returned by start_browser." },
|
|
190
|
+
action: {
|
|
191
|
+
type: "string",
|
|
192
|
+
enum: ["click", "type", "press", "select", "check", "uncheck", "hover", "scroll", "navigate", "back", "forward", "reload", "wait", "upload", "dialog"]
|
|
193
|
+
},
|
|
194
|
+
id: { type: "integer", description: "Target element id, from observe." },
|
|
195
|
+
role: { type: "string", description: "With name: the first element with this role and name, instead of id." },
|
|
196
|
+
name: { type: "string" },
|
|
197
|
+
x: { type: "number", description: "click: a viewport point instead of an element (with y)." },
|
|
198
|
+
y: { type: "number" },
|
|
199
|
+
text: { type: "string", description: "type: the text. wait for text: the text. dialog: the prompt answer." },
|
|
200
|
+
clear: { type: "boolean", description: "type: empty the field first." },
|
|
201
|
+
submit: { type: "boolean", description: "type: press Enter afterwards." },
|
|
202
|
+
keys: { type: "string", description: 'press: Enter, Escape, Control+A, or a sequence such as "Tab Tab Enter".' },
|
|
203
|
+
option: { type: "string", description: "select: option text or value." },
|
|
204
|
+
double: { type: "boolean", description: "click: double click." },
|
|
205
|
+
right: { type: "boolean", description: "click: right button." },
|
|
206
|
+
dy: { type: "integer", description: "scroll: pixels, positive is down." },
|
|
207
|
+
to: { type: "string", enum: ["top", "bottom"], description: "scroll." },
|
|
208
|
+
url: { type: "string", description: "navigate." },
|
|
209
|
+
ms: { type: "integer", description: "wait: a fixed time in milliseconds, at most 30000." },
|
|
210
|
+
for: { type: "string", enum: ["text", "id-gone", "url-change"], description: "wait: for text to appear, an element to go, or the URL to change." },
|
|
211
|
+
timeout: { type: "integer", description: "wait: milliseconds, default 10000, at most 30000." },
|
|
212
|
+
files: { type: "array", items: { type: "string" }, description: "upload: file paths on the browser's machine." },
|
|
213
|
+
accept: { type: "boolean", description: "dialog: accept (true) or dismiss." },
|
|
214
|
+
tab: { type: "string", description: "Tab id. Default: the tab used last." }
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
name: "list_browsers",
|
|
220
|
+
description: "List this workspace's browsers (burners and saved identities) with their status.",
|
|
221
|
+
inputSchema: { type: "object", properties: {} }
|
|
222
|
+
},
|
|
117
223
|
{
|
|
118
224
|
name: "credits",
|
|
119
225
|
description: "Get the current credit balance + available top-up packs.",
|
|
@@ -156,7 +262,7 @@ var tools = [
|
|
|
156
262
|
},
|
|
157
263
|
{
|
|
158
264
|
name: "create_schedule",
|
|
159
|
-
description: `Schedule a browser task to run automatically on a fixed interval (min 1 hour). Each run is a normal billed task. LLM key: same rules as run_task (the workspace's default saved key unless llm_key_id is given); the schedule stores only the saved key's id. With no llm and no saved key, the schedule runs on Browsa's hosted model and the result says so. Pass llm
|
|
265
|
+
description: `Schedule a browser task to run automatically on a fixed interval (min 1 hour). Each run is a normal billed task. LLM key: same rules as run_task (the workspace's default saved key unless llm_key_id is given); the schedule stores only the saved key's id. With no llm and no saved key, the schedule runs on Browsa's hosted model and the result says so. Pass llm "browsa", "browsa-fast" or "browsa-smart" to choose a hosted tier.`,
|
|
160
266
|
inputSchema: {
|
|
161
267
|
type: "object",
|
|
162
268
|
required: ["task", "interval_seconds"],
|
|
@@ -166,8 +272,9 @@ var tools = [
|
|
|
166
272
|
name: { type: "string", description: "Optional label for the schedule." },
|
|
167
273
|
llm: {
|
|
168
274
|
type: "string",
|
|
169
|
-
description: `LLM id${DEFAULT_LLM ? ` (default ${DEFAULT_LLM})` : ""}. Omit to use the workspace's default saved key (hosted model if none is saved)
|
|
275
|
+
description: `LLM id${DEFAULT_LLM ? ` (default ${DEFAULT_LLM})` : ""}. Omit to use the workspace's default saved key (hosted model if none is saved). Hosted tiers: "browsa", "browsa-fast", "browsa-smart".`
|
|
170
276
|
},
|
|
277
|
+
reasoning: REASONING_PROP,
|
|
171
278
|
llm_key_id: { type: "string", description: "Id of a saved LLM key (see list_llm_keys). Optional." },
|
|
172
279
|
llm_api_key: {
|
|
173
280
|
type: "string",
|
|
@@ -189,6 +296,11 @@ var tools = [
|
|
|
189
296
|
description: "List the LLM provider keys saved in this workspace: id, name, provider, masked key (prefix + last 4), whether it is the default for its provider, and its status (valid, invalid or unchecked). Never returns a secret. Pass an id as llm_key_id to run_task or create_schedule. Keys are added at " + LLM_KEYS_URL + ".",
|
|
190
297
|
inputSchema: { type: "object", properties: {} }
|
|
191
298
|
},
|
|
299
|
+
{
|
|
300
|
+
name: "list_models",
|
|
301
|
+
description: "List the hosted tiers (browsa, browsa-fast, browsa-smart: the model each runs on, its default reasoning and credits per task) and the providers a saved or per-task LLM key can be for. Read-only and free.",
|
|
302
|
+
inputSchema: { type: "object", properties: {} }
|
|
303
|
+
},
|
|
192
304
|
{
|
|
193
305
|
name: "list_job_files",
|
|
194
306
|
description: "List the output files a task wrote \u2014 extracted data + a session.gif recording. Returns name + size per file.",
|
|
@@ -214,7 +326,8 @@ function fail(message, extra) {
|
|
|
214
326
|
}
|
|
215
327
|
function chooseLlm(args) {
|
|
216
328
|
const llm = args.llm ?? DEFAULT_LLM;
|
|
217
|
-
|
|
329
|
+
const tier = String(llm ?? "").trim().toLowerCase();
|
|
330
|
+
if (tier === "browsa" || tier.startsWith("browsa-")) return { llm: tier, source: "hosted" };
|
|
218
331
|
if (args.llm_api_key) return { llm: llm ?? BYOK_DEFAULT_LLM, llmApiKey: args.llm_api_key, source: "per_task" };
|
|
219
332
|
if (args.llm_key_id) return { llm, llmKeyId: args.llm_key_id, source: "saved" };
|
|
220
333
|
if (DEFAULT_LLM_KEY) return { llm: llm ?? BYOK_DEFAULT_LLM, llmApiKey: DEFAULT_LLM_KEY, source: "per_task" };
|
|
@@ -223,8 +336,8 @@ function chooseLlm(args) {
|
|
|
223
336
|
}
|
|
224
337
|
var HOSTED = { llm: "browsa", source: "hosted" };
|
|
225
338
|
var NO_KEY_HELP = `No LLM key for this task: the workspace has no default saved key for this model's provider. Save a key at ${LLM_KEYS_URL} (the first key of a provider becomes its default), or set BROWSA_LLM_API_KEY in the MCP env, or pass llm:"browsa" to run on Browsa's hosted model.`;
|
|
226
|
-
var HOSTED_FALLBACK_TASK_NOTE = `No saved LLM key found, so this ran on Browsa's hosted model (adds
|
|
227
|
-
var HOSTED_FALLBACK_SCHEDULE_NOTE = `No saved LLM key found, so this schedule runs on Browsa's hosted model (adds
|
|
339
|
+
var HOSTED_FALLBACK_TASK_NOTE = `No saved LLM key found, so this ran on Browsa's hosted model (adds credits per task; see list_models). Save a key at ${LLM_KEYS_URL} to use your own.`;
|
|
340
|
+
var HOSTED_FALLBACK_SCHEDULE_NOTE = `No saved LLM key found, so this schedule runs on Browsa's hosted model (adds credits per run; see list_models). Save a key at ${LLM_KEYS_URL} and create the schedule again to use your own.`;
|
|
228
341
|
function canFallBackToHosted(e, choice) {
|
|
229
342
|
if (choice.source !== "default" || choice.llm !== void 0) return false;
|
|
230
343
|
return e.status === 400 && e.code === "LLM_KEY_REQUIRED" || e.status === 503 && e.code === "LLM_KEYS_UNAVAILABLE";
|
|
@@ -261,15 +374,98 @@ function llmKeyError(e, choice) {
|
|
|
261
374
|
}
|
|
262
375
|
return null;
|
|
263
376
|
}
|
|
264
|
-
async function
|
|
377
|
+
async function proxyNetwork() {
|
|
265
378
|
const base = (BASE_URL || "https://browsa.io").replace(/\/+$/, "");
|
|
266
|
-
const resp = await fetch(`${base}/v1/
|
|
267
|
-
headers: { "X-API-Key": API_KEY, Accept: "application/json", "User-Agent": "browsa-mcp/0.
|
|
379
|
+
const resp = await fetch(`${base}/v1/proxy-network`, {
|
|
380
|
+
headers: { "X-API-Key": API_KEY, Accept: "application/json", "User-Agent": "browsa-mcp/0.3.1" }
|
|
268
381
|
});
|
|
269
382
|
const body = await resp.json().catch(() => ({}));
|
|
383
|
+
if (resp.status === 404) return { enabled: false, tiers: [] };
|
|
270
384
|
if (!resp.ok) {
|
|
271
385
|
throw new BrowsaError(body?.error || `HTTP ${resp.status}`, { code: body?.code, requestId: body?.request_id, status: resp.status });
|
|
272
386
|
}
|
|
387
|
+
const tiers = body?.enabled === true && Array.isArray(body?.tiers) ? body.tiers : [];
|
|
388
|
+
return {
|
|
389
|
+
enabled: body?.enabled === true,
|
|
390
|
+
tiers: tiers.map((t) => ({
|
|
391
|
+
network: t?.network,
|
|
392
|
+
credits_per_gb: t?.credits_per_gb,
|
|
393
|
+
mb_per_credit: t?.mb_per_credit,
|
|
394
|
+
countries: Array.isArray(t?.countries) ? t.countries : []
|
|
395
|
+
}))
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
function proxyUsage(raw) {
|
|
399
|
+
if (!raw || typeof raw.proxy_network !== "string" || !raw.proxy_network) return {};
|
|
400
|
+
return { proxy_network: raw.proxy_network, proxy_bytes: raw.proxy_bytes ?? 0, proxy_credits: raw.proxy_credits ?? 0 };
|
|
401
|
+
}
|
|
402
|
+
async function apiGet(path) {
|
|
403
|
+
const base = (BASE_URL || "https://browsa.io").replace(/\/+$/, "");
|
|
404
|
+
const resp = await fetch(`${base}${path}`, {
|
|
405
|
+
headers: { "X-API-Key": API_KEY, Accept: "application/json", "User-Agent": "browsa-mcp/0.3.1" }
|
|
406
|
+
});
|
|
407
|
+
const body = await resp.json().catch(() => ({}));
|
|
408
|
+
if (!resp.ok) {
|
|
409
|
+
throw new BrowsaError(body?.error || `HTTP ${resp.status}`, { code: body?.code, requestId: body?.request_id, status: resp.status });
|
|
410
|
+
}
|
|
411
|
+
return body;
|
|
412
|
+
}
|
|
413
|
+
async function apiPost(path, payload, timeoutMs = 9e4) {
|
|
414
|
+
const base = (BASE_URL || "https://browsa.io").replace(/\/+$/, "");
|
|
415
|
+
const resp = await fetch(`${base}${path}`, {
|
|
416
|
+
method: "POST",
|
|
417
|
+
headers: {
|
|
418
|
+
"X-API-Key": API_KEY,
|
|
419
|
+
Accept: "application/json",
|
|
420
|
+
"Content-Type": "application/json",
|
|
421
|
+
"User-Agent": "browsa-mcp/0.3.1"
|
|
422
|
+
},
|
|
423
|
+
body: JSON.stringify(payload),
|
|
424
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
425
|
+
});
|
|
426
|
+
const body = await resp.json().catch(() => ({}));
|
|
427
|
+
if (!resp.ok) {
|
|
428
|
+
throw new BrowsaError(body?.error || `HTTP ${resp.status}`, { code: body?.code, requestId: body?.request_id, status: resp.status });
|
|
429
|
+
}
|
|
430
|
+
return body;
|
|
431
|
+
}
|
|
432
|
+
var pageSessions = /* @__PURE__ */ new Map();
|
|
433
|
+
async function pageCall(route, args) {
|
|
434
|
+
const { browser_id, ...body } = args;
|
|
435
|
+
const seen = pageSessions.get(browser_id);
|
|
436
|
+
const session = seen ? seen.tabs.get(body.tab ?? seen.last) : void 0;
|
|
437
|
+
if (session) body.session = session;
|
|
438
|
+
const r = await apiPost(`/v1/agents/${encodeURIComponent(browser_id)}/${route}`, body);
|
|
439
|
+
if (r?.tab && r?.session) {
|
|
440
|
+
const next = seen ?? { last: "", tabs: /* @__PURE__ */ new Map() };
|
|
441
|
+
next.last = r.tab;
|
|
442
|
+
next.tabs.set(r.tab, r.session);
|
|
443
|
+
pageSessions.set(browser_id, next);
|
|
444
|
+
}
|
|
445
|
+
let text = r?.text ?? "";
|
|
446
|
+
if (Array.isArray(r?.tabs) && r.tabs.length > 1) {
|
|
447
|
+
text += "\ntabs: " + r.tabs.map((t) => `${t.id} ${JSON.stringify(t.title || t.url || "")}${t.active ? " (this one)" : ""}`).join(" | ");
|
|
448
|
+
}
|
|
449
|
+
return text;
|
|
450
|
+
}
|
|
451
|
+
async function listModels() {
|
|
452
|
+
const body = await apiGet("/v1/models");
|
|
453
|
+
return { hosted: body?.hosted ?? [], own_key: body?.own_key ?? {} };
|
|
454
|
+
}
|
|
455
|
+
function outcomeFields(job) {
|
|
456
|
+
return {
|
|
457
|
+
outcome: job.outcome,
|
|
458
|
+
outcome_message: job.outcomeMessage,
|
|
459
|
+
...job.signals && job.signals.length ? { signals: job.signals } : {}
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
function llmResultFields(job) {
|
|
463
|
+
const r = job.raw?.result;
|
|
464
|
+
if (!r || typeof r !== "object") return {};
|
|
465
|
+
return { llm_tier: r.llm_tier, reasoning: r.reasoning, usage: r.usage, llm_cost_usd: r.llm_cost_usd };
|
|
466
|
+
}
|
|
467
|
+
async function listLlmKeys() {
|
|
468
|
+
const body = await apiGet("/v1/llm-keys");
|
|
273
469
|
return {
|
|
274
470
|
llm_keys: (body?.llm_keys ?? []).map((k) => ({
|
|
275
471
|
id: k.id,
|
|
@@ -304,6 +500,7 @@ server.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
|
304
500
|
llm: c.llm,
|
|
305
501
|
llmApiKey: c.llmApiKey,
|
|
306
502
|
llmKeyId: c.llmKeyId,
|
|
503
|
+
reasoning: args.reasoning,
|
|
307
504
|
country: args.country ?? DEFAULT_COUNTRY,
|
|
308
505
|
maxSteps: args.max_steps,
|
|
309
506
|
initialUrl: args.initial_url,
|
|
@@ -316,11 +513,14 @@ server.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
|
316
513
|
...fellBack ? { note: HOSTED_FALLBACK_TASK_NOTE, llm: "browsa" } : {},
|
|
317
514
|
job_id: job.id,
|
|
318
515
|
status: job.status,
|
|
516
|
+
...outcomeFields(job),
|
|
319
517
|
steps: `${job.stepCount}/${job.progressTotal}`,
|
|
320
518
|
live_url: job.liveUrl,
|
|
321
519
|
credits_charged: job.creditsCharged,
|
|
520
|
+
...proxyUsage(job.raw),
|
|
322
521
|
llm_key_masked: job.raw?.llm_key_masked,
|
|
323
522
|
llm_key_source: job.raw?.llm_key_source,
|
|
523
|
+
...llmResultFields(job),
|
|
324
524
|
final_result: job.finalResult,
|
|
325
525
|
error: job.errorMessage,
|
|
326
526
|
error_code: job.errorCode
|
|
@@ -331,12 +531,15 @@ server.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
|
331
531
|
return ok({
|
|
332
532
|
job_id: job.id,
|
|
333
533
|
status: job.status,
|
|
534
|
+
...outcomeFields(job),
|
|
334
535
|
steps: `${job.stepCount}/${job.progressTotal}`,
|
|
335
536
|
live_url: job.liveUrl,
|
|
336
537
|
input_question: job.inputQuestion,
|
|
538
|
+
...llmResultFields(job),
|
|
337
539
|
final_result: job.finalResult,
|
|
338
540
|
error: job.errorMessage,
|
|
339
|
-
error_code: job.errorCode
|
|
541
|
+
error_code: job.errorCode,
|
|
542
|
+
...proxyUsage(job.raw)
|
|
340
543
|
});
|
|
341
544
|
}
|
|
342
545
|
case "cancel_job": {
|
|
@@ -347,6 +550,38 @@ server.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
|
347
550
|
const job = await client.respondToJob(args.job_id, args.response);
|
|
348
551
|
return ok({ job_id: job.id, status: job.status });
|
|
349
552
|
}
|
|
553
|
+
case "start_browser": {
|
|
554
|
+
const a = await client.createAgent({
|
|
555
|
+
ttl: args.ttl ?? "10m",
|
|
556
|
+
country: args.country ?? DEFAULT_COUNTRY,
|
|
557
|
+
osType: args.os_type,
|
|
558
|
+
agent_id: args.profile_id,
|
|
559
|
+
proxy: args.proxy
|
|
560
|
+
});
|
|
561
|
+
return ok({
|
|
562
|
+
browser_id: a.id,
|
|
563
|
+
status: a.status,
|
|
564
|
+
// Connect with playwright.chromium.connect_over_cdp(cdp_http,
|
|
565
|
+
// headers={"X-API-Key": <your key>}); cdp_url is the page socket.
|
|
566
|
+
cdp_http: a.cdp_http,
|
|
567
|
+
cdp_url: a.cdp_url,
|
|
568
|
+
live_url: a.live_url,
|
|
569
|
+
expires_at: a.expires_at,
|
|
570
|
+
credits_charged: a.cost_credits,
|
|
571
|
+
...proxyUsage(a),
|
|
572
|
+
egress: args.proxy?.network ? `Browsa ${args.proxy.network} proxy network` : args.proxy ? "your proxy" : "Browsa's data-center IP",
|
|
573
|
+
note: "Call stop_browser with this browser_id when you are done."
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
case "stop_browser":
|
|
577
|
+
await client.destroyAgent(args.browser_id);
|
|
578
|
+
return ok({ stopped: args.browser_id });
|
|
579
|
+
case "observe":
|
|
580
|
+
return ok(await pageCall("observe", args));
|
|
581
|
+
case "act":
|
|
582
|
+
return ok(await pageCall("act", args));
|
|
583
|
+
case "list_browsers":
|
|
584
|
+
return ok(await client.listIdentities());
|
|
350
585
|
case "credits":
|
|
351
586
|
return ok(await client.credits());
|
|
352
587
|
case "list_webhooks":
|
|
@@ -368,6 +603,7 @@ server.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
|
368
603
|
llm: c.llm,
|
|
369
604
|
llmApiKey: c.llmApiKey,
|
|
370
605
|
llmKeyId: c.llmKeyId,
|
|
606
|
+
reasoning: args.reasoning,
|
|
371
607
|
intervalSeconds: args.interval_seconds,
|
|
372
608
|
country: args.country ?? DEFAULT_COUNTRY,
|
|
373
609
|
maxSteps: args.max_steps,
|
|
@@ -391,6 +627,7 @@ server.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
|
391
627
|
name: s.name,
|
|
392
628
|
task: s.task,
|
|
393
629
|
llm: s.llm,
|
|
630
|
+
reasoning: s.raw?.reasoning ?? void 0,
|
|
394
631
|
interval_seconds: s.intervalSeconds,
|
|
395
632
|
enabled: s.enabled,
|
|
396
633
|
next_run_at: s.nextRunAt,
|
|
@@ -401,6 +638,10 @@ server.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
|
401
638
|
return ok(await client.listJobFiles(args.job_id));
|
|
402
639
|
case "list_llm_keys":
|
|
403
640
|
return ok(await listLlmKeys());
|
|
641
|
+
case "proxy_network":
|
|
642
|
+
return ok(await proxyNetwork());
|
|
643
|
+
case "list_models":
|
|
644
|
+
return ok(await listModels());
|
|
404
645
|
default:
|
|
405
646
|
return fail(`unknown tool: ${name}`);
|
|
406
647
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@browsa/mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"mcpName": "io.browsa/browsa",
|
|
4
5
|
"description": "MCP server for Browsa: drive real cloud browsers from Claude Desktop, Cursor, Cline, and any MCP-compatible client",
|
|
5
6
|
"license": "MIT",
|
|
6
7
|
"author": "Browsa <support@browsa.io>",
|
|
7
8
|
"homepage": "https://browsa.io",
|
|
8
9
|
"bugs": {
|
|
10
|
+
"url": "https://github.com/browsa-io/browsa/issues",
|
|
9
11
|
"email": "support@browsa.io"
|
|
10
12
|
},
|
|
11
13
|
"keywords": [
|
|
@@ -40,11 +42,16 @@
|
|
|
40
42
|
},
|
|
41
43
|
"dependencies": {
|
|
42
44
|
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
43
|
-
"browsa": "^0.
|
|
45
|
+
"browsa": "^0.3.1"
|
|
44
46
|
},
|
|
45
47
|
"devDependencies": {
|
|
46
48
|
"@types/node": "^20",
|
|
47
49
|
"tsup": "^8",
|
|
48
50
|
"typescript": "^5"
|
|
51
|
+
},
|
|
52
|
+
"repository": {
|
|
53
|
+
"type": "git",
|
|
54
|
+
"url": "git+https://github.com/browsa-io/browsa.git",
|
|
55
|
+
"directory": "browsa-mcp"
|
|
49
56
|
}
|
|
50
57
|
}
|