Skip to main content
Glama
mobile-next

Mobile Next MCP Server

Official
by mobile-next

mobile_press_button

Simulate button presses on mobile devices using the Mobile Next MCP Server. Execute commands like HOME, VOLUME_UP, or DPAD_LEFT to automate interactions on iOS and Android platforms.

Instructions

Press a button on device

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
buttonYesThe button to press. Supported buttons: BACK (android only), HOME, VOLUME_UP, VOLUME_DOWN, ENTER, DPAD_CENTER (android tv only), DPAD_UP (android tv only), DPAD_DOWN (android tv only), DPAD_LEFT (android tv only), DPAD_RIGHT (android tv only)

Implementation Reference

  • src/server.ts:414-426 (registration)
    Registration of the 'mobile_press_button' MCP tool, including input schema (device, button) and handler that retrieves the appropriate Robot and calls pressButton
    tool( "mobile_press_button", "Press a button on device", { device: z.string().describe("The device identifier to use. Use mobile_list_available_devices to find which devices are available to you."), button: z.string().describe("The button to press. Supported buttons: BACK (android only), HOME, VOLUME_UP, VOLUME_DOWN, ENTER, DPAD_CENTER (android tv only), DPAD_UP (android tv only), DPAD_DOWN (android tv only), DPAD_LEFT (android tv only), DPAD_RIGHT (android tv only)"), }, async ({ device, button }) => { const robot = getRobotFromDevice(device); await robot.pressButton(button); return `Pressed the button: ${button}`; } );
  • AndroidRobot.pressButton implementation: maps button to Android keyevent and executes via adb shell input
    public async pressButton(button: Button) { if (!BUTTON_MAP[button]) { throw new ActionableError(`Button "${button}" is not supported`); } const mapped = BUTTON_MAP[button]; this.adb("shell", "input", "keyevent", mapped); }
  • IosRobot.pressButton: delegates to WebDriverAgent.pressButton
    public async pressButton(button: Button): Promise<void> { const wda = await this.wda(); await wda.pressButton(button); }
  • iPhone Simulator (Simctl).pressButton: delegates to WebDriverAgent.pressButton
    public async pressButton(button: Button) { const wda = await this.wda(); return wda.pressButton(button); }
  • WebDriverAgent.pressButton: handles ENTER specially, otherwise POST to /wda/pressButton endpoint on the agent
    public async pressButton(button: string) { const _map = { "HOME": "home", "VOLUME_UP": "volumeup", "VOLUME_DOWN": "volumedown", }; if (button === "ENTER") { await this.sendKeys("\n"); return; } // Type assertion to check if button is a key of _map if (!(button in _map)) { throw new ActionableError(`Button "${button}" is not supported`); } await this.withinSession(async sessionUrl => { const url = `${sessionUrl}/wda/pressButton`; const response = await fetch(url, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ name: button, }), }); return response.json(); }); }

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/mobile-next/mobile-mcp'

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