Skip to main content
Glama

screenshot

Capture full-page or element-specific screenshots in specified dimensions, with options for base64 encoding, using browser automation for testing Autoconsent rules.

Instructions

Capture screenshots of the entire page or specific elements

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
encodedNoIf true, capture the screenshot as a base64-encoded data URI (as text) instead of binary image content. Default false.
heightNoHeight in pixels (default: 720)
nameYesName for the screenshot
widthNoWidth in pixels (default: 1280)

Implementation Reference

  • The handler function for the 'screenshot' tool that captures a screenshot of the page using Puppeteer, optionally encodes it as base64 text, stores it in a map, notifies of resource changes, and returns success message with image or text content.
    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:41-64 (registration)
    Registers the 'screenshot' tool in the TOOLS array with its description and input schema definition.
    { 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"], }, },
  • Defines the input schema for the 'screenshot' tool, specifying parameters like name (required), width, height, and encoded.
    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"], },
  • Global Map to store screenshot base64 data keyed by name, used by the handler and resource handlers.
    const screenshots = new Map<string, string>();

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/noisysocks/autoconsent-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server