screenshot
Capture browser page screenshots using AdsPower LocalAPI, specifying save paths and full-page options for documentation or analysis.
Instructions
Get the screenshot of the page
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| savePath | No | The path to save the screenshot | |
| isFullPage | No | The is full page of the screenshot |
Implementation Reference
- src/handlers/automation.ts:28-40 (handler)The main handler function for the 'screenshot' tool. It captures a screenshot of the current browser page using Playwright, optionally saves it to a file, converts it to base64, stores it in the browser's screenshots map, and returns the image data.
async screenshot({ savePath, isFullPage }: ScreenshotParams) { browser.checkConnected(); const filename = `screenshot-${Date.now()}-${Math.random().toString(36).substring(2, 15)}.png`; const outputPath = path.join(savePath || defaultDownloadsPath, filename); const screenshot = await browser.pageInstance!.screenshot({ path: outputPath, fullPage: isFullPage }); const screenshotBase64 = screenshot.toString('base64'); browser.screenshotsInstance.set(filename, screenshotBase64); return [{ type: 'image' as const, data: screenshotBase64, mimeType: 'image/png' }]; }, - src/types/schemas.ts:177-180 (schema)Zod schema defining the input parameters for the screenshot tool: optional savePath (string) and isFullPage (boolean).
screenshotSchema: z.object({ savePath: z.string().optional().describe('The path to save the screenshot'), isFullPage: z.boolean().optional().describe('The is full page of the screenshot') }).strict(), - src/utils/toolRegister.ts:59-60 (registration)Registers the 'screenshot' tool with the MCP server using server.tool(), providing the tool name, description, input schema, and the wrapped handler function.
server.tool('screenshot', 'Get the screenshot of the page', schemas.screenshotSchema.shape, wrapHandler(automationHandlers.screenshot)); - src/utils/browserBase.ts:26-28 (helper)Getter for the screenshots Map instance used by the handler to store base64 screenshot data keyed by filename.
get screenshotsInstance() { return this.screenshots; } - src/handlers/automation.ts:163-165 (helper)Helper function to retrieve a stored screenshot by filename from the browser's screenshots map (used in commented resource code).
export const getScreenshot = (filename: string) => { return browser.screenshotsInstance.get(filename); }