browser_evaluate
Execute JavaScript code within browser sessions to automate web interactions, test functionality, or extract data using Playwright's isolated environments.
Instructions
Run JavaScript
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": {
"function": "<function>"
},
"name": "browser_evaluate"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| function | Yes |
Implementation Reference
- index.js:417-422 (handler)The 'browser_evaluate' tool registration and handler implementation. It uses 'proxyToolCall' to forward the request to an underlying browser instance.
server.tool('browser_evaluate', 'Run JavaScript', { function: z.string() }, async (args) => { const check = requireActivePage(); if (check) return check; return proxyToolCall('browser_evaluate', args); });