Skip to main content
Glama
jomon003

PlayMCP Browser Automation Server

by jomon003

resize

Adjust browser viewport dimensions for testing responsive designs or capturing screenshots at specific resolutions.

Instructions

Resize the browser viewport

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
widthYes
heightYes

Implementation Reference

  • The core handler function in PlaywrightController that resizes the browser viewport by setting the page viewport size.
    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 input schema requiring width and height as numbers.
    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:542-542 (registration)
    Registration of the resize tool in the tools object passed to MCP server capabilities.
    resize: RESIZE_TOOL,
  • Tool dispatch logic in the callTool handler: validates arguments, calls the controller resize method, and returns success response.
    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