Skip to main content
Glama
jomon003

PlayMCP Browser Automation Server

by jomon003

screenshot

Capture screenshots of web pages, specific elements, or the viewport using PlayMCP's automation tool. Define the path and select the area to save for web testing or analysis.

Instructions

Take a screenshot

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes
selectorNo
typeNo

Implementation Reference

  • The core handler function that performs the screenshot operation using Playwright API, handling element, viewport, or full page captures.
    async screenshot(options: ScreenshotOptions): Promise<void> { try { if (!this.isInitialized() || !this.state.page) { throw new Error('Browser not initialized'); } this.log('Taking screenshot', options); if (options.type === 'element' && options.selector) { const element = await this.state.page.$(options.selector); if (!element) { throw new Error('Element not found'); } await element.screenshot({ path: options.path }); } else if (options.type === 'viewport') { await this.state.page.screenshot({ path: options.path }); } else { await this.state.page.screenshot({ path: options.path, fullPage: true }); } this.log('Screenshot saved to', options.path); } catch (error: any) { console.error('Screenshot error:', error); throw new BrowserError( 'Failed to take screenshot', 'Check if the path is writable and element exists (if capturing element)' ); } }
  • TypeScript interface defining the input structure for the screenshot tool parameters.
    export interface ScreenshotOptions { path: string; type?: 'element' | 'page' | 'viewport'; selector?: string; }
  • src/server.ts:69-81 (registration)
    Tool definition object including name, description, and JSON schema for input validation, used for MCP tool registration.
    const SCREENSHOT_TOOL: Tool = { name: "screenshot", description: "Take a screenshot", inputSchema: { type: "object", properties: { path: { type: "string" }, type: { type: "string", enum: ["viewport", "element", "page"] }, selector: { type: "string" } }, required: ["path"] } };
  • src/server.ts:666-677 (registration)
    Switch case in callTool handler that validates input and invokes the screenshot method on the Playwright controller.
    case 'screenshot': { if (!args.path) { return { content: [{ type: "text", text: "Path is required" }], isError: true }; } await playwrightController.screenshot(args as any); return { content: [{ type: "text", text: "Screenshot taken successfully" }] }; }
  • src/server.ts:521-521 (registration)
    Maps the screenshot tool to the tools object provided to the MCP server capabilities.
    screenshot: SCREENSHOT_TOOL,

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/jomon003/PlayMCP'

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