Skip to main content
Glama
andreahaku

Expo iOS Development MCP Server

by andreahaku

ui.wait_for

Wait for UI elements to appear or become visible in iOS Simulator during React Native/Expo testing, ensuring reliable automation by specifying selectors and timeout settings.

Instructions

Wait for an element to be visible or exist

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorYesElement selector to wait for.
visibleNoWait for visibility (true) or existence (false).
timeoutNoTimeout in milliseconds.

Implementation Reference

  • Primary handler for the 'ui.wait_for' MCP tool. Generates a Detox snippet using generateWaitForSnippet and executes it with runDetoxAction, returning the result in MCP format.
    server.tool(
      "ui.wait_for",
      "Wait for an element to be visible or exist",
      UiWaitForInputSchema.shape,
      async (args) => {
        try {
          const snippet = generateWaitForSnippet({
            selector: args.selector,
            visible: args.visible,
            timeout: args.timeout,
          });
          const result = await runDetoxAction({
            actionName: `waitFor:${describeSelector(args.selector)}`,
            actionSnippet: snippet,
            timeoutMs: (args.timeout ?? 30000) + 5000, // Add buffer
          });
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(result, null, 2),
              },
            ],
            isError: !result.success,
          };
        } catch (error) {
          return handleToolError(error);
        }
      }
    );
  • Input schema (Zod) for the ui.wait_for tool, defining selector, visible flag, and timeout.
    export const UiWaitForInputSchema = z.object({
      selector: SelectorSchema.describe("Element selector to wait for."),
      visible: z.boolean().optional().default(true).describe("Wait for visibility (true) or existence (false)."),
      timeout: z.number().optional().default(30000).describe("Timeout in milliseconds."),
    });
  • Internal helper implementation of ui.wait_for logic used by the flow.run tool executor.
    case "ui.wait_for":
      const waitSnippet = generateWaitForSnippet({
        selector: input.selector as { by: "id" | "text" | "label"; value: string },
        visible: input.visible as boolean | undefined,
        timeout: input.timeout as number | undefined,
      });
      const waitResult = await runDetoxAction({
        actionName: `waitFor:${(input.selector as { value: string }).value}`,
        actionSnippet: waitSnippet,
      });
      return { success: waitResult.success, result: waitResult, error: waitResult.error?.message };
  • Helper function that generates the actual Detox JavaScript code snippet for waiting on an element (visible or exists). This is the core UI waiting logic.
    export function generateWaitForSnippet(options: WaitForOptions): string {
      const matcher = selectorToDetoxExpr(options.selector);
      const timeout = options.timeout ?? 30000;
    
      if (options.visible !== false) {
        return `await waitFor(element(${matcher})).toBeVisible().withTimeout(${timeout});`;
      }
      return `await waitFor(element(${matcher})).toExist().withTimeout(${timeout});`;
    }
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. It mentions waiting for visibility or existence but lacks details on behavior: e.g., whether it polls continuously, returns on success/failure, throws errors on timeout, or interacts with the UI state. This is a significant gap for a tool with potential side effects.

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 with zero waste. It's front-loaded and directly conveys the core functionality without unnecessary elaboration, 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 no annotations and no output schema, the description is incomplete. It doesn't explain return values (e.g., success/failure indicators), error handling, or dependencies (e.g., requiring a UI session). For a tool that interacts with dynamic UI elements, this leaves critical gaps for an agent.

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%, so the schema fully documents the parameters (selector, visible, timeout). The description adds no additional meaning beyond what's in the schema, such as examples or edge cases. Baseline 3 is appropriate since the schema does the heavy lifting.

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 tool's purpose with a specific verb ('wait for') and resource ('an element'), specifying the condition ('to be visible or exist'). It doesn't distinguish from siblings like ui.assert_text or ui.tap, which have different purposes, but the core functionality is well-defined.

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?

No explicit guidance on when to use this tool versus alternatives is provided. The description implies usage for waiting on UI elements, but it doesn't mention prerequisites (e.g., needing an active session) or compare it to siblings like ui.assert_text (which might assert without waiting).

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/andreahaku/expo_ios_development_mcp'

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