Skip to main content
Glama

snapshot

Capture a snapshot of the current webpage including all interactive elements for documentation, testing, or analysis purposes.

Instructions

Get a snapshot of the current page with interactive elements

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler method that captures the page snapshot including URL, title, and interactive elements by evaluating JavaScript on the page.
    async snapshot() {
      await this.ensureLaunched();
      
      // Get basic page information
      const url = await this.getUrl();
      const title = await this.getTitle();
      
      // Extract all interactive elements from the page
      const elements = await this.page.evaluate(() => {
        const interactive = document.querySelectorAll('a, button, input, select, textarea, [onclick], [role="button"]');
        return Array.from(interactive).map((el, index) => ({
          index,
          tag: el.tagName.toLowerCase(),
          text: el.textContent?.trim() || el.value || el.placeholder || '',
          type: el.type || '',
          role: el.getAttribute('role') || '',
          id: el.id || '',
          className: el.className || ''
        }));
      });
    
      // Return page snapshot with filtered interactive elements
      return {
        url,
        title,
        elements: elements.filter(el => el.text || el.id || el.className)
      };
    }
  • Registers the 'snapshot' MCP tool with input schema and a handler that calls the browser.snapshot() method and formats the response.
    {
      name: 'snapshot',
      description: 'Get a snapshot of the current page with interactive elements',
      inputSchema: {
        type: 'object',
        properties: {},
        required: []
      },
      handler: async () => {
        const snapshot = await browser.snapshot();
        return { 
          success: true, 
          data: snapshot,
          message: `Page snapshot captured for ${snapshot.url}`
        };
      }
    },
  • Input schema for the 'snapshot' tool, which requires no parameters.
    inputSchema: {
      type: 'object',
      properties: {},
      required: []
    },

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/zypin-testing/zypin-mcp'

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