browser_run_code
Execute a custom async Playwright snippet with page, context, and sessionId in scope to perform targeted browser automation or inspection in an active session.
Instructions
Run a custom async Playwright snippet with page, context, and sessionId in scope.
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_run_code"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Async JavaScript body or arrow function receiving `{ page, context, sessionId }`, e.g. 'async ({ page }) => await page.title()'. | |
| sessionId | No | Optional target browser session ID. If omitted, uses the currently active session (or auto-launches one). |