Skip to main content
Glama
random-robbie

MCP Web Browser Server

get_page_screenshots

Capture screenshots of web pages or specific elements using a headless browser, returning base64 encoded images for documentation or analysis.

Instructions

Capture screenshot of the current page.

Args:
    full_page: Whether to capture the entire page or just the viewport
    selector: Optional CSS selector to screenshot a specific element
    context: Optional context object for logging (ignored)

Returns:
    Base64 encoded screenshot image

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
full_pageNo
selectorNo
contextNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the 'get_page_screenshots' tool. It captures a screenshot of the current page (full page or viewport) or a specific element, encodes it as base64, and returns it. Requires a page to be loaded via 'browse_to' first.
    async def get_page_screenshots(
        full_page: bool = False, 
        selector: Optional[str] = None,
        context: Optional[Any] = None
    ) -> str:
        """
        Capture screenshot of the current page.
        
        Args:
            full_page: Whether to capture the entire page or just the viewport
            selector: Optional CSS selector to screenshot a specific element
            context: Optional context object for logging (ignored)
        
        Returns:
            Base64 encoded screenshot image
        """
        global _current_page
        
        if not _current_page:
            raise ValueError("No page is currently loaded. Use browse_to first.")
        
        try:
            if selector:
                element = await _current_page.query_selector(selector)
                if not element:
                    raise ValueError(f"No element found with selector: {selector}")
                screenshot_bytes = await element.screenshot()
            else:
                screenshot_bytes = await _current_page.screenshot(full_page=full_page)
            
            # Convert to base64 for easy transmission
            screenshot_base64 = base64.b64encode(screenshot_bytes).decode('utf-8')
            
            print(f"Screenshot captured: {'full page' if full_page else 'viewport'}", file=sys.stderr)
            
            return screenshot_base64
        
        except Exception as e:
            print(f"Error capturing screenshot: {e}", file=sys.stderr)
            raise ValueError(f"Error capturing screenshot: {e}")

Tool Definition Quality

Score is being calculated. Check back soon.

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/random-robbie/mcp-web-browser'

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