browser_resize
Adjust browser window dimensions to specified width and height for accurate web interaction and testing using Playwright MCP automation.
Instructions
Resize the browser window
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| height | Yes | Height of the browser window | |
| width | Yes | Width of the browser window |
Implementation Reference
- src/tools/common.ts:54-72 (handler)The handle function that resizes the browser viewport to the specified width and height using tab.page.setViewportSize, generates corresponding code snippet, defines an action, and returns execution details.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)Defines the schema for browser_resize tool including name, title, description, readOnly type, and Zod input schema requiring numeric width and height.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.ts:35-50 (registration)Registers browser_resize (via common(true)) in the snapshotTools array for tools that capture snapshots.export const snapshotTools: Tool<any>[] = [ ...common(true), ...console, ...dialogs(true), ...files(true), ...install, ...keyboard(true), ...navigate(true), ...network, ...pdf, ...screenshot, ...snapshot, ...tabs(true), ...testing, ...wait(true), ];
- src/tools.ts:52-66 (registration)Registers browser_resize (via common(false)) in the visionTools array for tools without snapshot capture.export const visionTools: Tool<any>[] = [ ...common(false), ...console, ...dialogs(false), ...files(false), ...install, ...keyboard(false), ...navigate(false), ...network, ...pdf, ...tabs(false), ...testing, ...vision, ...wait(false), ];