Skip to main content
Glama
jomon003

PlayMCP Browser Automation Server

by jomon003

takeScreenshot

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

Instructions

Take a screenshot of the page or specific element

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes
fullPageNoWhether to capture the full scrollable page
elementNoCSS selector for element screenshot

Implementation Reference

  • Core implementation of the takeScreenshot tool using Playwright to capture page or element screenshots.
    async takeScreenshot(path: string, options?: {fullPage?: boolean, element?: string}): Promise<void> { try { if (!this.isInitialized() || !this.state.page) { throw new Error('Browser not initialized'); } this.log('Taking screenshot', { path, options }); if (options?.element) { const locator = this.state.page.locator(options.element); await locator.screenshot({ path }); } else { await this.state.page.screenshot({ path, fullPage: options?.fullPage }); } this.log('Screenshot saved'); } catch (error: any) { console.error('Screenshot error:', error); throw new BrowserError('Failed to take screenshot', 'Check if the path is writable'); } }
  • Defines the tool metadata, description, and input schema (path required, fullPage/element optional).
    const TAKE_SCREENSHOT_TOOL: Tool = { name: "takeScreenshot", description: "Take a screenshot of the page or specific element", inputSchema: { type: "object", properties: { path: { type: "string" }, fullPage: { type: "boolean", description: "Whether to capture the full scrollable page" }, element: { type: "string", description: "CSS selector for element screenshot" } }, required: ["path"] } };
  • src/server.ts:548-548 (registration)
    Registers the takeScreenshot tool in the tools dictionary provided to the MCP Server's capabilities.
    takeScreenshot: TAKE_SCREENSHOT_TOOL,
  • Dispatches the takeScreenshot tool call in the MCP server's callTool handler, validating args and invoking the controller.
    case 'takeScreenshot': { if (!args.path) { return { content: [{ type: "text", text: "Path is required" }], isError: true }; } await playwrightController.takeScreenshot(args.path as string, { fullPage: args.fullPage as boolean, element: args.element as string }); return { content: [{ type: "text", text: "Screenshot taken successfully" }] }; }

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