javascript_tool
Executes JavaScript in a browser tab and returns the last expression's value or a top-level return, awaiting promises. Runs in the page's main world or an isolated world.
Instructions
Run JavaScript in a tab and return the value of the last expression, or of a top-level return (promises are awaited; the value must be JSON-serializable, DOM nodes cannot be returned). world "main" (default) is the page's own world; "isolated" cannot be seen by the page and sees no page-defined globals. The result is returned as is: this is the one tool whose output is NOT masked, so do not print cookies or tokens you do not need. Do not call alert / confirm / prompt without arming handle_dialog.
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": {
"text": "<text>"
},
"name": "javascript_tool"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | JavaScript. The result is the value of the last expression, or of a top-level return. | |
| tabId | No | Tab to act on, from tabs_context. Omitted: this session's active tab. Pass it always when several agents share the session. | |
| world | No | ||
| max_chars | No | Cap on the result size (default 20000). | |
| timeout_s | No | Seconds before giving up (default 20). |