browser_evaluate
Run JavaScript expressions or functions inside a live browser page or element context to read DOM state, computed values, and page data during automation.
Instructions
Evaluate a JavaScript expression or function in the browser page context (or on a specific element ref).
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 |
|---|---|---|---|
| ref | No | Optional element ref to pass as the first argument to the function. | |
| element | No | Human-readable description of the element if ref is specified. | |
| function | Yes | JavaScript function or expression string, e.g. '() => document.title' or '(el) => el.textContent'. | |
| sessionId | No | Optional target browser session ID. If omitted, uses the currently active session (or auto-launches one). |