Skip to main content
Glama
jomon003

PlayMCP Browser Automation Server

by jomon003

screenshot

Capture browser screenshots for web automation tasks. Specify viewport, element, or full page captures with Playwright integration.

Instructions

Take a screenshot

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes
typeNo
selectorNo

Implementation Reference

  • Core implementation of the screenshot tool in PlaywrightController. Handles screenshot types: element, viewport, full page. Uses Playwright API to capture and save to path.
    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)' ); } }
  • MCP Tool schema for 'screenshot' defining input parameters: path (required), type (viewport/element/page), selector.
    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:521-521 (registration)
    Registration of SCREENSHOT_TOOL in the tools dictionary provided to MCP server capabilities.
    screenshot: SCREENSHOT_TOOL,
  • MCP callTool dispatch case for 'screenshot' tool: validates path arg and calls playwrightController.screenshot.
    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" }] }; }
  • TypeScript interface defining ScreenshotOptions for type safety in the handler.
    export interface ScreenshotOptions { path: string; type?: 'element' | 'page' | 'viewport'; selector?: string; }

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