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}`);
      }
    }

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