browser_screenshot
Capture webpage screenshots through browser automation. Save full-page or partial screenshots to specified paths for documentation or testing purposes.
Instructions
截取网页截图
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | 保存路径(可选) | |
| fullPage | No | 是否整页截图(可选) | |
| sessionId | No | 会话 ID(可选) |
Implementation Reference
- src/tools/browser.js:217-233 (handler)The `screenshot` method that executes the `browser_screenshot` tool logic using Puppeteer's `page.screenshot()` to capture the page screenshot and save it to a file.async screenshot(savePath, fullPage = false, sessionId = 'default') { try { const page = this.pages.get(sessionId); if (!page) { return { success: false, error: '浏览器未启动' }; } const timestamp = new Date().toISOString().replace(/[:.]/g, '-'); const defaultPath = `screenshot-browser-${timestamp}.png`; const path = savePath || defaultPath; await page.screenshot({ path, fullPage }); return { success: true, path, fullPage, message: '截图已保存' }; } catch (error) { return { success: false, error: error.message }; }
- src/tools/browser.js:75-86 (schema)The tool definition including the input schema for `browser_screenshot` in `getToolDefinitions()`.{ name: 'browser_screenshot', description: '截取网页截图', inputSchema: { type: 'object', properties: { path: { type: 'string', description: '保存路径(可选)' }, fullPage: { type: 'boolean', description: '是否整页截图(可选)' }, sessionId: { type: 'string', description: '会话 ID(可选)' }, }, }, },
- src/tools/browser.js:135-136 (registration)The switch case in `executeTool` method that registers and dispatches the `browser_screenshot` tool call to its handler.case 'browser_screenshot': return await this.screenshot(args.path, args.fullPage, args.sessionId);