Skip to main content
Glama
b3nw
by b3nw

Take Screenshot

browser_take_screenshot

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

Instructions

Take a screenshot of the current page or a specific element

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fullPageNo
selectorNo

Implementation Reference

  • The main execution handler for browser_take_screenshot tool. Parses input, ensures browser connection, takes screenshot of the full page or specified selector, encodes to base64, and returns as text content.
    async (params: any) => {
      try {
        const input = z.object({
          fullPage: z.boolean().optional().default(false),
          selector: z.string().optional()
        }).parse(params);
        await this.playwright.ensureConnected();
        
        const page = this.playwright.getPage();
        let screenshot: Buffer;
        
        if (input.selector) {
          const element = await page.locator(input.selector);
          screenshot = await element.screenshot();
        } else {
          screenshot = await page.screenshot({ fullPage: input.fullPage });
        }
        
        return {
          content: [{
            type: 'text',
            text: `Screenshot taken (${screenshot.length} bytes), base64: ${screenshot.toString('base64')}`
          }]
        };
      } catch (error) {
        return {
          content: [{
            type: 'text',
            text: `Screenshot failed: ${error instanceof Error ? error.message : String(error)}`
          }],
          isError: true
        };
      }
    }
  • Zod schema defining the input parameters for the browser_take_screenshot tool: optional fullPage boolean and selector string.
    export const BrowserTakeScreenshotInputSchema = z.object({
      fullPage: z.boolean().optional().default(false),
      selector: z.string().optional()
    });
  • src/server.ts:64-72 (registration)
    Registers the browser_take_screenshot tool with the MCP server, providing name, title, description, and input schema.
    'browser_take_screenshot',
    {
      title: 'Take Screenshot',
      description: 'Take a screenshot of the current page or a specific element',
      inputSchema: {
        fullPage: z.boolean().optional().default(false),
        selector: z.string().optional()
      }
    },
  • Helper method in PlaywrightManager that ensures the browser is connected and page is ready before executing the screenshot.
    async ensureConnected(): Promise<void> {
      const connected = await this.isConnected();
      if (!connected) {
        await this.cleanup();
        await this.connect();
      }
    }
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 states what the tool does but lacks critical details: it doesn't specify if this requires page visibility, what format the screenshot returns (e.g., image data, file path), potential errors, or performance implications. This is inadequate for a tool with mutation-like effects.

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 with no wasted words. It's appropriately sized and front-loaded, directly stating the tool's purpose without unnecessary elaboration.

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 screenshot tool with potential side effects), lack of annotations, no output schema, and low schema coverage, the description is incomplete. It doesn't address return values, error conditions, or behavioral nuances, leaving significant gaps for an AI agent to use it correctly.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate for undocumented parameters. It mentions 'current page or a specific element', which loosely relates to the 'fullPage' and 'selector' parameters but doesn't explain their semantics, defaults, or interactions (e.g., that 'fullPage' defaults to false). This adds minimal value beyond the schema.

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 ('current page or a specific element'), which is a specific verb+resource combination. However, it doesn't explicitly distinguish this from sibling tools like 'browser_snapshot' which might have overlapping functionality, preventing a perfect score.

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 like 'browser_snapshot' or other screenshot-related methods. It mentions 'current page or a specific element' but doesn't clarify scenarios or exclusions, leaving usage decisions ambiguous.

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/b3nw/playwright-mcp-server'

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