Skip to main content
Glama

take_snapshot

Read-only

Capture a structured text snapshot of the current webpage, listing elements with unique identifiers for automation, debugging, and analysis tasks.

Instructions

Take a text snapshot of the currently selected page. The snapshot lists page elements along with a unique identifier (uid). Always use the latest snapshot. Prefer taking a snapshot over taking a screenshot.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Tool registration for 'take_snapshot'. Includes name, description, annotations (DEBUGGING category, read-only), empty input schema, and handler function that instructs the response to include a snapshot.
    export const takeSnapshot = defineTool({
      name: 'take_snapshot',
      description: `Take a text snapshot of the currently selected page. The snapshot lists page elements along with a unique
    identifier (uid). Always use the latest snapshot. Prefer taking a snapshot over taking a screenshot.`,
      annotations: {
        category: ToolCategories.DEBUGGING,
        readOnlyHint: true,
      },
      schema: {},
      handler: async (_request, response) => {
        response.setIncludeSnapshot(true);
      },
    });
  • Supporting utility in McpContext that creates the actual text snapshot using Puppeteer's accessibility.snapshot(), assigns unique IDs to nodes, and stores it in the context. Triggered when includeSnapshot is set.
    async createTextSnapshot(): Promise<void> {
      const page = this.getSelectedPage();
      const rootNode = await page.accessibility.snapshot({
        includeIframes: true,
      });
      if (!rootNode) {
        return;
      }
    
      const snapshotId = this.#nextSnapshotId++;
      // Iterate through the whole accessibility node tree and assign node ids that
      // will be used for the tree serialization and mapping ids back to nodes.
      let idCounter = 0;
      const idToNode = new Map<string, TextSnapshotNode>();
      const assignIds = (node: SerializedAXNode): TextSnapshotNode => {
        const nodeWithId: TextSnapshotNode = {
          ...node,
          id: `${snapshotId}_${idCounter++}`,
          children: node.children
            ? node.children.map(child => assignIds(child))
            : [],
        };
    
        // The AXNode for an option doesn't contain its `value`.
        // Therefore, set text content of the option as value.
        if (node.role === 'option') {
          const optionText = node.name;
          if (optionText) {
            nodeWithId.value = optionText.toString();
          }
        }
    
        idToNode.set(nodeWithId.id, nodeWithId);
        return nodeWithId;
      };
    
      const rootNodeWithId = assignIds(rootNode);
      this.#textSnapshot = {
        root: rootNodeWithId,
        snapshotId: String(snapshotId),
        idToNode,
      };
    }
  • The tool handler logic, which sets the response to include a snapshot, leading to snapshot capture.
    handler: async (_request, response) => {
      response.setIncludeSnapshot(true);
    },
Behavior4/5

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

The annotations declare readOnlyHint=true, indicating a safe read operation. The description adds valuable behavioral context beyond this by specifying that the snapshot lists page elements with unique identifiers (uid) and emphasizes using the latest snapshot. It doesn't contradict annotations, as 'take' in this context implies capturing data rather than modifying it.

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 efficiently structured in three sentences, each serving a distinct purpose: stating the action, detailing the output format, and providing usage guidance. There is no wasted text, and key information is front-loaded.

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?

Given the tool's simplicity (0 parameters, read-only operation) and lack of output schema, the description is mostly complete. It explains what the tool does, its output format, and usage preferences. However, it could slightly improve by mentioning any limitations or dependencies, such as requiring a selected page to be available.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0 parameters and 100% schema description coverage, the baseline is 4. The description adds no parameter-specific information, which is appropriate given the lack of parameters, so it maintains the baseline score without penalty.

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 text snapshot') and resource ('currently selected page'), distinguishing it from sibling tools like 'take_screenshot' by specifying it's a text-based capture. It explicitly differentiates from alternatives by mentioning 'Prefer taking a snapshot over taking a screenshot'.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool ('Always use the latest snapshot') and when to prefer it over alternatives ('Prefer taking a snapshot over taking a screenshot'). It clearly distinguishes usage from the 'take_screenshot' sibling tool by emphasizing text-based capture.

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/SHAY5555-gif/chrome-devtools-mcp'

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