evaluate_script
Execute JavaScript functions in the active Safari page and receive JSON-serializable results for automation and debugging.
Instructions
Evaluate a JavaScript function inside the currently selected page. Returns the response as JSON, so returned values have to be JSON-serializable.
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": {
"function": "<function>"
},
"name": "evaluate_script"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| args | No | An optional list of element UIDs to pass as arguments. | |
| function | Yes | A JavaScript function declaration to be executed in the currently selected page. Example without arguments: `() => { return document.title }` or `async () => { return await fetch("example.com") }`. Example with arguments: `(el) => { return el.innerText; }` |