Skip to main content
Glama
seabassgonzalez

MCP Browser Screenshot Server

screenshot_capture

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

Instructions

Take a screenshot of the current page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formatNoOutput format for the screenshotbase64
fullPageNoCapture full page screenshot
selectorNoCSS selector of element to screenshot

Implementation Reference

  • Handler for the screenshot_capture tool: captures screenshot of the current page or a specific element, supports fullPage, selector, and format (base64/binary). Uses Puppeteer page.screenshot() or element.screenshot().
    case 'screenshot_capture': {
      const { page } = await ensureBrowser();
      const fullPage = args?.fullPage === true;
      const selector = args?.selector as string | undefined;
      const format = (args?.format as string) || 'base64';
    
      let screenshot: Buffer;
    
      if (selector) {
        const element = await page.$(selector);
        if (!element) {
          throw new McpError(
            ErrorCode.InvalidParams,
            `Element with selector "${selector}" not found`,
          );
        }
        screenshot = (await element.screenshot()) as Buffer;
      } else {
        screenshot = (await page.screenshot({ fullPage })) as Buffer;
      }
    
      if (format === 'base64') {
        return {
          content: [
            {
              type: 'text',
              text: `data:image/png;base64,${screenshot.toString('base64')}`,
            },
          ],
        };
      } else {
        return {
          content: [
            {
              type: 'text',
              text: 'Screenshot captured as binary data',
            },
          ],
        };
      }
    }
  • Schema definition for screenshot_capture tool, defining input parameters: fullPage (boolean), selector (string), format (enum: base64/binary).
      name: 'screenshot_capture',
      description: 'Take a screenshot of the current page',
      inputSchema: {
        type: 'object',
        properties: {
          fullPage: {
            type: 'boolean',
            description: 'Capture full page screenshot',
            default: false,
          },
          selector: {
            type: 'string',
            description: 'CSS selector of element to screenshot',
          },
          format: {
            type: 'string',
            enum: ['base64', 'binary'],
            description: 'Output format for the screenshot',
            default: 'base64',
          },
        },
      },
    },
  • src/index.ts:90-207 (registration)
    Registration of all tools including screenshot_capture in the ListToolsRequestSchema handler.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          {
            name: 'browser_launch',
            description: 'Launch a new browser instance',
            inputSchema: {
              type: 'object',
              properties: {
                headless: {
                  type: 'boolean',
                  description: 'Run browser in headless mode',
                  default: true,
                },
              },
            },
          },
          {
            name: 'browser_navigate',
            description: 'Navigate to a URL',
            inputSchema: {
              type: 'object',
              properties: {
                url: {
                  type: 'string',
                  description: 'URL to navigate to',
                },
                waitUntil: {
                  type: 'string',
                  enum: [
                    'load',
                    'domcontentloaded',
                    'networkidle0',
                    'networkidle2',
                  ],
                  description: 'When to consider navigation complete',
                  default: 'networkidle2',
                },
              },
              required: ['url'],
            },
          },
          {
            name: 'browser_close',
            description: 'Close the browser instance',
            inputSchema: {
              type: 'object',
              properties: {},
            },
          },
          {
            name: 'screenshot_capture',
            description: 'Take a screenshot of the current page',
            inputSchema: {
              type: 'object',
              properties: {
                fullPage: {
                  type: 'boolean',
                  description: 'Capture full page screenshot',
                  default: false,
                },
                selector: {
                  type: 'string',
                  description: 'CSS selector of element to screenshot',
                },
                format: {
                  type: 'string',
                  enum: ['base64', 'binary'],
                  description: 'Output format for the screenshot',
                  default: 'base64',
                },
              },
            },
          },
          {
            name: 'screenshot_viewport',
            description: 'Take a screenshot with specific viewport settings',
            inputSchema: {
              type: 'object',
              properties: {
                preset: {
                  type: 'string',
                  enum: ['mobile', 'tablet', 'desktop', 'laptop'],
                  description: 'Viewport preset to use',
                },
                width: {
                  type: 'number',
                  description: 'Custom viewport width',
                },
                height: {
                  type: 'number',
                  description: 'Custom viewport height',
                },
                fullPage: {
                  type: 'boolean',
                  description: 'Capture full page screenshot',
                  default: false,
                },
              },
            },
          },
          {
            name: 'browser_execute_script',
            description: 'Execute JavaScript in the browser context',
            inputSchema: {
              type: 'object',
              properties: {
                script: {
                  type: 'string',
                  description: 'JavaScript code to execute',
                },
              },
              required: ['script'],
            },
          },
        ],
      };
    });
  • Helper function ensureBrowser() that launches Puppeteer browser and page if not available, used by screenshot_capture and other tools.
    async function ensureBrowser(): Promise<{ browser: Browser; page: Page }> {
      if (!browserState.browser || !browserState.browser.isConnected()) {
        const headless = process.env.HEADLESS !== 'false';
        browserState.browser = await puppeteer.launch({
          headless,
          args: ['--no-sandbox', '--disable-setuid-sandbox'],
        });
        browserState.page = await browserState.browser.newPage();
      }
    
      if (!browserState.page || browserState.page.isClosed()) {
        browserState.page = await browserState.browser.newPage();
      }
    
      return {
        browser: browserState.browser,
        page: browserState.page,
      };
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. While 'Take a screenshot' implies a read operation, it doesn't address important behavioral aspects like whether this requires specific permissions, if it captures only visible content or includes off-screen elements, or what happens with dynamic content. The description lacks behavioral context beyond the basic action.

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 extremely concise at just 5 words, with zero wasted language. It's front-loaded with the core action and target, making it immediately understandable 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?

For a screenshot tool with 3 parameters and no annotations or output schema, the description is insufficiently complete. It doesn't explain what format the screenshot returns (image data, file path, etc.), how it handles different page states, or the relationship between parameters like 'fullPage' and 'selector'. The agent would need to guess about important behavioral aspects.

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 no parameter information beyond what's already documented in the schema (which has 100% coverage). The schema fully describes all three parameters with their types, defaults, and enums. The description doesn't provide additional context about parameter interactions or usage scenarios.

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 target ('of the current page'), providing a specific verb+resource combination. However, it doesn't differentiate from the sibling 'screenshot_viewport' tool, which appears to be a similar screenshot functionality with potentially different scope.

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 'screenshot_viewport' or other browser tools. There are no explicit when/when-not instructions or references to sibling tools, leaving the agent without contextual usage information.

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/seabassgonzalez/mcp-browser-screenshot'

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