browser_resize
Adjust browser window dimensions to test responsive design, capture specific viewport content, or simulate different device screens during web automation.
Instructions
Resize the browser window
Input Schema
TableJSON 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:54-72 (handler)Handler function for the 'browser_resize' tool. It resizes the browser viewport using setViewportSize, generates corresponding code snippet, and defines an action to execute the resize.handle: async (context, params) => { const tab = context.currentTabOrDie(); const code = [ `// Resize browser window to ${params.width}x${params.height}`, `await page.setViewportSize({ width: ${params.width}, height: ${params.height} });` ]; const action = async () => { await tab.page.setViewportSize({ width: params.width, height: params.height }); }; return { code, action, captureSnapshot, waitForNetwork: true }; },
- src/tools/common.ts:43-52 (schema)Schema definition for the 'browser_resize' tool, including name, title, description, input schema with width and height parameters, and type.schema: { name: 'browser_resize', title: 'Resize browser window', description: 'Resize the browser window', inputSchema: z.object({ width: z.number().describe('Width of the browser window'), height: z.number().describe('Height of the browser window'), }), type: 'readOnly', },
- src/tools/common.ts:75-78 (registration)Registration of the 'browser_resize' tool by including the resize factory in the exported array of common tools.export default (captureSnapshot: boolean) => [ close, resize(captureSnapshot) ];