evaluate_script
Runs a JavaScript function in the currently selected page and returns the result as JSON. Use it to extract page data or automate browser actions.
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 arguments to pass to the function. | |
| function | Yes | A JavaScript function declaration to be executed by the tool 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; }` | |
| dialogAction | No | Handle dialogs while execution. "accept", "dismiss", or string for response of window.prompt. Defaults to accept. |