Skip to main content
Glama

analyze_webpage_screenshot

Extract content, layout, and interactive elements from webpage screenshots to analyze structure and accessibility.

Instructions

Specialized tool for analyzing webpage screenshots. Extracts content, layout information, and interactive elements from web pages.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
typeYesThe type of image input
dataYesThe webpage screenshot data (base64 string, file path, or URL)
mimeTypeNoMIME type of the image (required for base64 input)
focusAreaNoSpecific area to focus on (optional)
includeAccessibilityNoInclude accessibility analysis (default: true)
formatNoOutput format (default: json for structured webpage analysis)
maxTokensNoMaximum tokens in response (default: 4000)

Implementation Reference

  • The handler function that processes the input arguments, handles image processing, constructs specialized prompts for webpage screenshot analysis (including focus areas like layout, content, accessibility), calls the OpenRouter vision model API, and returns the analysis result.
    export async function handleAnalyzeWebpage(
      args: any,
      config: Config,
      openRouterClient: OpenRouterClient,
      logger: Logger
    ) {
      const imageProcessor = ImageProcessor.getInstance();
    
      try {
        const imageInput = {
          type: args.type as 'base64' | 'file' | 'url',
          data: args.data as string,
          mimeType: args.mimeType as string,
        };
    
        const focusArea = args.focusArea as string;
        const includeAccessibility = args.includeAccessibility !== false;
        const format = args.format as 'text' | 'json' || 'json';
        const maxTokens = args.maxTokens as number || 4000;
    
        logger.info(`Starting webpage screenshot analysis for type: ${imageInput.type}, focus: ${focusArea}`);
    
        // Process the image
        const processedImage = await imageProcessor.processImage(imageInput);
    
        // Validate image type
        if (!imageProcessor.isValidImageType(processedImage.mimeType)) {
          throw new Error(`Unsupported image type: ${processedImage.mimeType}`);
        }
    
        // Check file size
        const serverConfig = config.getServerConfig();
        const maxImageSize = serverConfig.maxImageSize || 10485760;
        if (processedImage.size > maxImageSize) {
          throw new Error(`Image size ${processedImage.size} exceeds maximum allowed size ${maxImageSize}`);
        }
    
        // Build specialized prompt for webpage analysis
        let prompt = 'Analyze this webpage screenshot and provide detailed information about its structure, content, and design.';
    
        if (focusArea) {
          switch (focusArea) {
            case 'layout':
              prompt += ' Focus specifically on the layout structure, grid system, spacing, and visual hierarchy.';
              break;
            case 'content':
              prompt += ' Focus specifically on the content, headings, body text, and information architecture.';
              break;
            case 'navigation':
              prompt += ' Focus specifically on navigation elements, menus, breadcrumbs, and user pathways.';
              break;
            case 'forms':
              prompt += ' Focus specifically on form elements, input fields, buttons, and validation indicators.';
              break;
            case 'interactive':
              prompt += ' Focus specifically on interactive elements like buttons, links, hover states, and calls-to-action.';
              break;
            case 'accessibility':
              prompt += ' Focus specifically on accessibility features, contrast ratios, alt text indicators, and keyboard navigation.';
              break;
          }
        }
    
        prompt += ' Include specific details about:';
    
        if (includeAccessibility || focusArea === 'accessibility') {
          prompt += ' accessibility considerations, color contrast, font sizes, and assistive technology compatibility;';
        }
    
        prompt += ' responsive design indicators, viewport information, and mobile optimization; visual design elements like colors, typography, and branding; user experience considerations and potential usability issues; any errors, warnings, or unusual states visible.';
    
        if (format === 'json') {
          prompt += ' Provide your analysis in a structured JSON format with the following schema: {"page_title": "string", "url": "string (if visible)", "layout": {"header": "description", "navigation": "description", "main_content": "description", "sidebar": "description", "footer": "description"}, "content": {"headings": ["list"], "body_text": "summary", "key_elements": ["list"]}, "interactive_elements": {"buttons": ["list"], "links": ["list"], "forms": ["list"]}, "design": {"color_scheme": "description", "typography": "description", "branding": "description"}, "accessibility": {"score": "1-10", "issues": ["list"], "positive_aspects": ["list"]}, "usability": {"strengths": ["list"], "issues": ["list"], "recommendations": ["list"]}, "technical_notes": "technical observations"}';
        }
    
        // Analyze the webpage screenshot
        const result = await openRouterClient.analyzeImage(
          processedImage.data,
          processedImage.mimeType,
          prompt,
          { format, maxTokens }
        );
    
        if (!result.success) {
          throw new Error(result.error || 'Failed to analyze webpage screenshot');
        }
    
        logger.info(`Webpage screenshot analysis completed successfully`, {
          model: result.model,
          usage: result.usage,
        });
    
        return {
          content: [
            {
              type: 'text',
              text: result.analysis || 'No analysis available',
            },
          ],
        };
      } catch (error) {
        logger.error('Webpage screenshot analysis failed', error);
        return {
          content: [
            {
              type: 'text',
              text: `Error: ${(error as Error).message}`,
            },
          ],
          isError: true,
        };
      }
    }
  • Input schema definition for the analyze_webpage_screenshot tool, specifying parameters like image type, data, focus areas, format, etc.
    inputSchema: {
      type: 'object',
      properties: {
        type: {
          type: 'string',
          enum: ['base64', 'file', 'url'],
          description: 'The type of image input',
        },
        data: {
          type: 'string',
          description: 'The webpage screenshot data (base64 string, file path, or URL)',
        },
        mimeType: {
          type: 'string',
          description: 'MIME type of the image (required for base64 input)',
        },
        focusArea: {
          type: 'string',
          enum: ['layout', 'content', 'navigation', 'forms', 'interactive', 'accessibility'],
          description: 'Specific area to focus on (optional)',
        },
        includeAccessibility: {
          type: 'boolean',
          description: 'Include accessibility analysis (default: true)',
        },
        format: {
          type: 'string',
          enum: ['text', 'json'],
          description: 'Output format (default: json for structured webpage analysis)',
        },
        maxTokens: {
          type: 'number',
          description: 'Maximum tokens in response (default: 4000)',
        },
      },
      required: ['type', 'data'],
    },
  • src/index.ts:90-130 (registration)
    Tool registration in the listTools handler, defining name, description, and input schema.
    {
      name: 'analyze_webpage_screenshot',
      description: 'Specialized tool for analyzing webpage screenshots. Extracts content, layout information, and interactive elements from web pages.',
      inputSchema: {
        type: 'object',
        properties: {
          type: {
            type: 'string',
            enum: ['base64', 'file', 'url'],
            description: 'The type of image input',
          },
          data: {
            type: 'string',
            description: 'The webpage screenshot data (base64 string, file path, or URL)',
          },
          mimeType: {
            type: 'string',
            description: 'MIME type of the image (required for base64 input)',
          },
          focusArea: {
            type: 'string',
            enum: ['layout', 'content', 'navigation', 'forms', 'interactive', 'accessibility'],
            description: 'Specific area to focus on (optional)',
          },
          includeAccessibility: {
            type: 'boolean',
            description: 'Include accessibility analysis (default: true)',
          },
          format: {
            type: 'string',
            enum: ['text', 'json'],
            description: 'Output format (default: json for structured webpage analysis)',
          },
          maxTokens: {
            type: 'number',
            description: 'Maximum tokens in response (default: 4000)',
          },
        },
        required: ['type', 'data'],
      },
    },
  • src/index.ts:194-195 (registration)
    Dispatch/registration of the handler in the centralized CallToolRequestSchema switch statement.
    case 'analyze_webpage_screenshot':
      return await handleAnalyzeWebpage(args, config, openRouterClient, logger);
  • src/index.ts:13-13 (registration)
    Import of the handler function.
    import { handleAnalyzeWebpage } from './tools/analyze-webpage.js';
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions what the tool extracts but doesn't cover critical aspects like whether it's a read-only operation, potential rate limits, authentication requirements, error handling, or what the output looks like (beyond mentioning extraction). For a tool with 7 parameters and no annotations, this is a significant gap.

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

Conciseness4/5

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

The description is concise (two sentences) and front-loaded with the core purpose. Every sentence contributes meaning without redundancy. However, it could be slightly more structured by explicitly separating functionality from context.

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 tool's complexity (7 parameters, no output schema, and no annotations), the description is incomplete. It lacks information on behavioral traits, output format details, error conditions, and differentiation from siblings. For a tool that analyzes webpage screenshots with multiple configuration options, this description doesn't provide enough context for an agent to use it effectively beyond basic invocation.

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%, meaning all parameters are documented in the schema itself. The description doesn't add any parameter-specific details beyond what's in the schema (e.g., it doesn't explain how 'focusArea' or 'format' affect the analysis). With high schema coverage, the baseline score of 3 is appropriate as the description doesn't compensate but also doesn't detract.

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 tool's purpose as 'analyzing webpage screenshots' and specifies what it extracts ('content, layout information, and interactive elements from web pages'), which is a specific verb+resource combination. However, it doesn't explicitly differentiate from sibling tools like 'analyze_image' or 'analyze_mobile_app_screenshot', which likely 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 its siblings ('analyze_image' and 'analyze_mobile_app_screenshot'), nor does it mention any prerequisites, exclusions, or alternative scenarios. It only states what the tool does 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/JonathanJude/openrouter-image-mcp'

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