Skip to main content
Glama

analyze_screenshot

Capture a screenshot of a web page and use AI to analyze and describe its visible content, with options for full-page capture, specific instructions, and detailed structural analysis.

Instructions

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

Input Schema

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

Implementation Reference

  • Zod schema defining the input parameters for analyze_screenshot (fullPage, path, pretext, model, detailed)
    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 ListToolsRequestSchema handler, defining the tool's name, description, and input JSON schema
    {
      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'
          }
        }
      }
    },
  • Main handler logic for the analyze_screenshot tool: takes a screenshot using Playwright, sends it to Ollama (Gemma3) for AI analysis, and returns the result
              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`
                      }
                    ]
                  };
                }
              }
Behavior2/5

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

No annotations are provided, so the description must carry the full burden. It mentions the AI model (Gemma3) and result 'describe what is visible', but it does not disclose the compound nature (screenshot + AI call), potential latency, or prerequisites (e.g., browser must be open). The description is incomplete for a multi-step operation.

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 a single sentence that front-loads the action and purpose. It contains no fluff and efficiently conveys the core functionality.

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

Completeness3/5

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

Given the tool's complexity (5 parameters, no output schema, composite operation), the description is minimal. It does not explain the return format or how the analysis relates to parameters like 'fullPage' or 'detailed'. Siblings like 'screenshot' exist, which helps context, but more detail on behavior would improve completeness.

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 baseline is 3. The description adds mention of 'Gemma3' which is already in the model parameter default. It does not provide meaningful additional context beyond the parameter descriptions (e.g., what 'pretext' or 'detailed' do in practice).

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?

Description clearly states the action: 'Take a screenshot and analyze it with AI (Gemma3) to describe what is visible on the page'. It specifies the verb (take/analyze), resource (screenshot/page), and the AI analysis. This distinguishes it from sibling 'screenshot' which likely only captures without analysis.

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 use when you need AI-driven description of page content, but it does not explicitly state when to prefer this over alternatives like 'get_page_info' or 'evaluate_javascript'. No exclusions or when-not-to-use guidance is provided.

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

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