browser_resize
Adjust browser window dimensions for testing responsive web designs or capturing specific viewport states by setting width and height parameters.
Instructions
Resize the browser window
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": {
"width": "<width>",
"height": "<height>"
},
"name": "browser_resize"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| width | Yes | Width of the browser window | |
| height | Yes | Height of the browser window |
Implementation Reference
- src/tools/common.ts:77-92 (handler)The main handler function for the 'browser_resize' tool. It validates input parameters using resizeSchema, retrieves the current tab from context, resizes the viewport using tab.page.setViewportSize, generates a code snippet for the action, and returns it within tab.run.
handle: async (context, params) => { const validatedParams = resizeSchema.parse(params); const tab = context.currentTab(); return await tab.run(async tab => { await tab.page.setViewportSize({ width: validatedParams.width, height: validatedParams.height }); const code = [ `// Resize browser window to ${validatedParams.width}x${validatedParams.height}`, `await page.setViewportSize({ width: ${validatedParams.width}, height: ${validatedParams.height} });` ]; return { code }; }, { captureSnapshot, }); }, }); - src/tools/common.ts:65-68 (schema)Zod schema for validating input parameters of browser_resize: width and height as numbers with descriptions.
const resizeSchema = z.object({ width: z.number().describe('Width of the browser window'), height: z.number().describe('Height of the browser window'), }); - src/tools/common.ts:94-98 (registration)Registration of the browser_resize tool via the resize factory function in the exported array of common tools.
export default (captureSnapshot: boolean) => [ close, wait, resize(captureSnapshot) ];