screenshot
Capture full-page or element-specific screenshots for browser automation, enabling visual documentation and testing of web pages in the Autoconsent MCP server environment.
Instructions
Capture screenshots of the entire page or specific elements
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name for the screenshot | |
| width | No | Width in pixels (default: 1280) | |
| height | No | Height in pixels (default: 720) | |
| encoded | No | If true, capture the screenshot as a base64-encoded data URI (as text) instead of binary image content. Default false. |
Implementation Reference
- src/index.ts:233-281 (handler)Handler for the 'screenshot' tool: sets viewport dimensions, captures the page screenshot as base64 using Puppeteer, stores it in a global Map by name, notifies resource list change, returns confirmation text and the screenshot as image content or base64 data URI text based on 'encoded' parameter.case "screenshot": { const width = args.width ?? 1280; const height = args.height ?? 720; const encoded = args.encoded ?? false; await page.setViewport({ width, height }); const screenshot = await page.screenshot({ encoding: "base64", fullPage: false, }); if (!screenshot) { return { content: [ { type: "text", text: "Screenshot failed", }, ], isError: true, }; } screenshots.set(args.name, screenshot as string); server.notification({ method: "notifications/resources/list_changed", }); return { content: [ { type: "text", text: `Screenshot '${args.name}' taken at ${width}x${height}`, } as TextContent, encoded ? ({ type: "text", text: `data:image/png;base64,${screenshot}`, } as TextContent) : ({ type: "image", data: screenshot, mimeType: "image/png", } as ImageContent), ], isError: false, }; }
- src/index.ts:42-64 (schema)Input schema and metadata (name, description) for the 'screenshot' tool, defining required 'name' and optional 'width', 'height', 'encoded' parameters.name: "screenshot", description: "Capture screenshots of the entire page or specific elements", inputSchema: { type: "object", properties: { name: { type: "string", description: "Name for the screenshot" }, width: { type: "number", description: "Width in pixels (default: 1280)", }, height: { type: "number", description: "Height in pixels (default: 720)", }, encoded: { type: "boolean", description: "If true, capture the screenshot as a base64-encoded data URI (as text) instead of binary image content. Default false.", }, }, required: ["name"], }, },
- src/index.ts:588-590 (registration)Registers the 'screenshot' tool (via the TOOLS array) for listing with MCP clients through ListToolsRequestSchema handler.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS, }));
- src/index.ts:592-594 (registration)Registers the tool execution dispatcher (handleToolCall containing screenshot case) via CallToolRequestSchema handler.server.setRequestHandler(CallToolRequestSchema, async (request) => handleToolCall(request.params.name, request.params.arguments ?? {}), );
- src/index.ts:176-176 (helper)Global Map storing base64-encoded screenshot data by name, enabling persistence and retrieval as MCP resources (screenshot:// URIs).const screenshots = new Map<string, string>();