Skip to main content
Glama

take_screenshot

Capture browser screenshots as base64 PNG images for visual feedback during web automation. Supports viewport, full-page, or element-specific captures to analyze displayed content before interacting with buttons or forms.

Instructions

Capture a screenshot of the current browser page as a base64-encoded PNG image. Essential for visual feedback to understand what's displayed before deciding which buttons to click or forms to fill. Supports capturing the visible viewport, entire scrollable page, or specific elements. Returns the image as base64 string and data URL for easy display.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesSession ID obtained from initialize_session
fullPageNoCapture the entire scrollable page content (true) or just visible viewport (false). Use true for long pages (default: false)
selectorNoOptional CSS selector to capture only a specific element (e.g., '.chat-container', '#main-content')

Implementation Reference

  • Core implementation of the take_screenshot tool. Captures screenshot of the full page or specific element using Puppeteer and returns base64 encoded image.
    export async function takeScreenshot(
      sessionId,
      fullPage = false,
      selector = null
    ) {
      const session = getSession(sessionId);
      const { page } = session;
    
      let screenshotBuffer;
      if (selector) {
        const element = await page.$(selector);
        if (!element) {
          throw new Error(`Element with selector "${selector}" not found`);
        }
        screenshotBuffer = await element.screenshot();
      } else {
        screenshotBuffer = await page.screenshot({ fullPage });
      }
    
      const base64Image = screenshotBuffer.toString("base64");
    
      return {
        success: true,
        sessionId,
        currentUrl: page.url(),
        title: await page.title(),
        screenshotBase64: base64Image,
        screenshotDataUrl: `data:image/png;base64,${base64Image}`,
        message: "Screenshot captured successfully",
      };
    }
  • Defines the tool name, description, and input schema for validation in the MCP ListTools response.
    {
      name: "take_screenshot",
      description:
        "Capture a screenshot of the current browser page as a base64-encoded PNG image. Essential for visual feedback to understand what's displayed before deciding which buttons to click or forms to fill. Supports capturing the visible viewport, entire scrollable page, or specific elements. Returns the image as base64 string and data URL for easy display.",
      inputSchema: {
        type: "object",
        properties: {
          sessionId: {
            type: "string",
            description: "Session ID obtained from initialize_session",
          },
          fullPage: {
            type: "boolean",
            description:
              "Capture the entire scrollable page content (true) or just visible viewport (false). Use true for long pages (default: false)",
            default: false,
          },
          selector: {
            type: "string",
            description:
              "Optional CSS selector to capture only a specific element (e.g., '.chat-container', '#main-content')",
          },
        },
        required: ["sessionId"],
      },
  • src/index.js:429-438 (registration)
    Registers and dispatches the take_screenshot tool call in the MCP CallToolRequest handler by invoking the takeScreenshot function.
    case "take_screenshot": {
      const { sessionId, fullPage = false, selector } = args;
      if (!sessionId) {
        throw new McpError(
          ErrorCode.InvalidParams,
          "sessionId parameter is required"
        );
      }
      result = await takeScreenshot(sessionId, fullPage, selector);
      break;
  • Re-exports the takeScreenshot function for centralized import in the main index.js file.
    export { takeScreenshot, getCurrentPageInfo } from "./visualInspection.js";
  • Imports the getSession helper function used by takeScreenshot to retrieve the browser session.
    import { getSession } from "./sessionManagement.js";
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key traits: the tool captures screenshots in various modes (viewport, full page, or specific elements) and returns data in multiple formats (base64 string and data URL). It could improve by mentioning potential limitations like performance impacts or browser compatibility, but it covers the core functionality well.

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 appropriately sized and front-loaded, starting with the core action and purpose in the first sentence. Each subsequent sentence adds value: explaining use cases, detailing capture options, and describing return formats. There is no wasted text, making it efficient and easy to parse for an AI agent.

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 moderate complexity (3 parameters, no output schema, no annotations), the description is largely complete. It covers the purpose, usage context, behavioral aspects, and return formats. However, it could be more comprehensive by addressing potential errors or edge cases, such as what happens if the selector is invalid or the sessionId is expired, which would help an agent handle failures better.

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?

The input schema has 100% description coverage, providing detailed information for all three parameters (sessionId, fullPage, selector). The description adds minimal value beyond the schema, only implying the capture modes without elaborating on parameter usage. Since schema coverage is high, the baseline score of 3 is appropriate, as the description does not significantly enhance parameter understanding.

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?

The description clearly states the tool's purpose with specific verbs ('capture a screenshot') and resources ('current browser page'), distinguishing it from siblings like click_element or get_current_page_info by focusing on visual capture rather than interaction or information retrieval. It explicitly mentions the output format ('base64-encoded PNG image'), which sets it apart from other tools.

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 provides clear context for when to use this tool ('essential for visual feedback to understand what's displayed before deciding which buttons to click or forms to fill'), offering practical guidance. However, it does not explicitly state when not to use it or name specific alternatives among siblings, such as get_current_page_info for textual information instead of visuals.

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/pyscout/webscout-mcp'

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