browser_resize
Resize browser windows to specified dimensions using Playwright MCP, enabling precise control for web automation tasks and structured accessibility testing.
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:51-58 (handler)Handler implementation for the 'browser_resize' tool. Adds resize code to response and sets the page viewport size using the provided width and height parameters.handle: async (tab, params, response) => { response.addCode(`// Resize browser window to ${params.width}x${params.height}`); response.addCode(`await page.setViewportSize({ width: ${params.width}, height: ${params.height} });`); await tab.waitForCompletion(async () => { await tab.page.setViewportSize({ width: params.width, height: params.height }); }); },
- src/tools/common.ts:40-49 (schema)Schema definition for the 'browser_resize' tool, including name, title, description, input schema (width and height as numbers), 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:61-64 (registration)Module-level registration of the 'browser_resize' tool (as 'resize') in the default export array, which is later imported and spread into the global tools list.export default [ close, resize ];
- src/tools.ts:36-52 (registration)Global registration of all tools, including those from common.ts (which contains 'browser_resize'), by spreading the imported tool arrays into allTools.export const allTools: Tool<any>[] = [ ...common, ...console, ...dialogs, ...evaluate, ...files, ...install, ...keyboard, ...navigate, ...network, ...mouse, ...pdf, ...screenshot, ...snapshot, ...tabs, ...wait, ];