browser_take_screenshot
Capture screenshots of web pages using Playwright browser automation. Save images with custom filenames and choose between viewport or full-page captures.
Instructions
Take a screenshot of the current page
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filename | No | File name to save the screenshot to | |
| fullPage | No | Take screenshot of full page |
Implementation Reference
- src/server.ts:269-286 (handler)The handler function that executes the browser_take_screenshot tool. It ensures a browser and page are available, saves a screenshot to the specified filename (or a timestamped default), optionally full page, and returns a success message.private async handleScreenshot(filename?: string, fullPage?: boolean) { await this.ensureBrowser(); const screenshotPath = filename || `screenshot-${Date.now()}.png`; await this.browserState.page!.screenshot({ path: screenshotPath, fullPage: fullPage || false, }); return { content: [ { type: 'text', text: `Screenshot saved to ${screenshotPath}`, }, ], }; }
- src/server.ts:122-138 (schema)The tool schema definition returned by listTools, including name, description, and inputSchema for filename (optional string) and fullPage (optional boolean).{ name: 'browser_take_screenshot', description: 'Take a screenshot of the current page', inputSchema: { type: 'object', properties: { filename: { type: 'string', description: 'File name to save the screenshot to', }, fullPage: { type: 'boolean', description: 'Take screenshot of full page', }, }, }, },
- src/server.ts:169-171 (registration)The switch case registration that maps the tool name to its handler function in the CallToolRequest handler.case 'browser_take_screenshot': return await this.handleScreenshot(args?.filename as string | undefined, args?.fullPage as boolean | undefined);