javascript_tool
Execute JavaScript in the page MAIN world to inspect page state, measure DOM elements, or debug browser behavior, supporting async/await and returning JSON-serializable results.
Instructions
Execute JavaScript code in the page MAIN world context (supports async/await and returns JSON-serializable results). Use for inspecting page state, DOM measurements, or debugging.
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": {
"action": "<action>",
"text": "<text>"
},
"name": "javascript_tool"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | JavaScript expression or async function body to execute. | |
| tabId | No | Target tab ID (defaults to active managed tab). | |
| action | Yes | Must be "javascript_exec". |