screenshot
Capture screenshots of web pages with optional full-page scroll and custom save paths.
Instructions
Take a screenshot of the current page
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fullPage | No | Capture full scrollable page | |
| path | No | Path to save screenshot (optional) |
Implementation Reference
- src/index.ts:39-42 (schema)Zod schema for the screenshot tool: defines input parameters (fullPage boolean default false, optional path string).
const ScreenshotSchema = z.object({ fullPage: z.boolean().default(false), path: z.string().optional() }); - src/index.ts:219-236 (registration)Tool registration in the ListToolsRequestSchema handler, defines name 'screenshot', description, and inputSchema (fullPage boolean, path string).
{ name: 'screenshot', description: 'Take a screenshot of the current page', inputSchema: { type: 'object', properties: { fullPage: { type: 'boolean', default: false, description: 'Capture full scrollable page' }, path: { type: 'string', description: 'Path to save screenshot (optional)' } } } }, - src/index.ts:519-542 (handler)Handler implementation for the 'screenshot' tool. Parses input via ScreenshotSchema, calls currentPage.screenshot() via Playwright, and returns a text result indicating either the save path or the buffer size.
case 'screenshot': { if (!currentPage) { throw new Error('No browser page available. Launch a browser first.'); } const params = ScreenshotSchema.parse(args); const buffer = await currentPage.screenshot({ fullPage: params.fullPage, path: params.path }); const result = params.path ? `Screenshot saved to: ${params.path}` : `Screenshot captured (${buffer.length} bytes)`; return { content: [ { type: 'text', text: result } ] }; }