Skip to main content
Glama

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

TableJSON Schema
NameRequiredDescriptionDefault
widthYesWidth of the browser window
heightYesHeight of the browser window

Implementation Reference

  • 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 }); }); },
  • 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', },
  • 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 }); }); }, });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/maywzh/playwright-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server