screenshot
Capture screenshots in Firefox using Playwright automation. Specify file path, tab ID, and full-page options for precise browser image capturing.
Instructions
Take a screenshot
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fullPage | No | ||
| path | No | screenshot.png | |
| tabId | No |
Implementation Reference
- index.js:409-426 (handler)The handler function for the 'screenshot' MCP tool. It ensures the browser is running, extracts path and fullPage from arguments (with defaults), calls page.screenshot from Playwright, and returns a text confirmation.// async screenshot(args = {}) { // this.ensureBrowserRunning(); // const { path = 'screenshot.png', fullPage = false } = args; // await this.page.screenshot({ // path, // fullPage // }); // return { // content: [ // { // type: 'text', // text: `Screenshot saved to: ${path}` // } // ] // }; // }
- index.js:136-151 (schema)The schema definition for the 'screenshot' tool, including name, description, and inputSchema specifying optional path (default 'screenshot.png') and fullPage (default false) parameters.// description: 'Take a screenshot of the current page', // inputSchema: { // type: 'object', // properties: { // path: { // type: 'string', // description: 'File path to save screenshot', // default: 'screenshot.png' // }, // fullPage: { // type: 'boolean', // description: 'Capture full page', // default: false // } // } // }
- index.js:247-248 (registration)Registration of the 'screenshot' tool handler in the switch statement within the CallToolRequestSchema request handler.// case 'screenshot': // return await this.screenshot(args);
- index.js:35-226 (registration)The listTools response includes the 'screenshot' tool in the tools array (specific block at 135-152). This registers the tool's metadata for MCP clients.// tools: [ // { // name: 'launch_firefox', // description: 'Launch Firefox browser', // inputSchema: { // type: 'object', // properties: { // headless: { // type: 'boolean', // description: 'Run browser in headless mode', // default: false // }, // url: { // type: 'string', // description: 'Initial URL to navigate to', // default: 'about:blank' // } // } // } // }, // { // name: 'navigate', // description: 'Navigate to a URL', // inputSchema: { // type: 'object', // properties: { // url: { // type: 'string', // description: 'URL to navigate to' // } // }, // required: ['url'] // } // }, // { // name: 'click', // description: 'Click on an element', // inputSchema: { // type: 'object', // properties: { // selector: { // type: 'string', // description: 'CSS selector or text content to click' // }, // coordinates: { // type: 'object', // properties: { // x: { type: 'number' }, // y: { type: 'number' } // }, // description: 'Click at specific coordinates (alternative to selector)' // } // } // } // }, // { // name: 'type_text', // description: 'Type text into an input field', // inputSchema: { // type: 'object', // properties: { // selector: { // type: 'string', // description: 'CSS selector of the input field' // }, // text: { // type: 'string', // description: 'Text to type' // } // }, // required: ['selector', 'text'] // } // }, // { // name: 'get_page_content', // description: 'Get the HTML content of the current page', // inputSchema: { // type: 'object', // properties: { // selector: { // type: 'string', // description: 'CSS selector to get specific element content (optional)' // } // } // } // }, // { // name: 'get_page_text', // description: 'Get the visible text content of the current page', // inputSchema: { // type: 'object', // properties: { // selector: { // type: 'string', // description: 'CSS selector to get specific element text (optional)' // } // } // } // }, // { // name: 'screenshot', // description: 'Take a screenshot of the current page', // inputSchema: { // type: 'object', // properties: { // path: { // type: 'string', // description: 'File path to save screenshot', // default: 'screenshot.png' // }, // fullPage: { // type: 'boolean', // description: 'Capture full page', // default: false // } // } // } // }, // { // name: 'wait_for_element', // description: 'Wait for an element to appear on the page', // inputSchema: { // type: 'object', // properties: { // selector: { // type: 'string', // description: 'CSS selector to wait for' // }, // timeout: { // type: 'number', // description: 'Timeout in milliseconds', // default: 30000 // } // }, // required: ['selector'] // } // }, // { // name: 'execute_script', // description: 'Execute JavaScript in the browser', // inputSchema: { // type: 'object', // properties: { // script: { // type: 'string', // description: 'JavaScript code to execute' // } // }, // required: ['script'] // } // }, // { // name: 'close_browser', // description: 'Close the Firefox browser', // inputSchema: { // type: 'object', // properties: {} // } // }, // { // name: 'get_current_url', // description: 'Get the current page URL', // inputSchema: { // type: 'object', // properties: {} // } // }, // { // name: 'back', // description: 'Navigate back in browser history', // inputSchema: { // type: 'object', // properties: {} // } // }, // { // name: 'forward', // description: 'Navigate forward in browser history', // inputSchema: { // type: 'object', // properties: {} // } // }, // { // name: 'reload', // description: 'Reload the current page', // inputSchema: { // type: 'object', // properties: {} // } // } // ],
- index.js:533-537 (helper)Helper method called by screenshot handler to ensure browser and page are initialized before taking screenshot.// ensureBrowserRunning() { // if (!this.browser || !this.page) { // throw new Error('Firefox browser is not running. Please launch it first using the launch_firefox tool.'); // } // }