Evaluate JavaScript
evaluateRuns JavaScript in a browser page’s main world and returns the result as JSON, enabling custom DOM queries and data extraction; use an IIFE for multiple statements.
Instructions
Execute JavaScript in the page main world and return a JSON value. Use an IIFE for multiple statements, e.g. "(() => ({title: document.title}))()". Powerful: prefer snapshot/DOM when possible.
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": "evaluate"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tabId | No | ||
| frameId | No | ||
| trusted | No | ||
| expression | Yes | ||
| userGesture | No | ||
| awaitPromise | No | ||
| returnByValue | No |