执行 JavaScript
browser_evaluateEvaluate a JavaScript expression in the page or a referenced element and return the result as JSON, enabling retrieval of computed styles or JS variables not available from snapshots or extraction.
Instructions
Evaluate a JavaScript expression in the page (or on a specific element by ref) and return the result as JSON. Runs in the page main world. Use for values not exposed by snapshot/extract, e.g. reading a computed style or a JS variable. The expression must be a single expression or IIFE.
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": {
"expression": "<expression>"
},
"name": "browser_evaluate"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ref | No | Element ref to bind as the `element` variable (optional) | |
| tabId | No | Tab id (default: active tab) | |
| expression | Yes | JavaScript expression to evaluate, e.g. "document.title" or "(() => {...})()" |