screenshot
Capture the current webpage as an image for documentation, debugging, or visual reference purposes.
Instructions
Take a screenshot of the current page
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filename | No | Optional filename for the screenshot |
Implementation Reference
- tools-playwright.js:168-171 (handler)MCP tool handler for 'screenshot' tool. Receives filename parameter, calls browser.screenshot(), and returns success message with file path.handler: async ({ filename }) => { const path = await browser.screenshot(filename); return { success: true, message: `Screenshot saved to ${path}` }; }
- tools-playwright.js:161-167 (schema)Input schema for screenshot tool. Accepts optional 'filename' string parameter.inputSchema: { type: 'object', properties: { filename: { type: 'string', description: 'Optional filename for the screenshot' } }, required: [] },
- browser.js:131-136 (helper)Core screenshot implementation in SimpleBrowser class. Ensures browser is launched, generates filename if not provided, takes screenshot with Playwright, returns path.async screenshot(filename) { await this.ensureLaunched(); const path = filename || `screenshot-${Date.now()}.png`; await this.page.screenshot({ path }); return path; }
- tools.js:18-21 (registration)Includes all Playwright tools (including screenshot) from createPlaywrightTools into the main createTools() array via spread operator.const playwrightTools = createPlaywrightTools(browser); return [ ...playwrightTools,
- index.js:75-77 (registration)Creates complete tools list via createTools(browser) and registers generic MCP handlers (CallToolRequestSchema and ListToolsRequestSchema) that dispatch to individual tool handlers.const tools = createTools(browser); // Handle tool execution requests from MCP clients