Skip to main content
Glama

snapshot

Capture accessibility trees from Tauri desktop applications to enable automated UI testing and interaction through element references.

Instructions

Get accessibility tree (returns ref numbers for click/fill)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
windowNoWindow label (default: focused window)

Implementation Reference

  • The main tool handler for 'snapshot' that processes requests, calls SocketManager.snapshot(), and returns formatted content as text
    snapshot: async (args: { window?: string }) => { const result = await socketManager.snapshot(args); return { content: [ { type: 'text' as const, text: result, }, ], }; },
  • Schema definition for the 'snapshot' tool using Zod, defining the tool name, description, and input validation with optional window parameter
    snapshot: { name: 'snapshot', description: 'Get accessibility tree (returns ref numbers for click/fill)', inputSchema: z.object({ window: z.string().optional().describe('Window label (default: focused window)'), }), },
  • SocketManager implementation of snapshot() that sends the command to the Tauri app and formats the response with window label, title, URL, and accessibility tree snapshot
    async snapshot(options?: { window?: string }): Promise<string> { const params: Record<string, unknown> = {}; if (options?.window) params.window = options.window; const result = await this.sendCommand('snapshot', params) as { window: string; snapshot: string; title: string; url: string }; // Format as readable output with window label return `# [${result.window}] ${result.title}\nURL: ${result.url}\n\n${result.snapshot}`; }
  • Registration of 'snapshot' in the DEFAULT_ESSENTIAL_TOOLS array, marking it as a core tool that should always be available
    const DEFAULT_ESSENTIAL_TOOLS = [ 'app_status', 'launch_app', 'stop_app', 'snapshot', 'click', 'fill', 'screenshot', 'navigate', ];
  • Dynamic tool registration where toolSchemas (including snapshot) are filtered by essentialTools and registered with the MCP server via ListToolsRequestSchema handler
    this.server.setRequestHandler(ListToolsRequestSchema, async () => { const allSchemas = Object.values(toolSchemas); // Filter tools if ESSENTIAL_TOOLS is set const filteredSchemas = essentialTools ? allSchemas.filter((schema) => essentialTools.has(schema.name)) : allSchemas; const tools: Tool[] = filteredSchemas.map((schema) => { const properties: Record<string, object> = {}; const required: string[] = []; const shape = schema.inputSchema.shape as Record<string, unknown>; for (const [key, zodValue] of Object.entries(shape)) { const zodSchema = zodValue as { _def?: { typeName?: string; description?: string }; description?: string; isOptional?: () => boolean }; properties[key] = { type: this.getZodType(zodSchema), description: zodSchema._def?.description || zodSchema.description || '', }; // Check if required (not optional) if (!zodSchema.isOptional?.()) { const typeName = zodSchema._def?.typeName; if (typeName !== 'ZodOptional') { required.push(key); } } } return { name: schema.name, description: schema.description, inputSchema: { type: 'object' as const, properties, required: required.length > 0 ? required : undefined, }, }; }); return { 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/DaveDev42/tauri-plugin-mcp'

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