Skip to main content
Glama

analyze_screenshot

Analyzes webpage screenshots using AI (Gemma3) to describe visible content, identify elements, and provide structural insights. Capture full-page or specific sections for detailed examination.

Instructions

Take a screenshot and analyze it with AI (Gemma3) to describe what is visible on the page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
detailedNoProvide detailed structural analysis of the page
fullPageNoCapture full scrollable page
modelNoAI model to use for analysis (default: gemma3:4b)gemma3:4b
pathNoPath to save screenshot (optional)
pretextNoOptional context or specific instructions for what to look for in the analysis

Implementation Reference

  • The main handler function for the 'analyze_screenshot' tool. It takes a screenshot of the current page using Playwright, converts it to base64, sends it to Ollama AI (default gemma3:4b) with a descriptive prompt, and returns the AI-generated analysis of the page contents.
              case 'analyze_screenshot': {
                if (!currentPage) {
                  throw new Error('No browser page available. Launch a browser first.');
                }
    
                const params = AnalyzeScreenshotSchema.parse(args);
                
                // Take screenshot
                const screenshotPath = params.path || `screenshot-${Date.now()}.png`;
                const screenshotBuffer = await currentPage.screenshot({ 
                  fullPage: params.fullPage,
                  path: screenshotPath
                });
    
                try {
                  // Initialize Ollama client
                  const ollama = new Ollama({ host: 'http://localhost:11434' });
    
                  // Convert screenshot to base64
                  const base64Image = screenshotBuffer.toString('base64');
    
                  // Prepare the prompt
                  let prompt = 'Analyze this website screenshot and describe exactly what you see. ';
                  
                  if (params.detailed) {
                    prompt += 'Provide a detailed structural analysis including layout, navigation elements, content sections, forms, buttons, and any interactive elements. ';
                  } else {
                    prompt += 'Focus on the main content and key elements visible on the page. ';
                  }
    
                  if (params.pretext) {
                    prompt += `Additional context/instructions: ${params.pretext}. `;
                  }
    
                  prompt += 'Be specific about colors, text content, images, and the overall design and functionality of the page.';
    
                  // Make AI request
                  const response = await ollama.generate({
                    model: params.model,
                    prompt: prompt,
                    images: [base64Image],
                    stream: false
                  });
    
                  return {
                    content: [
                      {
                        type: 'text',
                        text: `AI Analysis of Screenshot (${screenshotPath}):
    
    ${response.response}
    
    Screenshot saved to: ${screenshotPath}
    Model used: ${params.model}
    Analysis type: ${params.detailed ? 'Detailed structural analysis' : 'General description'}`
                      }
                    ]
                  };
    
                } catch (aiError) {
                  // If AI analysis fails, still return screenshot info
                  const fallbackMessage = aiError instanceof Error ? aiError.message : String(aiError);
                  
                  return {
                    content: [
                      {
                        type: 'text',
                        text: `Screenshot taken and saved to: ${screenshotPath}
    
    AI Analysis Error: ${fallbackMessage}
    
    Note: Make sure Ollama is running locally with the ${params.model} model installed.
    You can install it with: ollama pull ${params.model}
    And start Ollama with: ollama serve`
                      }
                    ]
                  };
                }
              }
  • Zod schema defining the input parameters for the analyze_screenshot tool, including options for full page screenshot, save path, analysis pretext, AI model, and detail level.
    const AnalyzeScreenshotSchema = z.object({
      fullPage: z.boolean().default(false),
      path: z.string().optional(),
      pretext: z.string().optional(),
      model: z.string().default('gemma3:4b'),
      detailed: z.boolean().default(false)
    });
  • src/index.ts:330-361 (registration)
    Tool registration in the listTools handler, defining the name, description, and inputSchema for analyze_screenshot.
    {
      name: 'analyze_screenshot',
      description: 'Take a screenshot and analyze it with AI (Gemma3) to describe what is visible on the page',
      inputSchema: {
        type: 'object',
        properties: {
          fullPage: {
            type: 'boolean',
            default: false,
            description: 'Capture full scrollable page'
          },
          path: {
            type: 'string',
            description: 'Path to save screenshot (optional)'
          },
          pretext: {
            type: 'string',
            description: 'Optional context or specific instructions for what to look for in the analysis'
          },
          model: {
            type: 'string',
            default: 'gemma3:4b',
            description: 'AI model to use for analysis (default: gemma3:4b)'
          },
          detailed: {
            type: 'boolean',
            default: false,
            description: 'Provide detailed structural analysis of the page'
          }
        }
      }
    },
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 taking a screenshot and analyzing with AI, but lacks details on permissions needed, rate limits, whether the analysis is destructive or read-only, error handling, or what the output format looks like. This is a significant gap for a tool with AI interaction and file operations.

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 a single, efficient sentence that front-loads the core action and purpose without unnecessary words. However, it could be slightly more structured by separating the screenshot capture and analysis steps for clarity, but it remains highly concise and to the point.

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 of AI analysis and screenshot capture, with no annotations and no output schema, the description is incomplete. It does not address behavioral aspects like error conditions, output format, or integration details, leaving gaps that could hinder effective tool selection and invocation by an AI agent.

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 schema description coverage is 100%, so the schema already documents all 5 parameters thoroughly. The description does not add any additional meaning or context beyond what the schema provides, such as explaining interactions between parameters or practical usage examples. Baseline 3 is appropriate when the schema handles parameter documentation.

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 the specific action ('Take a screenshot and analyze it with AI') and the resource ('what is visible on the page'), with the AI model specified as Gemma3. It distinguishes itself from the 'screenshot' sibling tool by adding the AI analysis component, making the purpose unambiguous and differentiated.

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

Usage Guidelines3/5

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

The description implies usage for analyzing page content via AI after capturing a screenshot, but it does not explicitly state when to use this tool versus alternatives like 'get_page_info' or 'screenshot'. No guidance is provided on prerequisites, exclusions, or specific scenarios where this tool is preferred over others.

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

Related 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/Wladastic/mcp-browser-server'

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