Skip to main content
Glama

screenshot

Capture screenshots of web pages for documentation, testing, or sharing purposes using browser automation on ARM64 devices.

Instructions

Take a screenshot of the current page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameNoName for the screenshot filescreenshot.png
fullPageNoCapture full page

Implementation Reference

  • Main handler function that executes the screenshot tool logic: ensures Chromium is running, optionally sets full-page metrics, captures screenshot via Page.captureScreenshot CDP command, saves as PNG to /tmp/, and returns success message.
    async screenshot(name = 'screenshot.png', fullPage = false) {
      await this.ensureChromium();
      
      const screenshotParams = { format: 'png' };
      
      if (fullPage) {
        const metrics = await this.sendCDPCommand('Page.getLayoutMetrics');
        await this.sendCDPCommand('Emulation.setDeviceMetricsOverride', {
          width: metrics.contentSize.width,
          height: metrics.contentSize.height,
          deviceScaleFactor: 1,
          mobile: false,
        });
        screenshotParams.clip = {
          x: 0,
          y: 0,
          width: metrics.contentSize.width,
          height: metrics.contentSize.height,
          scale: 1,
        };
      }
    
      const screenshot = await this.sendCDPCommand('Page.captureScreenshot', screenshotParams);
      const screenshotPath = `/tmp/${name}`;
      
      fs.writeFileSync(screenshotPath, screenshot.data, 'base64');
      
      return {
        content: [{ type: 'text', text: `Screenshot saved to ${screenshotPath}` }],
      };
    }
  • Registration of the 'screenshot' tool in the ListToolsRequestSchema handler, defining name, description, and input schema for parameters 'name' and 'fullPage'.
    {
      name: 'screenshot',
      description: 'Take a screenshot of the current page',
      inputSchema: {
        type: 'object',
        properties: {
          name: {
            type: 'string',
            description: 'Name for the screenshot file',
            default: 'screenshot.png',
          },
          fullPage: {
            type: 'boolean',
            description: 'Capture full page',
            default: false,
          },
        },
      },
    },
  • Dispatch handler in CallToolRequestSchema switch statement that invokes the screenshot method with parsed arguments.
    case 'screenshot':
      return await this.screenshot(args.name, args.fullPage);

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/nfodor/claude-arm64-browser'

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