Skip to main content
Glama

screenshot

Capture web page screenshots to visually verify frontend changes, check responsive layouts, or debug CSS issues. Supports custom viewports, device presets, and element-specific captures.

Instructions

Take a browser screenshot of a URL. Returns the image file path. Use this to visually verify frontend changes, check responsive layouts, or debug CSS issues. The returned file path can be viewed with the Read tool.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesURL to screenshot (http://, https://, or file://)
widthNoViewport width in pixels (default: 1440)
heightNoViewport height in pixels (default: 900)
fullPageNoCapture full scrollable page (default: true)
selectorNoCSS selector to screenshot a specific element instead of the full page
deviceNoDevice preset: "mobile" (375x812), "tablet" (768x1024), "desktop" (1440x900), "4k" (3840x2160), or a Puppeteer device name like "iPhone 15 Pro"
darkModeNoEmulate dark mode via prefers-color-scheme: dark
waitForNoMilliseconds to wait after load (default: 2000), or a CSS selector to wait for
outputNoCustom output file path (default: auto-generated in /tmp/browsershot-mcp/)

Implementation Reference

  • The `takeScreenshot` function implements the core logic for the "screenshot" tool, using Puppeteer to navigate, emulate devices/dark mode, and capture a full page or element screenshot.
    async function takeScreenshot({
      url,
      width = 1440,
      height = 900,
      fullPage = true,
      selector = null,
      deviceScaleFactor = 2,
      waitFor = 2000,
      darkMode = false,
      device = null,
      output = null,
    }) {
      const browser = await getBrowser();
      const page = await browser.newPage();
    
      try {
        // Device emulation (mobile, tablet)
        if (device) {
          const devices = puppeteer.KnownDevices || puppeteer.devices;
          const deviceDesc = devices[device];
          if (deviceDesc) {
            await page.emulate(deviceDesc);
          } else {
            // Fallback presets
            const presets = {
              mobile: { width: 375, height: 812, deviceScaleFactor: 3, isMobile: true, hasTouch: true },
              tablet: { width: 768, height: 1024, deviceScaleFactor: 2, isMobile: true, hasTouch: true },
              desktop: { width: 1440, height: 900, deviceScaleFactor: 2, isMobile: false, hasTouch: false },
              "4k": { width: 3840, height: 2160, deviceScaleFactor: 1, isMobile: false, hasTouch: false },
            };
            const p = presets[device.toLowerCase()];
            if (p) {
              await page.setViewport(p);
            } else {
              await page.setViewport({ width, height, deviceScaleFactor });
            }
          }
        } else {
          await page.setViewport({ width, height, deviceScaleFactor });
        }
    
        // Dark mode preference
        if (darkMode) {
          await page.emulateMediaFeatures([
            { name: "prefers-color-scheme", value: "dark" },
          ]);
        }
    
        // Navigate
        await page.goto(url, { waitUntil: "networkidle2", timeout: 30000 });
    
        // Wait for content to settle
        if (typeof waitFor === "number") {
          await new Promise((r) => setTimeout(r, waitFor));
        } else if (typeof waitFor === "string") {
          // CSS selector to wait for
          await page.waitForSelector(waitFor, { timeout: 10000 });
        }
    
        // Screenshot options
        const screenshotOpts = { fullPage };
    
        if (selector) {
          const el = await page.$(selector);
          if (!el) throw new Error(`Selector "${selector}" not found on page`);
          screenshotOpts.fullPage = false;
          // Element screenshot
          const filename = `element_${Date.now()}.png`;
          const filepath = output || join(SCREENSHOT_DIR, filename);
          await el.screenshot({ path: filepath });
          return filepath;
        }
    
        const filename = `page_${Date.now()}.png`;
        const filepath = output || join(SCREENSHOT_DIR, filename);
        screenshotOpts.path = filepath;
        await page.screenshot(screenshotOpts);
        return filepath;
      } finally {
        await page.close();
      }
    }
  • src/index.js:190-245 (registration)
    Tool registration for the "screenshot" tool in the `ListToolsRequestSchema` handler.
    {
      name: "screenshot",
      description:
        "Take a browser screenshot of a URL. Returns the image file path. " +
        "Use this to visually verify frontend changes, check responsive layouts, " +
        "or debug CSS issues. The returned file path can be viewed with the Read tool.",
      inputSchema: {
        type: "object",
        properties: {
          url: {
            type: "string",
            description: "URL to screenshot (http://, https://, or file://)",
          },
          width: {
            type: "number",
            description: "Viewport width in pixels (default: 1440)",
            default: 1440,
          },
          height: {
            type: "number",
            description: "Viewport height in pixels (default: 900)",
            default: 900,
          },
          fullPage: {
            type: "boolean",
            description: "Capture full scrollable page (default: true)",
            default: true,
          },
          selector: {
            type: "string",
            description: "CSS selector to screenshot a specific element instead of the full page",
          },
          device: {
            type: "string",
            description:
              'Device preset: "mobile" (375x812), "tablet" (768x1024), "desktop" (1440x900), "4k" (3840x2160), or a Puppeteer device name like "iPhone 15 Pro"',
          },
          darkMode: {
            type: "boolean",
            description: "Emulate dark mode via prefers-color-scheme: dark",
            default: false,
          },
          waitFor: {
            type: ["number", "string"],
            description:
              "Milliseconds to wait after load (default: 2000), or a CSS selector to wait for",
            default: 2000,
          },
          output: {
            type: "string",
            description: "Custom output file path (default: auto-generated in /tmp/browsershot-mcp/)",
          },
        },
        required: ["url"],
      },
    },
  • The request handler switch case for "screenshot" which calls `takeScreenshot` and returns the image as base64 for the MCP protocol.
    case "screenshot": {
      const filepath = await takeScreenshot(args);
      // Read the image and return as base64 for Claude to see
      const imageData = readFileSync(filepath);
      const base64 = imageData.toString("base64");
      return {
        content: [
          {
            type: "image",
            data: base64,
            mimeType: "image/png",
          },
          {
            type: "text",
            text: `Screenshot saved: ${filepath}\nViewport: ${args.width || 1440}x${args.height || 900}${args.device ? ` (${args.device})` : ""}${args.darkMode ? " [dark mode]" : ""}`,
          },
        ],
      };
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description must carry full behavioral disclosure. It successfully states the return value ('image file path'), but omits other behavioral traits like error handling (timeouts, invalid URLs), browser engine details (though 'Puppeteer' appears in schema), or idempotency. It compensates minimally by mentioning the Read tool integration.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three sentences that are all essential: purpose/return, use cases, and output consumption. Front-loaded with the core action, zero redundancy, and appropriately dense for the tool complexity. No wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 9-parameter browser automation tool with no output schema and no annotations, the description covers the critical missing output information (file path return) and basic usage contexts. However, it lacks discussion of failure modes, network requirements, or JavaScript execution behavior that would be expected for a complex browser tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, establishing a baseline of 3. The description adds no explicit parameter guidance, though the use cases ('responsive layouts') implicitly guide toward the device/width/height parameters. No additional syntax or format details are provided beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific action ('Take a browser screenshot') and target ('URL'), and distinguishes from sibling page_info by emphasizing visual verification ('visually verify frontend changes', 'debug CSS issues'). However, it does not explicitly contrast with screenshot_compare, which could lead to confusion about when to use simple capture versus visual diffing.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides clear positive use cases ('visually verify frontend changes, check responsive layouts, or debug CSS issues') and mentions the Read tool for consuming output. Lacks explicit negative guidance ('do not use when...') or selection logic for when to prefer screenshot_compare over this tool.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/kjaiswal/browsershot-mcp'

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