browser_execute_script
Run JavaScript expressions in the current Chrome page context through the debugger, await returned promises, and get results or errors; use an IIFE for multi-statement logic.
Instructions
Execute JavaScript in the current page, through the Chrome debugger (Runtime.evaluate) in the page's own context: the page's globals are visible and its Content Security Policy does not block it. A returned promise is awaited. If the code throws, the answer is ok:false with error and name, and the code is not run again. The call answers within 29.5 s; if the time runs out before the code is sent, the answer is error call-timeout with sent:false (nothing ran). If no answer reaches the server within 45 s (Chrome itself stalled), the answer is error no-answer with sent:"unknown": the code MAY have run, it is not repeated, and you should call again only if it is safe to run twice. IMPORTANT: the parameter is code (NOT script - though that alias is accepted), and it must be an EXPRESSION, not statements: use an IIFE (() => { ...; return x; })(). Top-level return is a syntax error (the handler wraps code in parentheses).
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": {
"code": "<code>"
},
"name": "browser_execute_script"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | JavaScript EXPRESSION to evaluate in page context. For multi-statement logic use an IIFE: (() => { ...; return result; })() | |
| partition | No | Run this call in a partition from browser_partition (an id like "p1"). Leave it out for the default partition. An unknown or closed id is an error; the call is never sent to the default partition instead. |