click
Automate desktop app testing by clicking UI elements using CSS selectors or element references within Tauri applications.
Instructions
Click element by ref or selector
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ref | No | Ref from snapshot | |
| selector | No | CSS selector | |
| window | No | Window label (default: focused window) |
Implementation Reference
- The click tool handler that validates input (requires either ref or selector), calls socketManager.click(), and formats the response as MCP contentclick: async (args: { ref?: number; selector?: string; window?: string }) => { if (!args.ref && !args.selector) { throw new Error('Either ref or selector must be provided'); } const result = await socketManager.click(args); return { content: [ { type: 'text' as const, text: result, }, ], }; },
- Schema definition for the click tool with name, description, and inputSchema validating optional ref, selector, and window parameters using Zodclick: { name: 'click', description: 'Click element by ref or selector', inputSchema: z.object({ ref: z.number().optional().describe('Ref from snapshot'), selector: z.string().optional().describe('CSS selector'), window: z.string().optional().describe('Window label (default: focused window)'), }), },
- Implementation of the click functionality in SocketManager that sends the click command via socket and handles success/error responsesasync click(options: { ref?: number; selector?: string; window?: string }): Promise<string> { const result = await this.sendCommand('click', options) as { success: boolean; error?: string }; if (!result.success) { throw new Error(result.error || 'Click failed'); } const target = options.ref ? `ref=${options.ref}` : options.selector; const windowInfo = options.window ? ` in window '${options.window}'` : ''; return `Clicked ${target}${windowInfo}`; }
- packages/tauri-mcp/src/server.ts:14-23 (registration)Click tool registered in DEFAULT_ESSENTIAL_TOOLS array, making it available in the MCP server's tool listconst DEFAULT_ESSENTIAL_TOOLS = [ 'app_status', 'launch_app', 'stop_app', 'snapshot', 'click', 'fill', 'screenshot', 'navigate', ];