Skip to content

Mobile MCP: let AI agents drive your iOS and Android apps. MCP server for simulators, emulators and real devices. Works with Claude Code, Codex, Cursor and any MCP client.

docs: list every button mobile_press_button accepts, per platform (#500)

Gil Megidish4db7edcea866
diff --git a/src/server.ts b/src/server.ts
index b54e508..9db3237 100644
--- a/src/server.ts
+++ b/src/server.ts
@@ -789,7 +789,12 @@ export const createMcpServer = (): McpServer => {
"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)"),
+ button: z.string().describe([
+ "The button to press, in upper case. Supported buttons:",
+ "Android: HOME, BACK, VOLUME_UP, VOLUME_DOWN, ENTER, BACKSPACE, APP_SWITCH, POWER, DPAD_CENTER, DPAD_UP, DPAD_DOWN, DPAD_LEFT, DPAD_RIGHT",
+ "iOS: HOME, VOLUME_UP, VOLUME_DOWN, ENTER, LOCK",
+ "BACKSPACE deletes the character before the cursor, APP_SWITCH opens the recent apps, POWER turns the screen on or off, LOCK locks the screen, and the DPAD buttons move focus on Android TV.",
+ ].join("\n")),
},
{ readOnlyHint: false, destructiveHint: false, openWorldHint: true },
async ({ device, button }) => {
diff --git a/test/server-tool-descriptions.test.ts b/test/server-tool-descriptions.test.ts
index d566c98..82dcbeb 100644
--- a/test/server-tool-descriptions.test.ts
+++ b/test/server-tool-descriptions.test.ts
@@ -102,3 +102,25 @@ test("says mobile_open_url only opens http and https urls by default", async ()
expect(openUrl.description).toContain("http:// or https://");
expect(openUrl.description).toContain("MOBILEMCP_ALLOW_UNSAFE_URLS=1");
});
+
+// the buttons mobilecli accepts: AndroidDevice.PressButton and DeviceKitClient.PressButton
+const ANDROID_BUTTONS = ["HOME", "BACK", "VOLUME_UP", "VOLUME_DOWN", "ENTER", "BACKSPACE", "APP_SWITCH", "POWER", "DPAD_CENTER", "DPAD_UP", "DPAD_DOWN", "DPAD_LEFT", "DPAD_RIGHT"];
+const IOS_BUTTONS = ["HOME", "VOLUME_UP", "VOLUME_DOWN", "ENTER", "LOCK"];
+
+const buttonDescription = async (): Promise<string> => {
+ const tools = await listToolDefinitions();
+ return findTool(tools, "mobile_press_button").inputSchema.properties!.button.description ?? "";
+};
+
+const buttonsListedFor = (description: string, platform: string): string[] => {
+ const line = description.split("\n").find(candidate => candidate.startsWith(`${platform}:`)) ?? "";
+ return line.slice(platform.length + 1).split(",").map(name => name.trim()).filter(name => name !== "");
+};
+
+test("lists every button mobile_press_button accepts on android", async () => {
+ expect(buttonsListedFor(await buttonDescription(), "Android").sort()).toEqual([...ANDROID_BUTTONS].sort());
+});
+
+test("lists every button mobile_press_button accepts on ios", async () => {
+ expect(buttonsListedFor(await buttonDescription(), "iOS").sort()).toEqual([...IOS_BUTTONS].sort());
+});