run_script reference
run_script is the action path of the MCP server. It runs sandboxed
JavaScript against the live browser session — page, context,
request, browser, and standard web APIs are bound globals. One tool
call can navigate, fill forms, click, assert, and make HTTP calls in
one atomic LLM turn.
Parameters
Pass either source (inline JavaScript) or path (relative path
to a .js / .mjs / .ts / .tsx / .mts / .cts file under
script_root) — not both. A TypeScript file, or any file with
top-level import / export, is bundled and run as an ES module
whose default export is the result.
source is wrapped in an async IIFE; use return <value> for the
result. Top-level await works.
args is bound to the global of the same name. It is never
interpolated into the source string — use this for any caller-controlled
data to keep prompt-injection out.
Return shape
Always a structured JSON payload:
Success
Failure
Scripts that throw surface as status: "error" in the payload —
not as MCP-level errors. Callers can inspect the failure without
catching protocol exceptions.
Globals
ES module import './foo.js' resolves inside script_root with the
same sandbox rules. Bare specifiers (import 'lodash') are rejected —
no node_modules resolution at runtime.
Examples
Login + extract
Call as:
Cross-call session state
Scraping with request
Web fetch (WHATWG-spec)
fetch shares the same HTTP core as request — cookies, sessions, and
any allow.net restriction bind both.
Configuration
The engine defaults are fixed in the server: a 5-minute timeout, a
256 MiB memory quota, script_root at ./.ferridriver/scripts (for
path / fs / imports), and artifacts_root at
./.ferridriver/artifacts (for artifacts.*). Override the timeout and
memory quota per call via the timeout_ms / memory_limit_mb
parameters above (each capped by the server maximum).
The one scripting knob in ferridriver.toml is the process.env
allow-list:
See Sandbox for process / fetch / fs /
AbortController details and what is absent, and
State and sessions for globalThis vs
vars lifetime.