browser_resize
Adjust browser window dimensions to specified width and height, enabling precise testing for accessibility compliance and responsive design evaluations.
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:37-57 (handler)Defines the browser_resize tool, including schema for width/height inputs and handler that generates code and resizes the viewport using page.setViewportSize.const resize = defineTabTool({ capability: 'core', 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', }, handle: async (tab, params, response) => { 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.ts:38-56 (registration)Registers browser_resize by spreading tools from common.ts (which exports resize) into the allTools array used by the backend.export const allTools: Tool<any>[] = [ ...common, ...console, ...dialogs, ...evaluate, ...files, ...form, ...install, ...keyboard, ...navigate, ...network, ...mouse, ...pdf, ...screenshot, ...snapshot, ...tabs, ...wait, ...verify, ];
- src/browserServerBackend.ts:61-63 (registration)MCP server backend listTools method that exposes the schema of browser_resize (included in _tools from filteredTools) to MCP clients.async listTools(): Promise<mcpServer.Tool[]> { return this._tools.map(tool => toMcpTool(tool.schema)); }