render.screenshot
Capture webpage screenshots for security testing and documentation during bug bounty hunting and vulnerability assessment.
Instructions
Take a screenshot of a webpage
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | URL to screenshot | |
| fullPage | No | Capture full page | |
| waitTime | No | Wait time in ms before screenshot |
Implementation Reference
- src/tools/render.ts:35-67 (handler)The core handler function for the render.screenshot tool. Launches a Puppeteer browser, creates a new page, sets viewport, navigates to the URL, waits, takes a screenshot (fullPage option), saves to screenshots directory with timestamp filename, and returns success with file details or error.async ({ url, fullPage = false, waitTime = 2000 }: any): Promise<ToolResult> => { let page: Page | null = null; try { const browserInstance = await getBrowser(); page = await browserInstance.newPage(); await page.setViewport({ width: 1920, height: 1080 }); await page.goto(url, { waitUntil: 'networkidle2', timeout: 30000 }); await new Promise(resolve => setTimeout(resolve, waitTime)); const screenshotsDir = path.join(process.cwd(), 'screenshots'); await fs.ensureDir(screenshotsDir); const filename = `screenshot_${Date.now()}.png`; const filepath = path.join(screenshotsDir, filename); await page.screenshot({ path: filepath, fullPage, }); await page.close(); return formatToolResult(true, { url, screenshot: filepath, filename, }); } catch (error: any) { if (page) await page.close().catch(() => {}); return formatToolResult(false, null, error.message); } }
- src/tools/render.ts:26-33 (schema)Input schema for the render.screenshot tool defining the expected parameters: url (required string), fullPage (optional boolean), waitTime (optional number).type: 'object', properties: { url: { type: 'string', description: 'URL to screenshot' }, fullPage: { type: 'boolean', description: 'Capture full page', default: false }, waitTime: { type: 'number', description: 'Wait time in ms before screenshot', default: 2000 }, }, required: ['url'], },
- src/tools/render.ts:22-68 (registration)Registration of the render.screenshot tool using server.tool(), including name, description, inputSchema, and inline handler function. Called within registerRenderTools.'render.screenshot', { description: 'Take a screenshot of a webpage', inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'URL to screenshot' }, fullPage: { type: 'boolean', description: 'Capture full page', default: false }, waitTime: { type: 'number', description: 'Wait time in ms before screenshot', default: 2000 }, }, required: ['url'], }, }, async ({ url, fullPage = false, waitTime = 2000 }: any): Promise<ToolResult> => { let page: Page | null = null; try { const browserInstance = await getBrowser(); page = await browserInstance.newPage(); await page.setViewport({ width: 1920, height: 1080 }); await page.goto(url, { waitUntil: 'networkidle2', timeout: 30000 }); await new Promise(resolve => setTimeout(resolve, waitTime)); const screenshotsDir = path.join(process.cwd(), 'screenshots'); await fs.ensureDir(screenshotsDir); const filename = `screenshot_${Date.now()}.png`; const filepath = path.join(screenshotsDir, filename); await page.screenshot({ path: filepath, fullPage, }); await page.close(); return formatToolResult(true, { url, screenshot: filepath, filename, }); } catch (error: any) { if (page) await page.close().catch(() => {}); return formatToolResult(false, null, error.message); } } );
- src/tools/render.ts:9-17 (helper)Helper function to lazily initialize and return a shared Puppeteer Browser instance used by all render tools, including screenshot.async function getBrowser(): Promise<Browser> { if (!browser) { browser = await puppeteer.launch({ headless: true, args: ['--no-sandbox', '--disable-setuid-sandbox'], }); } return browser; }
- src/index.ts:42-42 (registration)Invocation of registerRenderTools(server) which registers the render.screenshot tool (and others) on the main MCP Server instance.registerRenderTools(server);