Evaluate JavaScript
browser_evaluateExecute custom JavaScript in the live browser page. Pass an arrow function as a string to read data or modify the page; optionally target an element to receive it as an argument.
Instructions
Run JavaScript in the page. Pass an arrow function as a string: "() => document.title". With target, the function receives the element.
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": "browser_evaluate"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| target | No | Element ref or CSS selector to pass to the function | |
| filename | No | Save the result to this file instead of returning it | |
| function | Yes | () => { /* code */ } or (el) => { /* code */ } when target is given |