Skip to main content
Glama

take_screenshot

Capture browser page screenshots for automation testing and documentation using Playwright's browser control capabilities.

Instructions

Take a screenshot of the current page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
page_idNo
selectorNo

Implementation Reference

  • Handler for executing the take_screenshot tool: captures screenshot of page or element, encodes to base64, returns as ImageContent.
    elif name == "take_screenshot":
        page = get_active_page(arguments.get("page_id"))
        selector = arguments.get("selector")
        
        if selector:
            screenshot = await page.locator(selector).screenshot()
        else:
            screenshot = await page.screenshot()
        
        # Convert the bytes to base64
        base64_image = base64.b64encode(screenshot).decode('utf-8')
        
        # Return as ImageContent
        return [types.ImageContent(
            type="image",
            image=types.ImageData(
                mime_type="image/png",
                data=base64_image
            )
        )]
  • Registration of the take_screenshot tool in the list_tools() response, defining name, description, and input schema.
    types.Tool(
        name="take_screenshot",
        description="Take a screenshot of the current page",
        inputSchema={
            "type": "object",
            "properties": {
                "page_id": {"type": "string"},
                "selector": {"type": "string"},
            },
        },
    ),
  • Input schema definition for take_screenshot tool: optional page_id and selector.
    inputSchema={
        "type": "object",
        "properties": {
            "page_id": {"type": "string"},
            "selector": {"type": "string"},
        },
    },
  • Helper function used by take_screenshot (and other tools) to retrieve the active Playwright Page instance.
    def get_active_page(page_id: Optional[str] = None) -> Page:
        """Get the active page based on page_id or current default."""
        global current_page_id
        
        if page_id is None:
            page_id = current_page_id
        
        if page_id not in pages:
            raise ValueError(f"Page not found: {page_id}")
        
        return pages[page_id]
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. While 'take a screenshot' implies a read operation that captures visual state, it doesn't specify whether this requires page visibility, what format the screenshot returns (image data, file path, etc.), whether it waits for page load, or any performance/rate limit considerations. The description adds minimal behavioral context beyond the basic action.

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 extremely concise at just 6 words, front-loading the core functionality with zero wasted words. Every word earns its place by communicating the essential action and target without unnecessary elaboration.

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?

For a tool with 2 undocumented parameters, no annotations, and no output schema, the description is insufficiently complete. It doesn't explain what the tool returns (image format, location, etc.), how parameters affect the screenshot (full page vs. element), or any behavioral constraints. The minimal description leaves too many unknowns for effective tool selection and invocation.

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

Parameters2/5

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

The input schema has 2 parameters (page_id, selector) with 0% description coverage, meaning neither parameter is documented in the schema. The description provides no information about these parameters - it doesn't explain what page_id refers to, what selector is used for, or whether parameters are optional/required. The description fails to compensate for the schema's lack of documentation.

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 ('take a screenshot') and the target ('current page'), providing a specific verb+resource combination. However, it doesn't distinguish this tool from potential alternatives like capturing specific elements versus full pages, which would require sibling tool analysis for full differentiation.

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 'get_page_content' or 'get_text' for content extraction, or when screenshots are preferable to other capture methods. There's no mention of prerequisites, timing considerations, or comparison with sibling tools.

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/misanthropic-ai/playwrite-mcp'

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