Skip to main content
Glama

pilot_screenshot

Capture screenshots of web pages or specific elements using browser automation. Specify full-page captures, element references, or custom clip regions for precise documentation and analysis.

Instructions

Take a screenshot of the page or a specific element.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
refNoElement ref or CSS selector to screenshot
full_pageNoCapture full page (default: true)
output_pathNoOutput file path
clipNoClip region {x, y, width, height}

Implementation Reference

  • Handler function for pilot_screenshot which takes a screenshot using Playwright and returns it as an MCP image content.
    async ({ ref, full_page, output_path, clip }) => {
      await bm.ensureBrowser();
      try {
        const page = bm.getPage();
        const screenshotPath = output_path || path.join(TEMP_DIR, 'pilot-screenshot.png');
    
        if (ref) {
          const resolved = await bm.resolveRef(ref);
          const locator = 'locator' in resolved ? resolved.locator : page.locator(resolved.selector);
          await locator.screenshot({ path: screenshotPath, timeout: 5000 });
        } else if (clip) {
          await page.screenshot({ path: screenshotPath, clip });
        } else {
          await page.screenshot({ path: screenshotPath, fullPage: full_page !== false });
        }
    
        const imageData = fs.readFileSync(screenshotPath);
        const base64 = imageData.toString('base64');
    
        return {
          content: [
            { type: 'text' as const, text: `Screenshot saved: ${screenshotPath}` },
            { type: 'image' as const, data: base64, mimeType: 'image/png' },
          ],
        };
      } catch (err) {
        return { content: [{ type: 'text' as const, text: wrapError(err) }], isError: true };
      }
    }
  • Input schema for pilot_screenshot tool.
    {
      ref: z.string().optional().describe('Element ref or CSS selector to screenshot'),
      full_page: z.boolean().optional().describe('Capture full page (default: true)'),
      output_path: z.string().optional().describe('Output file path'),
      clip: z.object({
        x: z.number(),
        y: z.number(),
        width: z.number(),
        height: z.number(),
      }).optional().describe('Clip region {x, y, width, height}'),
    },
  • Full registration of the pilot_screenshot tool.
    server.tool(
      'pilot_screenshot',
      'Take a screenshot of the page or a specific element.',

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/TacosyHorchata/Pilot'

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