Skip to main content
Glama

screenshot_page

Capture page screenshots as base64 PNG images for browser automation, testing, and documentation purposes.

Instructions

Capture page screenshot as base64 PNG.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool handler: obtains Firefox instance, captures page screenshot via takeScreenshotPage(), validates result, builds formatted response with size checks and truncation if needed.
    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: name 'screenshot_page', 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:103-147 (registration)
    Registration of screenshot_page handler in the central toolHandlers Map used by the MCP server.
    const toolHandlers = new Map< string, (input: unknown) => Promise<{ content: Array<{ type: string; text: string }>; isError?: boolean }> >([ // Pages ['list_pages', tools.handleListPages], ['new_page', tools.handleNewPage], ['navigate_page', tools.handleNavigatePage], ['select_page', tools.handleSelectPage], ['close_page', tools.handleClosePage], // Script evaluation - DISABLED (see docs/future-features.md) // ['evaluate_script', tools.handleEvaluateScript], // Console ['list_console_messages', tools.handleListConsoleMessages], ['clear_console_messages', tools.handleClearConsoleMessages], // Network ['list_network_requests', tools.handleListNetworkRequests], ['get_network_request', tools.handleGetNetworkRequest], // Snapshot ['take_snapshot', tools.handleTakeSnapshot], ['resolve_uid_to_selector', tools.handleResolveUidToSelector], ['clear_snapshot', tools.handleClearSnapshot], // Input ['click_by_uid', tools.handleClickByUid], ['hover_by_uid', tools.handleHoverByUid], ['fill_by_uid', tools.handleFillByUid], ['drag_by_uid_to_uid', tools.handleDragByUidToUid], ['fill_form_by_uid', tools.handleFillFormByUid], ['upload_file_by_uid', tools.handleUploadFileByUid], // Screenshot ['screenshot_page', tools.handleScreenshotPage], ['screenshot_by_uid', tools.handleScreenshotByUid], // Utilities ['accept_dialog', tools.handleAcceptDialog], ['dismiss_dialog', tools.handleDismissDialog], ['navigate_history', tools.handleNavigateHistory], ['set_viewport_size', tools.handleSetViewportSize], ]);
  • src/index.ts:182-191 (registration)
    Inclusion of screenshotPageTool schema in the allTools array for listTools response.
    // Screenshot tools.screenshotPageTool, tools.screenshotByUidTool, // Utilities tools.acceptDialogTool, tools.dismissDialogTool, tools.navigateHistoryTool, tools.setViewportSizeTool, ];
  • Helper function to format screenshot response with size calculation, truncation for token limits, and emoji/size warnings.
    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