stagehand_run_script
Run a Stagehand script against the active browser session to validate it. Accepts file path or inline source, reusing the live session with no extra setup.
Instructions
Run a Stagehand script (default export from defineScript) against the
current browser session. Accepts either a file path or inline
source — exactly one. Returns {status: "passed"|"failed", durationMs}.
On failure also returns error and stack. Use after authoring a script
to validate it; the MCP's live session is reused, so no separate setup
is required. Inline source mode resolves bare imports against the
MCP's own node_modules (no install needed); path mode resolves
from the script's project.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ctx | No | Optional context object forwarded to the script as `ctx`. The default Ctx shape accepts baseUrl, username, password, and any other string fields without schema declaration. Scripts that declare a custom Ctx generic are responsible for their own runtime validation. | |
| path | No | Path to a .ts or .js file whose default export was produced by defineScript(...). Relative paths resolve against the MCP process's current working directory. Bare imports from the script resolve against the script's own node_modules tree, so the script's project must have the needed deps installed (including @popoverai/browser-automation for defineScript). Mutually exclusive with `source`. | |
| source | No | Inline script source as an alternative to `path`. Useful when the caller has no filesystem access, or when the script is ephemeral. The script is run from a temp location inside the MCP's own package, so bare imports (defineScript, zod, etc.) resolve against the MCP's node_modules — no install required anywhere else. Mutually exclusive with `path`. |