Skip to main content
Glama

selectAllText

Select all text in focused input fields on mobile devices using long press and tap actions for Android and iOS platforms.

Instructions

Select all text in the currently focused input field using long press + tap on 'Select All'

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
platformYesPlatform of the device

Implementation Reference

  • Registration of the 'selectAllText' tool using ToolRegistry.registerDeviceAware, specifying name, description, schema, and handler.
    "selectAllText", "Select all text in the currently focused input field using long press + tap on 'Select All'", selectAllTextSchema, selectAllTextHandler, true // Supports progress notifications );
  • The main handler function for the 'selectAllText' MCP tool. It creates an instance of SelectAllText and executes it, then formats the response.
    const selectAllTextHandler = async (device: BootedDevice, args: SelectAllTextArgs, progress?: ProgressCallback) => { try { const selectAllText = new SelectAllText(device); const result = await selectAllText.execute(progress); return createJSONToolResponse({ message: "Selected all text in focused input field", observation: result.observation, ...result }); } catch (error) { throw new ActionableError(`Failed to select all text: ${error}`); } };
  • Zod schema defining the input arguments for the selectAllText tool (platform only).
    export const selectAllTextSchema = z.object({ platform: z.enum(["android", "ios"]).describe("Platform of the device") });
  • The core execute method of the SelectAllText class, which performs the actual logic: observes screen, finds focused text input, double-taps its center to select all.
    async execute(progress?: ProgressCallback): Promise<SelectAllTextResult> { return this.observedInteraction( async (observeResult: ObserveResult) => { try { // Find the focused text input field const targetElement = this.elementUtils.findFocusedTextInput(observeResult.viewHierarchy); // If no focused element, find any text input field if (!targetElement) { throw new ActionableError("No focused text input field found. Please focus on a text field first."); } // Get center coordinates of the text field const tapPoint = this.elementUtils.getElementCenter(targetElement); await this.adb.executeCommand(`shell input tap ${tapPoint.x} ${tapPoint.y}`); await new Promise(resolve => setTimeout(resolve, 100)); await this.adb.executeCommand(`shell input tap ${tapPoint.x} ${tapPoint.y}`); return { success: true }; } catch (error) { return { success: false, error: `Failed to select all text: ${error instanceof Error ? error.message : String(error)}` }; } }, { changeExpected: false, tolerancePercent: 0, timeoutMs: 500, progress } ); }
  • TypeScript interface defining the output structure of the selectAllText operation.
    export interface SelectAllTextResult { success: boolean; observation?: ObserveResult; error?: string; }

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/zillow/auto-mobile'

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