fill
Fill input fields in Tauri apps using CSS selector or snapshot ref. Optionally target a specific window.
Instructions
Fill input by ref or selector
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ref | No | Ref from snapshot | |
| selector | No | CSS selector | |
| value | Yes | Value | |
| window | No | Window label (default: focused window) |
Implementation Reference
- The fill tool handler function that validates input (ref or selector required), calls socketManager.fill(), and returns the result as text content.
fill: async (args: { ref?: number; selector?: string; value: string; window?: string }) => { if (args.ref == null && !args.selector) { throw new Error('Either ref or selector must be provided'); } const result = await socketManager.fill(args); return { content: [ { type: 'text' as const, text: result, }, ], }; }, - The fill tool schema definition with name 'fill', description 'Fill input by ref or selector', and inputSchema with optional ref (number), optional selector (string), required value (string), and optional window (string).
fill: { name: 'fill', description: 'Fill input by ref or selector', inputSchema: z.object({ ref: z.number().optional().describe('Ref from snapshot'), selector: z.string().optional().describe('CSS selector'), value: z.string().describe('Value'), window: z.string().optional().describe('Window label (default: focused window)'), }), }, - packages/tauri-mcp/src/server.ts:14-23 (registration)The fill tool is registered in the DEFAULT_ESSENTIAL_TOOLS array in the MCP server, making it available as a default tool.
const DEFAULT_ESSENTIAL_TOOLS = [ 'get_session_status', 'start_session', 'stop_session', 'snapshot', 'click', 'fill', 'screenshot', 'navigate', ]; - The SocketManager.fill() helper that sends a 'fill' JSON-RPC command over the Unix socket to the Tauri app, handling the response and formatting the success message.
async fill(options: { ref?: number; selector?: string; value: string; window?: string }): Promise<string> { const result = await this.sendCommand('fill', options) as { success: boolean; error?: string }; if (!result.success) { throw new Error(result.error || 'Fill failed'); } const target = options.ref ? `ref=${options.ref}` : options.selector; const windowInfo = options.window ? ` in window '${options.window}'` : ''; return `Filled ${target} with "${options.value}"${windowInfo}`; }