browser_run_code_unsafe
Execute arbitrary Playwright JavaScript in the browser server process to run custom page interactions, such as clicking, navigating, or extracting data, inside an isolated session.
Instructions
Run a Playwright code snippet. Unsafe: executes arbitrary JavaScript in the Playwright server process and is RCE-equivalent.
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": {
"session": "<session>"
},
"name": "browser_run_code_unsafe"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | No | A JavaScript function containing Playwright code to execute. It will be invoked with a single argument, page, which you can use for any page interaction. For example: `async (page) => { await page.getByRole('button', { name: 'Submit' }).click(); return await page.title(); }` | |
| color | No | Optional Chrome tab group color override for a newly created session. | |
| account | No | Chrome account profile to use (defaults to 'default'). Configured accounts: 'default' (Isolated Browser). | default |
| session | Yes | Required isolated session name (also displayed as the Chrome tab group title), e.g. "T1867-api-debug" or "home-css". Use a unique, descriptive task name per conversation so concurrent agents never hijack each other's active tab. | |
| filename | No | Load code from the specified file. Relative file names are resolved against the workspace root. If both code and filename are provided, code will be ignored. |