Skip to main content
Glama

Run browser script

run_script
Destructive

Batches multiple BrowserTwin browser steps into one JavaScript script: open or resume a space, act, wait, and log the output a next step needs. Returns console output and errors.

Instructions

Run a BrowserTwin SDK script (JavaScript, top-level await; same API as btwin nodejs, see resource wwt-lite://guide or help()). Batch several steps into one script: open or resume a space, act, wait, then console.log what the next step needs (a snapshot last). Returns the console output and errors. If the output says the user has control, stop and tell the user.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "code": "<code>"
    },
    "name": "run_script"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYesScript body, e.g. const task = await taskSpace("goal"); const page = task.page("p1"); await page.goto("http://127.0.0.1:8080/"); console.log(await page.snapshot());

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.9/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare destructiveHint=true, openWorldHint=true, and idempotentHint=false, so the safety profile is known. The description adds real behavior beyond that: it returns console output and errors, it runs top-level await, and it defines the control-handoff condition under which the agent must halt and defer to the user. It does not spell out what a script can destroy or any timeouts/limits, which is the remaining gap for a destructive tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the core action and API identity, then the recommended workflow, then the return value and the stop condition. Dense and mostly waste-free, though the parenthetical API references make the opening sentence long.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema exists, and the description compensates by saying it returns console output and errors plus the special control-handoff message. Combined with the workflow sketch and API pointer, an agent has enough to invoke it correctly; only execution limits and failure/timeout behavior are left unstated.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

There is a single parameter at 100% schema coverage, and the schema's own example already shows a full script body. The description adds marginal meaning ('top-level await', 'same API as btwin nodejs', reference to resource wwt-lite://guide or help()) that helps the agent write valid code, but the syntax/format burden still rests largely on the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a concrete verb and resource ('Run a BrowserTwin SDK script') and scopes it as JavaScript with top-level await and a btwin-nodejs-compatible API. It partially separates itself from single-action siblings by framing itself as the way to 'batch several steps into one script', but it never names an alternative tool outright, so the differentiation is implied rather than explicit.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives a clear usage pattern (open or resume a space, act, wait, then console.log what the next step needs) and an operational rule for when to stop ('If the output says the user has control, stop and tell the user'). It stops short of telling the agent when a single-purpose sibling like run_actions or snapshot would be preferable.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.