screenshot
Capture and save the current webpage as an image. Use the tool to specify file names and choose between full-page or partial captures, ideal for documentation or testing purposes.
Instructions
Take a screenshot of the current page
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fullPage | No | Capture full page | |
| name | No | Name for the screenshot file | screenshot.png |
Implementation Reference
- index-browser-only.js:350-380 (handler)Main handler implementation for the 'screenshot' MCP tool. Captures screenshot using Chrome DevTools Protocol (Page.captureScreenshot), handles full-page option, saves base64 data to /tmp/{name}, and returns the file path.async screenshot(name = 'screenshot.png', fullPage = false) { await this.ensureChromium(); const screenshotParams = { format: 'png' }; if (fullPage) { const metrics = await this.sendCDPCommand('Page.getLayoutMetrics'); await this.sendCDPCommand('Emulation.setDeviceMetricsOverride', { width: metrics.contentSize.width, height: metrics.contentSize.height, deviceScaleFactor: 1, mobile: false, }); screenshotParams.clip = { x: 0, y: 0, width: metrics.contentSize.width, height: metrics.contentSize.height, scale: 1, }; } const screenshot = await this.sendCDPCommand('Page.captureScreenshot', screenshotParams); const screenshotPath = `/tmp/${name}`; fs.writeFileSync(screenshotPath, screenshot.data, 'base64'); return { content: [{ type: 'text', text: `Screenshot saved to ${screenshotPath}` }], }; }
- index-browser-only.js:129-147 (registration)Tool registration in ListToolsRequestSchema handler. Defines name 'screenshot', description, and input schema with optional 'name' (string, default 'screenshot.png') and 'fullPage' (boolean, default false).{ name: 'screenshot', description: 'Take a screenshot of the current page', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Name for the screenshot file', default: 'screenshot.png', }, fullPage: { type: 'boolean', description: 'Capture full page', default: false, }, }, }, },
- index-browser-only.js:132-146 (schema)Input schema definition for the 'screenshot' tool validation.inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Name for the screenshot file', default: 'screenshot.png', }, fullPage: { type: 'boolean', description: 'Capture full page', default: false, }, }, },
- index-browser-only.js:183-184 (handler)Dispatch handler in CallToolRequestSchema that routes 'screenshot' tool calls to the main screenshot method.return await this.screenshot(args.name, args.fullPage); case 'evaluate':