Run JavaScript
browser_evaluateExecutes JavaScript expressions or functions on the current page, awaits promises, and returns JSON-compatible results for extracting dynamic data and checking page state.
Instructions
Run JavaScript on the current page, await promises, and return JSON text without a snapshot. Return JSON-compatible values; null/undefined become null. Script effects are not undone on failure. Cancellation stops waiting, but may not stop the script.
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": {
"session_id": "<session_id>",
"expression": "<expression>"
},
"name": "browser_evaluate"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| arg | No | JSON object passed to the function; use properties for scalar or array values. | |
| expression | Yes | JavaScript expression or function to invoke. | |
| session_id | Yes | ID from `browser_open`; call `browser_fetch` first. | |
| isolated_context | No | False accesses the page's own JS variables; True uses a separate context with the same DOM. |