browser_screenshot
Capture webpage screenshots for documentation, testing, or debugging using Selenium WebDriver automation.
Instructions
Take a screenshot of the current page
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| outputPath | No | Optional path where to save the screenshot. If not provided, returns base64 data. |
Implementation Reference
- src/tools/actionTools.ts:484-523 (handler)MCP server.tool registration and inline handler for 'browser_screenshot'. Defines input schema, executes screenshot capture via ActionService, and returns either file save confirmation or base64 image data in the tool response.'browser_screenshot', 'Take a screenshot of the current page', { outputPath: z .string() .optional() .describe('Optional path where to save the screenshot. If not provided, returns base64 data.'), }, async ({ outputPath }) => { try { const driver = stateManager.getDriver(); const actionService = new ActionService(driver); const screenshot = await actionService.takeScreenshot(); if (outputPath) { const fs = await import('fs/promises'); await fs.writeFile(outputPath, screenshot, 'base64'); return { content: [{ type: 'text', text: `Screenshot saved to ${outputPath}` }], }; } else { return { content: [ { type: 'text', text: 'Screenshot captured as base64:' }, { type: 'text', text: screenshot }, ], }; } } catch (e) { return { content: [ { type: 'text', text: `Error taking screenshot: ${(e as Error).message}`, }, ], }; } } );
- src/tools/actionTools.ts:486-491 (schema)Zod input schema for the browser_screenshot tool: optional outputPath string.{ outputPath: z .string() .optional() .describe('Optional path where to save the screenshot. If not provided, returns base64 data.'), },
- Core screenshot capture method in ActionService using Selenium WebDriver's driver.takeScreenshot().async takeScreenshot(): Promise<string> { return this.driver.takeScreenshot(); }