Skip to main content
Glama

press_key

Simulate pressing hardware or software keys on Android devices to automate navigation, volume control, power management, and menu access during testing or automation workflows.

Instructions

Press a hardware/software key

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYesKey to press
device_idNoDevice ID (optional if only one device)

Implementation Reference

  • The MCP tool handler for "press_key" which calls the ADB helper.
    async ({ key, device_id }) => {
      await adb.pressKey(KEYCODE_MAP[key], device_id);
      return { content: [{ type: "text", text: `Pressed: ${key}` }] };
    },
  • The ADB implementation of the pressKey logic.
    async pressKey(keycode: number, deviceId?: string): Promise<void> {
      await this.exec(["shell", "input", "keyevent", String(keycode)], deviceId);
    }
  • The input schema definition for the "press_key" tool.
    {
      key: z
        .enum([
          "back",
          "home",
          "enter",
          "tab",
          "delete",
          "menu",
          "recent_apps",
          "volume_up",
          "volume_down",
          "power",
          "search",
          "dpad_up",
          "dpad_down",
          "dpad_left",
          "dpad_right",
          "dpad_center",
        ])
        .describe("Key to press"),
      device_id: z.string().optional().describe("Device ID (optional if only one device)"),
    },
  • src/index.ts:304-306 (registration)
    The registration of the "press_key" tool in the MCP server.
    server.tool(
      "press_key",
      "Press a hardware/software 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/martingeidobler/android-mcp-server'

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