Skip to main content
Glama
Radek44
by Radek44

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
NameRequiredDescriptionDefault
selectorYesCSS selector to identify the input element
textYesText to type into the element
clearNoWhether to clear existing text before typing. Default: false

Implementation Reference

  • 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'], }, },
  • 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; }
  • 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), }, ], }; }
  • 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); }

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/Radek44/mcp-tauri-automation'

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