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" }]
      };
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions the action but doesn't describe what happens (e.g., saves to a file, returns image data), potential side effects (e.g., may fail if browser not open), or constraints (e.g., permissions needed). This is inadequate for a mutation tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose without unnecessary details. Every word earns its place, making it highly concise and well-structured for quick understanding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (a mutation tool with no annotations and no output schema), the description is incomplete. It doesn't explain the return value, error conditions, or behavioral nuances, leaving significant gaps for an AI agent to correctly invoke the tool in a real-world context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds minimal meaning beyond the input schema. It implies 'page' and 'specific element' as targets, which loosely maps to the 'fullPage' and 'element' parameters, but doesn't explain their interaction or the 'path' parameter's role. With 67% schema description coverage (two parameters have descriptions), the baseline is 3, as the schema does some heavy lifting but the description doesn't fully compensate for gaps.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('take a screenshot') and the target ('page or specific element'), which is a specific verb+resource combination. However, it doesn't distinguish this tool from the sibling 'screenshot' tool, which appears to be a duplicate or similar functionality, leaving some ambiguity about when to use one versus the other.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention the sibling 'screenshot' tool or other related tools like 'getImages', nor does it specify prerequisites (e.g., requiring an open browser) or contexts for use, leaving the agent to infer usage from the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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