Skip to main content
Glama
maderwin

pinchtab-mcp

Snapshot

pinchtab_snapshot

Capture an accessibility tree snapshot of the page, returning element refs for automation. Filter by interactive elements or use compact format to reduce token usage.

Instructions

Get an accessibility tree snapshot of the page. Returns element refs (e0, e1, …) that can be used with click/type/press. Use filter='interactive' for fewer tokens. Use format='compact' for minimal output.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
diffNoIf true, return only changes since last snapshot. Great for multi-step workflows.
filterNoFilter elements: 'interactive' for buttons/links/inputs only. Default: 'all'
formatNo'compact' returns minimal refs (~3.6K tokens). Default: 'full'

Implementation Reference

  • The actual handler function for pinchtab_snapshot. It builds query params (filter, format, diff) and calls pinch('GET', '/snapshot?...') to get the accessibility tree snapshot from the PinchTab server.
    async ({ filter, format, diff }) => {
      try {
        const params = new URLSearchParams();
        if (filter) params.set("filter", filter);
        if (format === "compact") params.set("format", "compact");
        if (diff) params.set("diff", "true");
        const qs = params.toString() ? `?${params.toString()}` : "";
        return toolResult(await pinch("GET", `/snapshot${qs}`));
      } catch (error) {
        return toolError(error);
      }
    },
  • Registration of the 'pinchtab_snapshot' tool using server.registerTool(). Defines name, description, input schema (diff, filter, format), and the handler.
    server.registerTool(
      "pinchtab_snapshot",
      {
        description:
          "Get an accessibility tree snapshot of the page. Returns element refs (e0, e1, …) that can be used with click/type/press. Use filter='interactive' for fewer tokens. Use format='compact' for minimal output.",
        inputSchema: z.object({
          diff: z
            .boolean()
            .optional()
            .describe(
              "If true, return only changes since last snapshot. Great for multi-step workflows.",
            ),
          filter: z
            .enum(["all", "interactive"])
            .optional()
            .describe("Filter elements: 'interactive' for buttons/links/inputs only. Default: 'all'"),
          format: z
            .enum(["full", "compact"])
            .optional()
            .describe("'compact' returns minimal refs (~3.6K tokens). Default: 'full'"),
        }),
        title: "Snapshot",
      },
      async ({ filter, format, diff }) => {
        try {
          const params = new URLSearchParams();
          if (filter) params.set("filter", filter);
          if (format === "compact") params.set("format", "compact");
          if (diff) params.set("diff", "true");
          const qs = params.toString() ? `?${params.toString()}` : "";
          return toolResult(await pinch("GET", `/snapshot${qs}`));
        } catch (error) {
          return toolError(error);
        }
      },
    );
  • Input schema for pinchtab_snapshot using Zod. Validates 'diff' (boolean, optional), 'filter' (enum: 'all'|'interactive'), and 'format' (enum: 'full'|'compact').
    inputSchema: z.object({
      diff: z
        .boolean()
        .optional()
        .describe(
          "If true, return only changes since last snapshot. Great for multi-step workflows.",
        ),
      filter: z
        .enum(["all", "interactive"])
        .optional()
        .describe("Filter elements: 'interactive' for buttons/links/inputs only. Default: 'all'"),
      format: z
        .enum(["full", "compact"])
        .optional()
        .describe("'compact' returns minimal refs (~3.6K tokens). Default: 'full'"),
    }),
  • Helper function waitAndSnapshot used by other tools (navigate, wait) to wait then fetch a compact snapshot. The snapshot tool itself calls pinch directly.
    export async function waitAndSnapshot(ms: number): Promise<string> {
      const clamped = Math.min(ms, MAX_WAIT_MS);
      await new Promise((resolve) => setTimeout(resolve, clamped));
      const snapshot = await pinch("GET", "/snapshot?format=compact");
      return typeof snapshot === "string" ? snapshot : JSON.stringify(snapshot, undefined, 2);
    }
  • The pinch() HTTP client that makes requests to the PinchTab server. The snapshot handler calls pinch('GET', '/snapshot?...') to retrieve the snapshot.
    export async function pinch(
      method: string,
      path: string,
      body?: Record<string, unknown>,
    ): Promise<unknown> {
      if (!(await isPinchtabRunning())) {
        await ensurePinchtabRunning();
      }
    
      const headers: Record<string, string> = {
        "Content-Type": "application/json",
      };
      if (PINCHTAB_TOKEN) {
        headers["Authorization"] = `Bearer ${PINCHTAB_TOKEN}`;
      }
    
      const url = `${PINCHTAB_URL}${path}`;
    
      let res: Response;
      try {
        res = await fetch(url, {
          body: body ? JSON.stringify(body) : undefined,
          headers,
          method,
          signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
        });
      } catch (error) {
        if (error instanceof DOMException && error.name === "TimeoutError") {
          throw new Error(`PinchTab ${method} ${path} timed out after ${REQUEST_TIMEOUT_MS / 1000}s`);
        }
        throw error;
      }
    
      if (!res.ok) {
        const text = await res.text();
        throw new Error(`PinchTab ${method} ${path} → ${res.status}: ${text}`);
      }
    
      const contentType = (res.headers.get("content-type") ?? "").split(";")[0].toLowerCase().trim();
      if (contentType === "application/json") {
        return res.json();
      }
      return res.text();
    }
Behavior3/5

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

No annotations provided. Description implicitly indicates read-only snapshot behavior but does not disclose potential side effects or precise behavior beyond returning refs. Adequate but not exhaustive.

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?

Three sentences, no redundancy. First sentence gives core purpose, subsequent sentences provide actionable usage guidance. Extremely efficient.

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 no output schema, description adequately explains return value (element refs). All parameters are covered. Missing error handling details, but acceptable for a snapshot tool.

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?

Schema covers all parameters with descriptions. Description adds value by explaining 'diff' for multi-step workflows and emphasizing token savings for filter and format. Enhances understanding beyond schema.

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 tool gets an accessibility tree snapshot and returns element refs for use with click/type/press. It distinguishes from sibling tools like pinchtab_click that use these refs.

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

Usage Guidelines4/5

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

Provides specific usage tips: filter='interactive' for fewer tokens, format='compact' for minimal output, and diff for multi-step workflows. Lacks explicit when-not-to-use or alternatives, but context is clear.

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/maderwin/pinchtab-mcp'

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