Skip to main content
Glama
zillow
by zillow

clearText

Remove text from the currently focused input field on mobile devices to automate testing and streamline data entry tasks.

Instructions

Clear text from the currently focused input field

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
platformYesPlatform of the device

Implementation Reference

  • Registers the clearText tool in the ToolRegistry with name, description, schema, and handler function.
    ToolRegistry.registerDeviceAware(
      "clearText",
      "Clear text from the currently focused input field",
      clearTextSchema,
      clearTextHandler,
      true // Supports progress notifications
    );
  • The registered handler for the clearText tool, which instantiates ClearText class and executes it.
    const clearTextHandler = async (device: BootedDevice, args: ClearTextArgs, progress?: ProgressCallback) => {
      try {
        const clearText = new ClearText(device);
        const result = await clearText.execute(progress);
    
        return createJSONToolResponse({
          message: "Cleared text from input field",
          observation: result.observation,
          ...result
        });
      } catch (error) {
        throw new ActionableError(`Failed to clear text: ${error}`);
      }
    };
  • Zod schema defining the input arguments for the clearText tool.
    export const clearTextSchema = z.object({
      platform: z.enum(["android", "ios"]).describe("Platform of the device")
    });
  • Core execution logic of ClearText class, finds focused text field length and clears it by sending delete keyevents.
    async execute(progress?: ProgressCallback): Promise<ClearTextResult> {
      return this.observedInteraction(
        async (observeResult: ObserveResult) => {
          try {
            if (!observeResult.viewHierarchy) {
              // Fallback: if we can't get view hierarchy, use a reasonable default
              await this.clearWithDeletes(200);
              return { success: true };
            }
    
            let textLength = 0;
    
            // Look for focused elements first by traversing and checking attributes
            textLength = this.findFocusedElementTextLength(observeResult.viewHierarchy);
    
            // TODO: Move cursor to the end of the text
    
            if (textLength > 0) {
              await this.clearWithDeletes(textLength);
            }
    
            return {
              success: true
            };
          } catch (error) {
            return {
              success: false,
              error: "Failed to clear text"
            };
          }
        },
        {
          changeExpected: false, // TODO: can only make this true once we know for sure there was text in the text field
          tolerancePercent: 0.00,
          timeoutMs: 100,
          progress
        }
      );
    }
  • TypeScript interface defining the return type of the clearText operation.
    export interface ClearTextResult {
      success: boolean;
      observation?: ObserveResult;
      error?: string;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. While 'Clear text' implies a destructive write operation, the description doesn't specify what 'clear' entails (e.g., deletion, reset to empty), whether it requires specific permissions, or how it interacts with the UI (e.g., triggers events). This leaves significant gaps for a mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is front-loaded and wastes no space, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a mutation operation with no annotations and no output schema), the description is incomplete. It lacks details on behavioral traits (e.g., side effects, error conditions), usage context, and return values, which are critical for an AI agent to invoke it correctly in a UI automation scenario.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with the single parameter 'platform' fully documented in the schema as 'Platform of the device' with enum values. The description adds no parameter-specific information beyond what the schema provides, so the baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Clear text') and target ('currently focused input field'), providing a specific verb+resource combination. However, it doesn't distinguish this tool from sibling tools like 'selectAllText' or 'inputText', which might have overlapping or related functionality for text manipulation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing a focused input field), exclusions, or comparisons to sibling tools like 'selectAllText' or 'inputText' for text-related operations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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