Skip to main content
Glama
seabassgonzalez

MCP Browser Screenshot Server

screenshot_viewport

Capture web page screenshots with customizable viewport dimensions and device presets for testing responsive designs and monitoring web content.

Instructions

Take a screenshot with specific viewport settings

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fullPageNoCapture full page screenshot
heightNoCustom viewport height
presetNoViewport preset to use
widthNoCustom viewport width

Implementation Reference

  • Handler for the screenshot_viewport tool: sets the page viewport using provided preset or custom dimensions, then captures and returns a base64-encoded PNG screenshot.
    case 'screenshot_viewport': {
      const { page } = await ensureBrowser();
      const preset = args?.preset as string | undefined;
      const width = args?.width as number | undefined;
      const height = args?.height as number | undefined;
      const fullPage = args?.fullPage === true;
    
      if (preset && viewportPresets[preset]) {
        await page.setViewport(viewportPresets[preset]);
      } else if (width && height) {
        await page.setViewport({ width, height });
      } else {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Either preset or width/height must be provided',
        );
      }
    
      const screenshot = (await page.screenshot({ fullPage })) as Buffer;
    
      return {
        content: [
          {
            type: 'text',
            text: `data:image/png;base64,${screenshot.toString('base64')}`,
          },
        ],
      };
    }
  • src/index.ts:164-190 (registration)
    Registration of the screenshot_viewport tool in the list of available tools, including name, description, and input schema.
    {
      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,
          },
        },
      },
    },
  • Input schema defining parameters for the screenshot_viewport tool: preset, width, height, fullPage.
    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,
        },
      },
  • Preset viewport configurations used by the screenshot_viewport handler for common device sizes.
    const viewportPresets: Record<string, ViewportPreset> = {
      mobile: {
        width: 375,
        height: 812,
        deviceScaleFactor: 3,
        isMobile: true,
        hasTouch: true,
      },
      tablet: {
        width: 768,
        height: 1024,
        deviceScaleFactor: 2,
        isMobile: true,
        hasTouch: true,
      },
      desktop: {
        width: 1920,
        height: 1080,
        deviceScaleFactor: 1,
      },
      laptop: {
        width: 1366,
        height: 768,
        deviceScaleFactor: 1,
      },
    };
  • Utility function to ensure a browser and page instance are available, launching if necessary. Used by screenshot_viewport 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 but only states the basic action without disclosing behavioral traits. It doesn't mention whether this requires an active browser session, what format the screenshot returns, if there are rate limits, or what happens when viewport parameters conflict.

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 - a single sentence that directly states the tool's purpose without unnecessary words. It's front-loaded with the core action and immediately specifies the key differentiator (viewport settings).

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 tool with 4 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what the tool returns (image format, size limitations), doesn't mention dependencies on browser state, and provides no context about how it relates to sibling browser tools.

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?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds minimal value beyond implying viewport customization but doesn't explain parameter interactions (e.g., how preset relates to width/height, what happens when fullPage is true with custom dimensions).

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 specifies the scope ('with specific viewport settings'), which distinguishes it from generic screenshot tools. However, it doesn't explicitly differentiate from sibling 'screenshot_capture' tool, which might have overlapping functionality.

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_capture' or other browser tools. There's no mention of prerequisites, context requirements, or comparison with sibling tools.

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