Skip to main content
Glama
gourraguis

Website Screenshot MCP

by gourraguis

Website Screenshot

screenshot

Captures an image of a website and saves it to a specified file path, with options for format, full-page capture, and device viewport.

Instructions

Takes a screenshot of a website.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYes
outputPathYes
formatNo
fullPageNo
deviceNolaptop-hidpi

Implementation Reference

  • Main handler function that launches Puppeteer, navigates to the URL, takes a screenshot, and saves it to the specified output path. Supports PNG/JPEG formats, full-page capture, and device emulation.
    export const screenshotHandler = async ({ url, outputPath, format = "png", fullPage = true, device }: ScreenshotParams) => {
      try {
        // Ensure the output path has the correct extension
        const extension = `.${format}`;
        let path = outputPath.endsWith(extension) ? outputPath : `${outputPath}${extension}`;
    
        if (!isScreenshotPath(path)) {
          // This should not happen due to the logic above, but it satisfies TypeScript
          throw new Error("Invalid screenshot path");
        }
    
        const browser = await puppeteer.launch({
          headless: true,
          args: ['--no-sandbox', '--disable-setuid-sandbox']
        });
        const page = await browser.newPage();
    
        const deviceName = DEVICE_ID_MAP[device];
        const deviceToEmulate = KnownDevices[deviceName as keyof typeof KnownDevices];
        await page.emulate(deviceToEmulate);
        
        await page.goto(url, { waitUntil: "networkidle2" });
        await page.screenshot({ path, type: format, fullPage });
        await browser.close();
    
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify({ success: true, outputPath: path }),
            },
          ],
        };
      } catch (error: any) {
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify({ success: false, error: error.message }),
            },
          ],
          isError: true,
        };
      }
    };
  • Zod schema defining the input parameters: url, outputPath, optional format (png/jpeg), optional fullPage boolean, and optional device (defaults to laptop-hidpi).
    const screenshotSchema = z.object({
      url: z.string().url(),
      outputPath: z.string(),
      format: z.enum(["png", "jpeg"]).optional(),
      fullPage: z.boolean().optional(),
      device: z.enum(Object.keys(DEVICE_ID_MAP) as [DeviceId, ...DeviceId[]]).default('laptop-hidpi'),
    });
  • src/main.ts:24-31 (registration)
    Registers the screenshot tool with the MCP server under the name 'screenshot', using the schema and handler imported from screenshot.ts.
    server.registerTool(
      "screenshot",
      {
        ...screenshotTool,
        inputSchema: screenshotTool.inputSchema,
      },
      screenshotHandler
    );
  • Type guard that validates the output path ends with .png or .jpeg extension.
    function isScreenshotPath(path: string): path is ScreenshotPath {
      return path.endsWith(".png") || path.endsWith(".jpeg");
    }
  • Mapping from short device IDs to Puppeteer KnownDevices names for device emulation.
    const DEVICE_ID_MAP: Record<string, string> = {
      'ios-large': 'iPhone 14 Pro Max',
      'ios-small': 'iPhone SE',
      'android-large': 'Pixel 6 Pro',
      'android-medium': 'Galaxy S8',
      'tablet-large': 'iPad Pro 11',
      'tablet-small': 'iPad Mini',
      'laptop-hidpi': 'Laptop with HiDPI screen',
      'laptop-mdpi': 'Laptop with MDPI screen',
    };
Behavior2/5

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

No annotations are provided, and the description does not disclose behavioral details such as whether the screenshot is saved locally or returned as data, browser rendering nuances, or error handling.

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

Conciseness2/5

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

The description is extremely concise (one sentence) but fails to front-load essential information or justify its brevity given the tool's complexity.

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

Completeness1/5

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

With no output schema and no annotations, the description does not cover return values, side effects, or required permissions, making it insufficient for correct invocation.

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

Parameters1/5

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

Schema description coverage is 0%, and the description provides no explanation for any of the 5 parameters, leaving the agent to infer meaning from schema names alone.

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 'Takes a screenshot of a website' clearly states the primary action and resource, but lacks specificity about features like full-page or device emulation.

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

Usage Guidelines2/5

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

No guidance on when to use this tool, no context on alternatives (none provided), and no indication of prerequisites or limitations.

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/gourraguis/glasses-mcp'

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