resize_browser
Adjust browser window dimensions for testing responsive web designs or capturing screenshots at specific resolutions.
Instructions
调整浏览器窗口大小
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| size | Yes | 窗口大小,格式为 'width,height' |
Implementation Reference
- src/browserSession.ts:538-549 (handler)Core implementation of resize_browser tool: parses 'width,height' string, sets page viewport, and resizes the browser window using CDP Browser domain commands.async resize(size: string): Promise<BrowserActionResult> { return this.doAction(async (page) => { const [width, height] = size.split(",").map(Number); const session = await page.createCDPSession(); await page.setViewport({ width, height }); const { windowId } = await session.send("Browser.getWindowForTarget"); await session.send("Browser.setWindowBounds", { bounds: { width, height }, windowId, }); }); }
- src/index.ts:140-153 (registration)Tool registration in listTools handler, including name, description, and input schema definition.{ name: "resize_browser", description: "调整浏览器窗口大小", inputSchema: { type: "object", properties: { size: { type: "string", description: "窗口大小,格式为 'width,height'", }, }, required: ["size"], }, },
- src/index.ts:218-223 (handler)Dispatch handler in CallToolRequestSchema that validates input and calls BrowserSession.resize().case "resize_browser": if (!args?.size) { throw new Error("size参数是必需的"); } result = await this.browserSession.resize(args.size as string); break;
- src/index.ts:319-320 (helper)Helper function providing success message for resize_browser tool.case "resize_browser": return "✅ 浏览器窗口大小调整完成";