Skip to main content
Glama
kbyk004-diy

Playwright-Lighthouse MCP Server

by kbyk004-diy

take-screenshot

Capture screenshots of web pages for performance analysis, supporting full-page captures to document website appearance during testing.

Instructions

Takes a screenshot of the currently open page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesURL of the website you want to capture
fullPageNoIf true, captures a screenshot of the entire page

Implementation Reference

  • The handler function that executes the take-screenshot tool. It navigates to the given URL, takes a JPEG screenshot (full page if specified), saves it to the screenshots directory, closes the browser, and returns text messages with the save path and the base64-encoded image.
    async ({ url, fullPage }) => {
      try {
        // Automatically launch browser and navigate to URL
        await navigateToUrl(url);
    
        const screenshot = await page!.screenshot({ fullPage, type: "jpeg", quality: 80 });
        
        // Create directory for screenshots if it doesn't exist
        const screenshotsDir = path.join(__dirname, "../screenshots");
        if (!existsSync(screenshotsDir)) {
          mkdirSync(screenshotsDir, { recursive: true });
        }
        
        // Save screenshot
        const screenshotPath = path.join(screenshotsDir, `screenshot-${Date.now()}.jpg`);
        writeFileSync(screenshotPath, screenshot);
    
        // Close browser after taking screenshot
        await closeBrowser();
        
        return {
          content: [
            {
              type: "text" as const,
              text: `Screenshot captured. ${fullPage ? "(Full page)" : ""}`,
            },
            {
              type: "text" as const,
              text: `Saved to: ${screenshotPath}`,
            },
            {
              type: "image" as const,
              data: screenshot.toString("base64"),
              mimeType: "image/jpeg",
            },
          ],
        };
      } catch (error) {
        // Close browser even when an error occurs
        await closeBrowser();
        
        return {
          content: [
            {
              type: "text" as const,
              text: `An error occurred while taking screenshot: ${error instanceof Error ? error.message : String(error)}`,
            },
          ],
          isError: true,
        };
      }
    }
  • Zod schema defining the input parameters for the take-screenshot tool: 'url' (required URL string) and 'fullPage' (optional boolean, defaults to false).
    {
      url: z.string().url().describe("URL of the website you want to capture"),
      fullPage: z.boolean().default(false).describe("If true, captures a screenshot of the entire page"),
    },
  • src/index.ts:445-504 (registration)
    Registers the 'take-screenshot' tool with the MCP server using server.tool(), specifying the name, description, input schema, and handler function.
    server.tool(
      "take-screenshot",
      "Takes a screenshot of the currently open page",
      {
        url: z.string().url().describe("URL of the website you want to capture"),
        fullPage: z.boolean().default(false).describe("If true, captures a screenshot of the entire page"),
      },
      async ({ url, fullPage }) => {
        try {
          // Automatically launch browser and navigate to URL
          await navigateToUrl(url);
    
          const screenshot = await page!.screenshot({ fullPage, type: "jpeg", quality: 80 });
          
          // Create directory for screenshots if it doesn't exist
          const screenshotsDir = path.join(__dirname, "../screenshots");
          if (!existsSync(screenshotsDir)) {
            mkdirSync(screenshotsDir, { recursive: true });
          }
          
          // Save screenshot
          const screenshotPath = path.join(screenshotsDir, `screenshot-${Date.now()}.jpg`);
          writeFileSync(screenshotPath, screenshot);
    
          // Close browser after taking screenshot
          await closeBrowser();
          
          return {
            content: [
              {
                type: "text" as const,
                text: `Screenshot captured. ${fullPage ? "(Full page)" : ""}`,
              },
              {
                type: "text" as const,
                text: `Saved to: ${screenshotPath}`,
              },
              {
                type: "image" as const,
                data: screenshot.toString("base64"),
                mimeType: "image/jpeg",
              },
            ],
          };
        } catch (error) {
          // Close browser even when an error occurs
          await closeBrowser();
          
          return {
            content: [
              {
                type: "text" as const,
                text: `An error occurred while taking screenshot: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
            isError: true,
          };
        }
      }
    );
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states the action but lacks behavioral details: it doesn't mention output format (e.g., image type, storage location), error conditions (e.g., invalid URL, timeout), or side effects (e.g., whether it opens a browser). For a tool with no annotation coverage, this is a significant gap in 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?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is front-loaded and appropriately sized, earning its place with zero waste.

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

Completeness2/5

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

Given the tool's complexity (involves browser interaction and image capture), lack of annotations, and no output schema, the description is incomplete. It doesn't cover behavioral aspects like output format, error handling, or dependencies, which are crucial for an AI agent to use it correctly. The description should do more to compensate for these gaps.

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%, so the schema already documents both parameters ('url' and 'fullPage') with clear descriptions. The description adds no additional parameter semantics beyond what's in the schema, such as explaining 'currently open page' in relation to the 'url' parameter. Baseline 3 is appropriate when the schema does the heavy lifting.

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 clearly states the action ('takes a screenshot') and target ('currently open page'), providing a specific verb+resource. However, it doesn't explicitly differentiate from the sibling tool 'run-lighthouse', which might also involve page analysis but serves a different purpose. The description is unambiguous about what the tool does.

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?

The description provides no guidance on when to use this tool versus alternatives like 'run-lighthouse'. It mentions 'currently open page' but doesn't specify prerequisites (e.g., whether a browser must be active) or exclusions. Usage context is implied but not explicit, leaving gaps for an AI agent to infer.

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/kbyk004-diy/playwright-lighthouse-mcp'

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