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
| Name | Required | Description | Default |
|---|---|---|---|
| window | No | Window label (default: focused window) |
Implementation Reference
- The main tool handler for 'snapshot' that processes requests, calls SocketManager.snapshot(), and returns formatted content as textsnapshot: 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 parametersnapshot: { 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 snapshotasync 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}`; }
- packages/tauri-mcp/src/server.ts:14-23 (registration)Registration of 'snapshot' in the DEFAULT_ESSENTIAL_TOOLS array, marking it as a core tool that should always be availableconst DEFAULT_ESSENTIAL_TOOLS = [ 'app_status', 'launch_app', 'stop_app', 'snapshot', 'click', 'fill', 'screenshot', 'navigate', ];
- packages/tauri-mcp/src/server.ts:68-109 (registration)Dynamic tool registration where toolSchemas (including snapshot) are filtered by essentialTools and registered with the MCP server via ListToolsRequestSchema handlerthis.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 }; });