screenshot_page
Capture web page screenshots for documentation, testing, or visual reference by providing a URL, with options for full-page capture and element waiting.
Instructions
Take a screenshot of a web page
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | URL to screenshot | |
| fullPage | No | Capture full page | |
| waitForSelector | No | CSS selector to wait for before screenshot |
Implementation Reference
- src/scrapers/dynamic-scraper.ts:222-245 (handler)Core implementation of screenshotPage using Playwright: launches browser, navigates to URL, waits for selector if provided, takes screenshot, returns Buffer.async screenshotPage(config: ScrapingConfig, options?: { fullPage?: boolean; path?: string }): Promise<Buffer> { const browser = await this.getBrowser(); const page = await browser.newPage(); try { await page.goto(config.url, { waitUntil: 'networkidle', timeout: config.timeout || 30000, }); if (config.waitForSelector) { await page.waitForSelector(config.waitForSelector); } const screenshot = await page.screenshot({ fullPage: options?.fullPage || false, path: options?.path, }); return screenshot as Buffer; } finally { await page.close(); } }
- src/tools/web-scraping.ts:356-365 (handler)MCP tool handler switch case for 'screenshot_page': calls DynamicScraper.screenshotPage and returns base64-encoded PNG.case 'screenshot_page': { const screenshot = await dynamicScraper.screenshotPage(config, { fullPage: params.fullPage as boolean, }); return { screenshot: screenshot.toString('base64'), format: 'png', message: 'Screenshot taken successfully', }; }
- src/tools/web-scraping.ts:197-219 (registration)Registers the 'screenshot_page' tool in webScrapingTools array, including description and input schema.{ name: 'screenshot_page', description: 'Take a screenshot of a web page', inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'URL to screenshot', }, fullPage: { type: 'boolean', description: 'Capture full page', default: false, }, waitForSelector: { type: 'string', description: 'CSS selector to wait for before screenshot', }, }, required: ['url'], }, },
- src/tools/web-scraping.ts:200-219 (schema)Input schema for the screenshot_page tool defining parameters: url (required), fullPage, waitForSelector.inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'URL to screenshot', }, fullPage: { type: 'boolean', description: 'Capture full page', default: false, }, waitForSelector: { type: 'string', description: 'CSS selector to wait for before screenshot', }, }, required: ['url'], }, },