Skip to main content
Glama

browser_resize

Adjust browser window dimensions for testing responsive web designs or capturing specific viewport states by setting width and height parameters.

Instructions

Resize the browser window

Input Schema

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

Implementation Reference

  • The main handler function for the 'browser_resize' tool. It validates input parameters using resizeSchema, retrieves the current tab from context, resizes the viewport using tab.page.setViewportSize, generates a code snippet for the action, and returns it within tab.run.
      handle: async (context, params) => {
        const validatedParams = resizeSchema.parse(params);
    
        const tab = context.currentTab();
        return await tab.run(async tab => {
          await tab.page.setViewportSize({ width: validatedParams.width, height: validatedParams.height });
          const code = [
            `// Resize browser window to ${validatedParams.width}x${validatedParams.height}`,
            `await page.setViewportSize({ width: ${validatedParams.width}, height: ${validatedParams.height} });`
          ];
          return { code };
        }, {
          captureSnapshot,
        });
      },
    });
  • Zod schema for validating input parameters of browser_resize: width and height as numbers with descriptions.
    const resizeSchema = z.object({
      width: z.number().describe('Width of the browser window'),
      height: z.number().describe('Height of the browser window'),
    });
  • Registration of the browser_resize tool via the resize factory function in the exported array of common tools.
    export default (captureSnapshot: boolean) => [
      close,
      wait,
      resize(captureSnapshot)
    ];

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/markbustamante77/mcp'

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