type_text
Enter text into input fields and editable elements using CSS selectors to automate form filling and data entry in Tauri desktop applications.
Instructions
Type text into an input field or editable element
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| selector | Yes | CSS selector to identify the input element | |
| text | Yes | Text to type into the element | |
| clear | No | Whether to clear existing text before typing. Default: false |
Implementation Reference
- src/tools/interact.ts:35-54 (handler)Handler function for the 'type_text' MCP tool. It invokes the TauriDriver's typeText method and standardizes the response.export async function typeText( driver: TauriDriver, params: TypeTextParams ): Promise<ToolResponse<{ message: string }>> { try { await driver.typeText(params.selector, params.text, params.clear); return { success: true, data: { message: `Typed text into element: ${params.selector}`, }, }; } catch (error) { return { success: false, error: error instanceof Error ? error.message : String(error), }; } }
- src/index.ts:116-138 (registration)Registration of the 'type_text' tool in the MCP server's listTools response, defining name, description, and input schema.{ name: 'type_text', description: 'Type text into an input field or editable element', inputSchema: { type: 'object', properties: { selector: { type: 'string', description: 'CSS selector to identify the input element', }, text: { type: 'string', description: 'Text to type into the element', }, clear: { type: 'boolean', description: 'Whether to clear existing text before typing. Default: false', default: false, }, }, required: ['selector', 'text'], }, },
- src/types.ts:72-79 (schema)TypeScript interface defining the input parameters for the type_text tool.export interface TypeTextParams { /** CSS selector for the input element */ selector: string; /** Text to type */ text: string; /** Whether to clear existing text first */ clear?: boolean; }
- src/index.ts:274-284 (handler)Dispatch handler in the MCP CallToolRequestSchema that routes 'type_text' calls to the typeText function.case 'type_text': { const result = await typeText(driver, args as any); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
- src/tauri-driver.ts:134-147 (helper)Core implementation in TauriDriver class that executes the text typing using WebDriverIO element methods.async typeText(selector: string, text: string, clear: boolean = false): Promise<void> { this.ensureAppRunning(); const element = await this.appState.browser!.$(selector); if (!(await element.isExisting())) { throw new Error(`Element not found: ${selector}`); } if (clear) { await element.clearValue(); } await element.setValue(text); }