Skip to main content
Glama
andreahaku

Expo iOS Development MCP Server

by andreahaku

ui.press_key

Press special keys like return, backspace, or delete during iOS Simulator UI automation for React Native/Expo development testing.

Instructions

Press a special key (return, backspace, delete)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYesKey to press.

Implementation Reference

  • Registers the ui.press_key MCP tool, providing description, input schema, and the handler function that generates a Detox snippet and executes it via runDetoxAction.
    server.tool(
      "ui.press_key",
      "Press a special key (return, backspace, delete)",
      UiPressKeyInputSchema.shape,
      async (args) => {
        try {
          const snippet = generatePressKeySnippet(args.key);
          const result = await runDetoxAction({
            actionName: `pressKey:${args.key}`,
            actionSnippet: snippet,
          });
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(result, null, 2),
              },
            ],
            isError: !result.success,
          };
        } catch (error) {
          return handleToolError(error);
        }
      }
    );
  • The core handler function for ui.press_key: generates Detox code snippet using the provided key and runs it, returning the result or error.
    async (args) => {
      try {
        const snippet = generatePressKeySnippet(args.key);
        const result = await runDetoxAction({
          actionName: `pressKey:${args.key}`,
          actionSnippet: snippet,
        });
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(result, null, 2),
            },
          ],
          isError: !result.success,
        };
      } catch (error) {
        return handleToolError(error);
      }
    }
  • Zod schema defining the input for ui.press_key: requires a 'key' enum of supported special keys.
    export const UiPressKeyInputSchema = z.object({
      key: z.enum(["return", "backspace", "delete"]).describe("Key to press."),
    });
  • Helper function that generates the specific Detox test code snippet for pressing the given key (targets first UITextField).
    export function generatePressKeySnippet(key: KeyType): string {
      switch (key) {
        case "return":
          return `await element(by.type('UITextField')).atIndex(0).tapReturnKey();`;
        case "backspace":
          return `await element(by.type('UITextField')).atIndex(0).tapBackspaceKey();`;
        case "delete":
          // Delete key is same as backspace on iOS
          return `await element(by.type('UITextField')).atIndex(0).tapBackspaceKey();`;
        default:
          throw new Error(`Unsupported key: ${key}`);
      }
    }
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. It states the action ('press') but doesn't describe what 'press' entails (e.g., duration, effect on UI, whether it's a single key event), potential side effects, or error conditions. This leaves significant gaps for a tool that interacts with UI elements.

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 extremely concise—a single, efficient sentence that directly states the tool's purpose with zero wasted words. It's front-loaded with the core action and immediately specifies the allowed keys.

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 for a UI interaction tool. It lacks details on behavioral traits (e.g., what 'press' means operationally), expected outcomes, error handling, and how it fits within the broader UI testing context alongside siblings like ui.tap or ui.type.

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?

The input schema has 100% description coverage, with the 'key' parameter fully documented via enum and description. The description adds no additional parameter semantics beyond what the schema provides (it merely repeats the allowed keys). Baseline 3 is appropriate when the schema does all the work.

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 ('press') and resource ('special key'), specifying the allowed keys (return, backspace, delete). It distinguishes from sibling tools like ui.tap or ui.type by focusing on special keys rather than taps or text input. However, it doesn't explicitly differentiate from all siblings (e.g., ui.long_press also involves key/button actions).

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 when pressing a special key is appropriate compared to other UI interaction tools like ui.tap, ui.type, or ui.long_press, nor does it specify any prerequisites or exclusions for usage.

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