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}`);
    }
Behavior2/5

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

With no annotations, the description carries full burden but only states the output format without behavioral details. It doesn't mention whether this captures the current viewport or full page, requires a page to be loaded, has size/quality limits, or affects page state. This leaves significant gaps for a mutation-like tool.

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 a single, efficient sentence with zero waste. It's front-loaded with the core action and output format, making it easy to parse. Every word earns its place without redundancy.

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 no annotations, no output schema, and behavioral implications (capturing may involve rendering or state changes), the description is incomplete. It lacks details on return values, error conditions, or operational constraints, making it inadequate for safe and effective use.

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

Parameters4/5

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

The tool has 0 parameters with 100% schema coverage, so no parameter documentation is needed. The description doesn't add parameter details, which is appropriate here. A baseline of 4 is applied since no parameters exist, and the description doesn't introduce confusion.

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 ('Capture') and resource ('page screenshot'), specifying the output format ('base64 PNG'). It distinguishes from sibling 'screenshot_by_uid' by targeting the current page rather than a specific element. However, it doesn't explicitly mention the current page context, leaving some ambiguity.

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?

No guidance is provided on when to use this tool versus alternatives like 'screenshot_by_uid' for element-specific captures or 'take_snapshot' which might serve a similar purpose. The description implies usage for capturing the entire page, but lacks explicit context or prerequisites.

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

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