Skip to main content
Glama
ashios15

MCP Frontend Tools Server

by ashios15

Page Screenshot (Playwright)

page_screenshot

Capture a PNG screenshot of any URL using headless Chromium. Supports element selectors, full-page capture, dark mode, and custom viewports.

Instructions

Launch headless Chromium, navigate to a URL, and save a PNG screenshot. Supports element selectors, full-page capture, dark mode, and custom viewports. Requires the optional playwright peer dependency.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesURL to screenshot.
outPathYesAbsolute file path to write PNG to. Parent dirs will be created.
selectorNoCSS selector to screenshot instead of the viewport.
fullPageNoCapture the full scrollable page (default: false).
widthNoViewport width (default 1280).
heightNoViewport height (default 800).
deviceScaleFactorNoDPR (default 2).
colorSchemeNo
waitForSelectorNoWait for this selector before capturing.
timeoutMsNo

Implementation Reference

  • Handler function that registers the 'page_screenshot' tool with the MCP server. Contains the full implementation: launches headless Chromium via Playwright, navigates to the URL, optionally waits for a selector, captures a screenshot (viewport or element), writes it to disk, and returns metadata (file size, viewport, etc.).
    export function registerPageScreenshot(server: McpServer) {
      server.registerTool(
        "page_screenshot",
        {
          title: "Page Screenshot (Playwright)",
          description:
            "Launch headless Chromium, navigate to a URL, and save a PNG screenshot. Supports element selectors, full-page capture, dark mode, and custom viewports. Requires the optional `playwright` peer dependency.",
          inputSchema: InputShape,
        },
        async (args) => {
          try {
            const pw = await loadOptional<typeof import("playwright")>(
              "playwright",
              "npm i -D playwright && npx playwright install chromium"
            );
            const browser = await pw.chromium.launch();
            try {
              const context = await browser.newContext({
                viewport: {
                  width: args.width ?? 1280,
                  height: args.height ?? 800,
                },
                deviceScaleFactor: args.deviceScaleFactor ?? 2,
                colorScheme: args.colorScheme ?? "light",
              });
              const page = await context.newPage();
              const timeout = args.timeoutMs ?? 20000;
              await page.goto(args.url, { waitUntil: "networkidle", timeout });
              if (args.waitForSelector) {
                await page.waitForSelector(args.waitForSelector, { timeout });
              }
              await fs.mkdir(path.dirname(args.outPath), { recursive: true });
              if (args.selector) {
                const el = await page.$(args.selector);
                if (!el) return errorResult(`Selector not found: ${args.selector}`);
                await el.screenshot({ path: args.outPath });
              } else {
                await page.screenshot({
                  path: args.outPath,
                  fullPage: args.fullPage ?? false,
                });
              }
              const stat = await fs.stat(args.outPath);
              return jsonResult({
                url: args.url,
                outPath: args.outPath,
                bytes: stat.size,
                viewport: {
                  width: args.width ?? 1280,
                  height: args.height ?? 800,
                  deviceScaleFactor: args.deviceScaleFactor ?? 2,
                },
                colorScheme: args.colorScheme ?? "light",
                fullPage: args.fullPage ?? false,
                selector: args.selector ?? null,
              });
            } finally {
              await browser.close();
            }
          } catch (err) {
            return errorResult(err instanceof Error ? err.message : String(err));
          }
        }
      );
Behavior4/5

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

With no annotations, the description must carry behavioral disclosure. It discloses headless Chromium usage, supports for selectors, full-page, dark mode, and viewports. It also mentions the optional Playwright dependency. Missing details on error handling and default behaviors, but still provides significant transparency.

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?

Two sentences, both substantive. First sentence defines core action; second lists key features and a dependency. No redundant or extraneous words.

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

Completeness4/5

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

Given the tool's complexity (10 parameters, no output schema), the description provides a good high-level overview. It specifies the browser engine, supported features, and a dependency. It could mention return behavior (writes file to disk) or default values, but the schema covers defaults. Overall complete given the context.

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 80%, so baseline is 3. The description provides a high-level grouping of features (e.g., 'Supports element selectors, full-page capture, dark mode, and custom viewports') but does not add detail beyond the schema. For the two parameters without schema descriptions (timeoutMs, waitForSelector? waitForSelector has description, timeoutMs does not), the description does not compensate.

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

Purpose5/5

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

Description clearly states 'Launch headless Chromium, navigate to a URL, and save a PNG screenshot.' It uses specific verbs and a concrete resource. Distinct from siblings like axe_audit or bundle_budget_check, which address different tasks.

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

Usage Guidelines4/5

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

The description implies when to use (when a screenshot of a web page is needed) but does not explicitly exclude alternatives or provide when-not-to-use guidance. Siblings are clearly different, so context is clear.

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/ashios15/mcp-frontend-tools'

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