Skip to main content
Glama
jomon003

PlayMCP Browser Automation Server

by jomon003

resize

Adjust browser viewport dimensions to specified width and height for precise web automation, testing, or scraping tasks using Playwright integration.

Instructions

Resize the browser viewport

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
heightYes
widthYes

Implementation Reference

  • Core implementation of the resize tool handler in PlaywrightController class. Resizes the browser viewport using page.setViewportSize and includes error handling.
    async resize(width: number, height: number): Promise<void> { try { if (!this.isInitialized() || !this.state.page) { throw new Error('Browser not initialized'); } this.log('Resizing viewport', { width, height }); await this.state.page.setViewportSize({ width, height }); this.log('Resize complete'); } catch (error: any) { console.error('Resize error:', error); throw new BrowserError('Failed to resize viewport', 'Check if width and height are positive numbers'); } }
  • Tool schema definition including name, description, and inputSchema for width and height parameters.
    const RESIZE_TOOL: Tool = { name: "resize", description: "Resize the browser viewport", inputSchema: { type: "object", properties: { width: { type: "number" }, height: { type: "number" } }, required: ["width", "height"] } };
  • src/server.ts:541-542 (registration)
    Registration of the resize tool in the tools object passed to MCP Server capabilities.
    waitForSelector: WAIT_FOR_SELECTOR_TOOL, resize: RESIZE_TOOL,
  • MCP callTool request handler case for 'resize' that validates arguments and delegates to PlaywrightController.resize.
    case 'resize': { if (typeof args.width !== 'number' || typeof args.height !== 'number') { return { content: [{ type: "text", text: "Width and height are required" }], isError: true }; } await playwrightController.resize(args.width, args.height); return { content: [{ type: "text", text: "Browser resized successfully" }] }; }

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/jomon003/PlayMCP'

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