browser_resize
Resize browser windows to specific dimensions for testing or content layout adjustments. Set width and height parameters to control viewport size.
Instructions
Resize the browser window
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:51-57 (handler)The handler function for the 'browser_resize' tool. It adds code to resize the viewport and waits for completion by calling page.setViewportSize with the provided width and height.
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/common.ts:40-49 (schema)The schema definition for the 'browser_resize' tool, specifying the name, title, description, input schema (width and height as numbers), and type as readOnly.
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:38-58 (registration)The full tool definition and registration using defineTabTool, which includes schema and handler. This tool is exported and included in the allTools array in src/tools.ts.
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 }); }); }, });