Execute JavaScript in the Browser REPL
Execute JavaScript in a persistent Node.js Browser REPL. Start with live help:
repl.help(); // List methods
repl.help("click"); // Signature, behavior, defaults, and example
repl.help("webmcp.invokeTool");
Available methods:
<!-- BEGIN GENERATED REPL METHOD LIST -->- REPL: repl.help, repl.write, repl.emitImage
- Browser control: cdp, drainEvents, waitForEvent, gotoUrl, pageInfo, accessibilitySnapshot, click, typeText, fillInput, pressKey, scroll, captureScreenshot, listTabs, currentTab, switchTab, newTab, closeTab, ensureRealTab, iframeTarget, waitMs, waitForLoad, waitForElement, waitForNetworkIdle, js, uploadFile, httpGet
- WebMCP: webmcp.listTools, webmcp.invokeTool, webmcp.addCustomTools, webmcp.listCustomTools, webmcp.removeCustomTool
Browser-control methods are available both directly and on browser. The same frozen browser-wide WebMCP client is available as webmcp and browser.webmcp, including custom tool add, list, and remove methods. webmcp.listTools() discovers tools through GET /webmcp/tools, and webmcp.invokeTool() calls POST /webmcp/invoke. Common workflows:
await gotoUrl("https://example.com");
await waitForLoad();
const tree = await accessibilitySnapshot();
const link = tree.nodes.find(node => node.role === "link" && node.name === "More information...");
if (!link) throw new Error("link not found");
await click(link);
const path = await captureScreenshot("/tmp/page.png", true, 1600);
await repl.emitImage({path});
Top-level bindings and dynamically imported modules persist until reset or process replacement. Expression values are ignored; emit output with repl.write(...), console methods, or repl.emitImage(...). Pinned patchright and playwright-core packages are available through dynamic import(), and cdp() provides unrestricted DevTools access.
The runtime starts lazily and is owned by the API process. Reset, API restart, timeout, crash, OOM, or protocol failure destroys its state and changes its CUID2 repl_id. Executions are serialized. This endpoint is unrestricted code execution inside the browser VM, equivalent in trust level to the process and Playwright execution APIs; it is not sandboxed.
Request body
Response
Code executed (success or structured failure)
Changes
Changed in 1 of the 65 revisions of this API.1
- ○
endpoint added
endpoint-added
- ○