Run JavaScript
javascript_toolRun JavaScript in a browser tab's page context to inspect or modify the DOM, read window variables, and evaluate expressions with top-level await.
Instructions
Execute JavaScript in the page's context (DOM, window, page variables). REPL semantics: top-level await works and the value of the last expression is returned — write the expression you want (e.g. document.title or await fetch(url).then(r => r.json())) rather than return ....
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": {
"tabId": "<tabId>",
"text": "<text>"
},
"name": "javascript_tool"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | JavaScript code to run. | |
| tabId | Yes | Tab ID from tabs_context / tabs_create. | |
| action | No | 'javascript_exec' (accepted for compatibility). |