Skip to main content
Glama

browser_screenshot

Capture screenshots of web pages or specific elements using parallel browser instances for testing, documentation, or monitoring purposes.

Instructions

Take a screenshot of the page or element

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
instanceIdYesInstance ID
fullPageNoWhether to capture the full page
selectorNoElement selector (capture specific element)
typeNoImage formatpng
qualityNoImage quality (1-100, JPEG only)

Implementation Reference

  • Core handler implementation that captures screenshot of the entire page or a specific element using Playwright APIs, returns base64 encoded image.
    private async screenshot(instanceId: string, options: ScreenshotOptions, selector?: string): Promise<ToolResult> {
      const instance = this.browserManager.getInstance(instanceId);
      if (!instance) {
        return { success: false, error: `Instance ${instanceId} not found` };
      }
    
      try {
        let screenshotData: Buffer;
        
        if (selector) {
          const element = await instance.page.$(selector);
          if (!element) {
            return { success: false, error: `Element not found: ${selector}`, instanceId };
          }
          screenshotData = await element.screenshot({
            type: options.type,
            quality: options.type === 'jpeg' ? options.quality : undefined
          });
        } else {
          screenshotData = await instance.page.screenshot({
            fullPage: options.fullPage,
            type: options.type,
            quality: options.type === 'jpeg' ? options.quality : undefined,
            clip: options.clip
          });
        }
    
        return {
          success: true,
          data: { 
            screenshot: screenshotData.toString('base64'),
            type: options.type,
            selector
          },
          instanceId
        };
      } catch (error) {
        return {
          success: false,
          error: `Screenshot failed: ${error instanceof Error ? error.message : error}`,
          instanceId
        };
      }
    }
  • src/tools.ts:359-394 (registration)
    Tool definition and registration in BrowserTools.getTools(), including name, description, and detailed input JSON schema.
    {
      name: 'browser_screenshot',
      description: 'Take a screenshot of the page or element',
      inputSchema: {
        type: 'object',
        properties: {
          instanceId: {
            type: 'string',
            description: 'Instance ID'
          },
          fullPage: {
            type: 'boolean',
            description: 'Whether to capture the full page',
            default: false
          },
          selector: {
            type: 'string',
            description: 'Element selector (capture specific element)'
          },
          type: {
            type: 'string',
            enum: ['png', 'jpeg'],
            description: 'Image format',
            default: 'png'
          },
          quality: {
            type: 'number',
            description: 'Image quality (1-100, JPEG only)',
            minimum: 1,
            maximum: 100,
            default: 80
          }
        },
        required: ['instanceId']
      }
    },
  • Dispatcher in executeTools method that routes the tool call to the screenshot handler with parsed arguments.
    case 'browser_screenshot':
      return await this.screenshot(args.instanceId, {
        fullPage: args.fullPage || false,
        type: args.type || 'png',
        quality: args.quality || 80
      }, args.selector);

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/sailaoda/concurrent-browser-mcp'

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