Skip to main content
Glama
snapshot.ts1.67 kB
/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import {Locator} from 'puppeteer-core'; import z from 'zod'; import {ToolCategories} from './categories.js'; import {defineTool, timeoutSchema} from './ToolDefinition.js'; 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); }, }); export const waitFor = defineTool({ name: 'wait_for', description: `Wait for the specified text to appear on the selected page.`, annotations: { category: ToolCategories.NAVIGATION_AUTOMATION, readOnlyHint: true, }, schema: { text: z.string().describe('Text to appear on the page'), ...timeoutSchema, }, handler: async (request, response, context) => { const page = context.getSelectedPage(); const frames = page.frames(); const locator = Locator.race( frames.flatMap(frame => [ frame.locator(`aria/${request.params.text}`), frame.locator(`text/${request.params.text}`), ]), ); if (request.params.timeout) { locator.setTimeout(request.params.timeout); } await locator.wait(); response.appendResponseLine( `Element with text "${request.params.text}" found.`, ); response.setIncludeSnapshot(true); }, });

Implementation Reference

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