Skip to main content
Glama
BrowserGenie

BrowserGenie MCP Server

by BrowserGenie

screenshot_viewport

Capture the current browser viewport to verify UI elements, debug layout issues, and inspect page state.

Instructions

Take a screenshot of what's currently visible in the browser window. Use this to see the current state of the page, verify UI elements, or debug layout issues. Returns an image you can view.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formatNoImage format: png (default, lossless) or jpeg (smaller file size)
qualityNoJPEG quality 0-100 (higher = better quality, larger file)
tabIdNoTarget tab ID (defaults to currently active tab)
apiKeyNoAPI key for authentication if enabled

Implementation Reference

  • The handler function that executes the screenshot_viewport tool logic. Sends a 'screenshot_viewport' command via the WebSocket bridge, receives the image data, and returns it as an image content response.
    async ({ format, quality, tabId, apiKey }) => {
      const result = await bridge.sendCommand({
        command: 'screenshot_viewport',
        params: { format, quality },
        tabId,
        apiKey,
        timeout: LONG_TIMEOUT,
      });
      if (!result.success) {
        return { content: [{ type: 'text', text: `Error: ${result.error?.message}` }], isError: true };
      }
      const data = result.data as { image: string; mimeType: string };
      return {
        content: [{
          type: 'image',
          data: data.image,
          mimeType: data.mimeType,
        }],
      };
    }
  • Zod schema defining the input parameters for screenshot_viewport: format (png/jpeg), quality (0-100), tabId, and apiKey.
    {
      format: z.enum(['png', 'jpeg']).optional().describe('Image format: png (default, lossless) or jpeg (smaller file size)'),
      quality: z.number().min(0).max(100).optional().describe('JPEG quality 0-100 (higher = better quality, larger file)'),
      tabId: z.number().optional().describe('Target tab ID (defaults to currently active tab)'),
      apiKey: z.string().optional().describe('API key for authentication if enabled'),
    },
  • The tool is registered with the MCP server via server.tool() with the name 'screenshot_viewport', a description, schema, and handler.
    server.tool(
      'screenshot_viewport',
      'Take a screenshot of what\'s currently visible in the browser window. Use this to see the current state of the page, verify UI elements, or debug layout issues. Returns an image you can view.',
      {
        format: z.enum(['png', 'jpeg']).optional().describe('Image format: png (default, lossless) or jpeg (smaller file size)'),
        quality: z.number().min(0).max(100).optional().describe('JPEG quality 0-100 (higher = better quality, larger file)'),
        tabId: z.number().optional().describe('Target tab ID (defaults to currently active tab)'),
        apiKey: z.string().optional().describe('API key for authentication if enabled'),
      },
      async ({ format, quality, tabId, apiKey }) => {
        const result = await bridge.sendCommand({
          command: 'screenshot_viewport',
          params: { format, quality },
          tabId,
          apiKey,
          timeout: LONG_TIMEOUT,
        });
        if (!result.success) {
          return { content: [{ type: 'text', text: `Error: ${result.error?.message}` }], isError: true };
        }
        const data = result.data as { image: string; mimeType: string };
        return {
          content: [{
            type: 'image',
            data: data.image,
            mimeType: data.mimeType,
          }],
        };
      }
    );
  • The registerScreenshotTools function is called from registerAllTools in the tools index, which bootstraps all tool registrations.
      registerScreenshotTools(server, bridge);
      registerClickTools(server, bridge);
      registerInputTools(server, bridge);
      registerDragDropTools(server, bridge);
      registerHoverTools(server, bridge);
    
      registerDevtoolsSourcesTools(server, bridge);
      registerDevtoolsModifyTools(server, bridge);
      registerDevtoolsNetworkTools(server, bridge);
      registerDevtoolsStorageTools(server, bridge);
      registerDevtoolsConsoleTools(server, bridge);
    
      registerAccessibilityTools(server, bridge);
      registerEmulationTools(server, bridge);
      registerElementTools(server, bridge);
      registerAuditTools(server, bridge);
      registerInteractionTools(server, bridge);
      registerMonitoringTools(server, bridge);
      registerQaTools(server, bridge);
      registerGestureTools(server, bridge);
      registerMacroTools(server, bridge);
      registerVisualRegressionTools(server, bridge);
    }
  • The sendCommand helper on WebSocketBridge that sends the 'screenshot_viewport' command over WebSocket to the Chrome extension and waits for a response.
    async sendCommand(cmd: BridgeCommand): Promise<BridgeResponse> {
      if (!this.isConnected()) {
        return {
          success: false,
          error: {
            code: 'NOT_CONNECTED',
            message: 'Chrome extension is not connected. Ensure the extension is installed, enabled, and the browser is running.',
          },
        };
      }
    
      const id = crypto.randomUUID();
      const timeout = cmd.timeout ?? DEFAULT_TIMEOUT;
    
      return new Promise<BridgeResponse>((resolve, reject) => {
        const timer = setTimeout(() => {
          this.pending.delete(id);
          resolve({
            success: false,
            error: {
              code: 'TIMEOUT',
              message: `Command '${cmd.command}' timed out after ${timeout}ms`,
            },
          });
        }, timeout);
    
        this.pending.set(id, { resolve, reject, timer });
    
        const message = {
          id,
          type: 'request',
          command: cmd.command,
          params: cmd.params,
          tabId: cmd.tabId,
          apiKey: cmd.apiKey,
          timestamp: Date.now(),
        };
    
        this.client!.send(JSON.stringify(message));
      });
    }
Behavior3/5

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

No annotations are provided, so the description must bear full transparency. It states it returns an image, but lacks details about side effects, resolution, or behavior when the window is obscured, which is adequate for a simple tool but not thorough.

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?

Three sentences, front-loaded with core purpose, no redundant phrasing, efficient and easy to parse.

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

Completeness4/5

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

For a simple screenshot tool with no output schema and full parameter docs, the description covers purpose, typical usage, and return type. It could mention limitations (e.g., only viewport) but is sufficient for selection.

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?

Input schema has 100% coverage with parameter descriptions, so the description does not need to add much. It adds no extra meaning beyond the schema, which is acceptable but does not improve clarity.

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

Purpose5/5

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

The description clearly states 'Take a screenshot of what's currently visible' using a specific verb and resource, and effectively distinguishes from sibling tools like screenshot_element and screenshot_full_page which target different areas.

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

Usage Guidelines4/5

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

The description suggests use cases ('verify UI elements, debug layout issues') but does not explicitly discuss when to avoid this tool or contrast with siblings like screenshot_element, leaving room for ambiguity.

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/BrowserGenie/mcp'

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