-
Notifications
You must be signed in to change notification settings - Fork 0
execute_script
Kelly Ferrone edited this page Sep 9, 2026
·
4 revisions
Run JavaScript in the page and return its result.
| MCP tool | execute_script |
| HTTP | POST /browser/script |
The escape hatch for anything the other tools do not cover: scrolling (window.scrollTo(0, 2000)), drag and drop, computed styles, direct DOM access. Use return to send a value back.
| Name | Type | Required | Default | Notes |
|---|---|---|---|---|
script |
string | yes | — | |
session_id |
string | yes over HTTP | — | The session_id returned by /browser/open. Required here. |
url |
string | no | — |
| Field | Type | Notes |
|---|---|---|
result |
any | Whatever the script returned. Any JSON type. |
url |
string | Current URL after the action. |
title |
string | Page title after the action. |
Errors are 400 for a bad argument, 401 without a token, 500 when the Grid
refuses. Over MCP the same failures arrive as a tool error.
MCP
execute_script(script="…")
HTTP
curl -X POST $SELENIUM_FLOW/browser/script \
-H "Authorization: Bearer $TOKEN" \
-H 'Content-Type: application/json' \
-d '{
"session_id": "…",
"script": "…"
}'The action pages are generated from openapi.yaml, which is itself generated from the live MCP tool schemas — so they describe the server that shipped, not the one someone remembered. Prose belongs in wiki-notes/<tool>.md in the repo.
selenium-flow · MIT
Start here
Lifecycle
Going places
Doing things
Getting things out