Skip to main content
Glama

screenshot

Capture web page screenshots by providing a URL, with options for full-page capture and viewport dimensions.

Instructions

Captura screenshot de uma página web

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesURL da página para capturar
fullPageNoCapturar página inteira ou apenas viewport
widthNoLargura do viewport em pixels
heightNoAltura do viewport em pixels

Implementation Reference

  • Core handler function for the screenshot tool: launches headless Chromium via Playwright, navigates to the provided URL, captures a PNG screenshot (full page or viewport), encodes to base64, determines dimensions, and returns a structured result.
    export async function screenshot( params: ScreenshotParams ): Promise<ScreenshotResult> { const { url, fullPage = false, width = 1920, height = 1080 } = params; const browser = await chromium.launch({ headless: true }); const page = await browser.newPage({ userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36", }); try { await page.setViewportSize({ width, height }); await page.goto(url, { waitUntil: "networkidle", timeout: 30000 }); await page.waitForTimeout(1000); const screenshotBuffer = await page.screenshot({ fullPage, type: "png", }); const dimensions = await page.evaluate(() => ({ width: document.documentElement.scrollWidth, height: document.documentElement.scrollHeight, })); return { url, base64: screenshotBuffer.toString("base64"), width: fullPage ? dimensions.width : width, height: fullPage ? dimensions.height : height, timestamp: new Date().toISOString(), }; } finally { await browser.close(); } }
  • TypeScript interfaces defining the input parameters (ScreenshotParams) and output structure (ScreenshotResult) for the screenshot tool.
    interface ScreenshotParams { url: string; fullPage?: boolean; width?: number; height?: number; } interface ScreenshotResult { url: string; base64: string; width: number; height: number; timestamp: string; }
  • Zod schema for input validation of the screenshot tool parameters, used in MCP server.tool registration.
    { url: z .string() .url() .describe("URL da página para capturar"), fullPage: z .boolean() .default(false) .describe("Capturar página inteira ou apenas viewport"), width: z .number() .int() .default(1920) .describe("Largura do viewport em pixels"), height: z .number() .int() .default(1080) .describe("Altura do viewport em pixels"), },
  • src/index.ts:112-147 (registration)
    MCP server registration of the 'screenshot' tool, including description, input schema, and wrapper handler that invokes the core screenshot function and returns MCP-formatted content (text description + base64 image).
    server.tool( "screenshot", "Captura screenshot de uma página web", { url: z .string() .url() .describe("URL da página para capturar"), fullPage: z .boolean() .default(false) .describe("Capturar página inteira ou apenas viewport"), width: z .number() .int() .default(1920) .describe("Largura do viewport em pixels"), height: z .number() .int() .default(1080) .describe("Altura do viewport em pixels"), }, async (params) => { const result = await screenshot(params); return { content: [ { type: "text", text: `Screenshot capturado: ${result.width}x${result.height}`, }, { type: "image", data: result.base64, mimeType: "image/png" }, ], }; } );

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/alucardeht/isis-mcp'

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