screenshot
Capture a screenshot of any webpage as a PNG image. Specify the URL and optionally set a geographic location to tailor the content.
Instructions
Capture a screenshot of any webpage and return it as a PNG image
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | URL to screenshot | |
| geo | No | Geolocation of the desired request, expressed as a country name |
Implementation Reference
- The handler function for the screenshot tool: calls sapiClient.scrape with headless:'png' and returns the result as a PNG image in MCP content format.
async (scrapingParams: ScrapingMCPParams, extra: ProgressExtra) => { const { data } = await sapiClient.scrape({ auth, scrapingParams: { ...scrapingParams, headless: 'png' }, extra, }); return { content: [ { type: 'image' as const, data: data as string, mimeType: 'image/png', }, ], }; } - src/tools/screenshot/screenshot-tool.ts:15-47 (registration)Registers the tool named 'screenshot' with the MCP server, providing description, inputSchema (url + geo), annotations, and the handler callback.
register = ({ server, sapiClient, auth }: ToolRegistrationArgs) => { server.registerTool( 'screenshot', { description: 'Capture a screenshot of any webpage and return it as a PNG image', inputSchema: { url: z.string().describe('URL to screenshot'), geo: zodGeo, }, annotations: { readOnlyHint: true, openWorldHint: true, }, }, async (scrapingParams: ScrapingMCPParams, extra: ProgressExtra) => { const { data } = await sapiClient.scrape({ auth, scrapingParams: { ...scrapingParams, headless: 'png' }, extra, }); return { content: [ { type: 'image' as const, data: data as string, mimeType: 'image/png', }, ], }; } ); }; - Input schema for the screenshot tool: requires a 'url' string and optional 'geo' geolocation field.
inputSchema: { url: z.string().describe('URL to screenshot'), geo: zodGeo, - src/zod/zod-types.ts:3-8 (schema)Definition of the zodGeo schema used by the screenshot tool's input schema.
export const zodGeo = z .string() .describe('Geolocation of the desired request, expressed as a country name') .optional(); export const zodLocale = z.string().describe('Locale of the desired request').optional(); - src/server/sapi-base-server.ts:68-68 (registration)Instantiation of ScreenshotTool in the allTools array, which gets registered via registerAllTools() or registerTools().
new ScreenshotTool(),