Skip to main content
Glama

mobile_type_keys

Type text into focused elements on mobile devices for automation testing. Specify device identifier, text content, and submission option to simulate user input in iOS and Android applications.

Instructions

Type text into the focused element

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
deviceYesThe device identifier to use. Use mobile_list_available_devices to find which devices are available to you.
textYesThe text to type
submitYesWhether to submit the text. If true, the text will be submitted as if the user pressed the enter key.

Implementation Reference

  • src/server.ts:365-382 (registration)
    Registration of the 'mobile_type_keys' tool, including inline schema definition and handler function that uses the selected robot to send keys and optionally press ENTER.
    tool( "mobile_type_keys", "Type text into the focused element", { text: z.string().describe("The text to type"), submit: z.boolean().describe("Whether to submit the text. If true, the text will be submitted as if the user pressed the enter key."), }, async ({ text, submit }) => { requireRobot(); await robot!.sendKeys(text); if (submit) { await robot!.pressButton("ENTER"); } return `Typed text: ${text}`; } );
  • Handler implementation for 'mobile_type_keys': requires a selected robot, sends the provided text via robot.sendKeys(), and if submit is true, presses the ENTER button.
    async ({ text, submit }) => { requireRobot(); await robot!.sendKeys(text); if (submit) { await robot!.pressButton("ENTER"); } return `Typed text: ${text}`; }
  • Zod schema for 'mobile_type_keys' tool parameters: text (required string), submit (boolean).
    text: z.string().describe("The text to type"), submit: z.boolean().describe("Whether to submit the text. If true, the text will be submitted as if the user pressed the enter key."),
  • Helper function 'tool()' used to register all tools, including error handling wrapper around the provided callback.
    const tool = (name: string, description: string, paramsSchema: ZodRawShape, cb: (args: z.objectOutputType<ZodRawShape, ZodTypeAny>) => Promise<string>) => { const wrappedCb = async (args: ZodRawShape): Promise<CallToolResult> => { try { trace(`Invoking ${name} with args: ${JSON.stringify(args)}`); const response = await cb(args); trace(`=> ${response}`); return { content: [{ type: "text", text: response }], }; } catch (error: any) { if (error instanceof ActionableError) { return { content: [{ type: "text", text: `${error.message}. Please fix the issue and try again.` }], }; } else { // a real exception trace(`Tool '${description}' failed: ${error.message} stack: ${error.stack}`); return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true, }; } } }; server.tool(name, description, paramsSchema, args => wrappedCb(args));

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/EmpathySlainLovers/MCP'

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