Skip to main content
Glama

screenshot_page

Capture PNG screenshots of web pages for visual verification and testing purposes using browser automation.

Instructions

Capture a PNG screenshot of the current page and return it as a base64 string (without data: prefix). TIP: Use for visual verification rather than structural inspection.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler function that captures a screenshot of the current page using Firefox DevTools, processes the base64 PNG data with size checks via helper, and returns a formatted MCP tool response.
    export async function handleScreenshotPage(_args: unknown): Promise<McpToolResponse> { try { const { getFirefox } = await import('../index.js'); const firefox = await getFirefox(); const base64Png = await firefox.takeScreenshotPage(); if (!base64Png || typeof base64Png !== 'string') { throw new Error('Invalid screenshot data'); } return buildScreenshotResponse(base64Png, 'page'); } catch (error) { return errorResponse(error as Error); } }
  • Tool schema definition for 'screenshot_page', specifying name, description, and empty input schema (no parameters required).
    export const screenshotPageTool = { name: 'screenshot_page', description: 'Capture page screenshot as base64 PNG.', inputSchema: { type: 'object', properties: {}, }, };
  • src/index.ts:139-139 (registration)
    Maps the 'screenshot_page' tool name to its handler function in the central toolHandlers Map used by the MCP server for execution.
    ['screenshot_page', tools.handleScreenshotPage],
  • src/index.ts:183-183 (registration)
    Includes the screenshotPageTool schema in the allTools array provided to clients via the listTools MCP request.
    tools.screenshotPageTool,
  • Supporting function to format screenshot responses with size calculations, truncation for token limits, and emoji-prefixed output.
    function buildScreenshotResponse(base64Png: string, label: string): McpToolResponse { const sizeKB = Math.round(base64Png.length / 1024); // Check if screenshot exceeds size limit if (base64Png.length > TOKEN_LIMITS.MAX_SCREENSHOT_CHARS) { const truncatedData = base64Png.slice(0, TOKEN_LIMITS.MAX_SCREENSHOT_CHARS); return successResponse(`📸 ${label} (${sizeKB}KB) [truncated]\n${truncatedData}`); } // Add warning for large screenshots const warn = base64Png.length > TOKEN_LIMITS.WARNING_THRESHOLD_CHARS ? ' [large]' : ''; return successResponse(`📸 ${label} (${sizeKB}KB)${warn}\n${base64Png}`); }

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/freema/firefox-devtools-mcp'

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