Skip to main content
Glama

browser_screenshot

Capture webpage or element screenshots and save them in desired formats or directories using Chrome automation with anti-bot detection bypass.

Instructions

Take a screenshot of the current page or a specific element

Args: name: The name of the screenshot - required, default is "screenshot" storeBase64: Whether to store the screenshot as a base64 string - optional, default is True downloadsDir: The directory to save the screenshot to - optional, default is the user's Downloads directory

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
downloadsDirNo
nameYes
storeBase64No

Implementation Reference

  • The main handler function for the 'browser_screenshot' tool. It takes a screenshot of the current browser page, saves it to a specified directory with a timestamped filename, and optionally stores the base64 encoded image in memory under the given name. Uses undetected_chromedriver and handles browser state via shared global webdriver.
    @mcp.tool() async def browser_screenshot( name: str, storeBase64: bool = True, downloadsDir: str = None, ): """Take a screenshot of the current page or a specific element Args: name: The name of the screenshot - required, default is "screenshot" storeBase64: Whether to store the screenshot as a base64 string - optional, default is True downloadsDir: The directory to save the screenshot to - optional, default is the user's Downloads directory """ name = name or "screenshot" async def screenshot_handler(driver: uc.Chrome): timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H-%M-%S") filename = f"{name}-{timestamp}.png" download_dir = downloadsDir or DEFAULT_DOWNLOAD_PATH os.makedirs(download_dir, exist_ok=True) output_path = os.path.join(download_dir, filename) driver.save_screenshot(output_path) messages = [f"Screenshot saved to: {os.path.relpath(output_path, os.getcwd())}"] if storeBase64: base64 = driver.get_screenshot_as_base64() SCREENSHOTS[name] = base64 # todo: notifications/resources/list_changed messages.append(f"Screenshot also stored in memory with name: {name}") return await create_success_response(messages) return await tool.safe_execute( ToolContext(webdriver=await ensure_browser()), screenshot_handler )
  • The @mcp.tool() decorator registers the browser_screenshot function as an MCP tool.
    @mcp.tool()

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/dragons96/mcp-undetected-chromedriver'

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