list_apps
Retrieve a list of apps installed on an Android device by providing the device's serial number, aiding in app development and preference management.
Instructions
Lists apps installed on device
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| deviceId | Yes | The device's serial number. |
Implementation Reference
- src/tools/common.ts:34-60 (registration)Registers the "list_apps" MCP tool, providing description, input schema, and the handler function that executes the tool logic by listing apps on the specified device.server.tool( "list_apps", "Lists apps installed on device", DeviceSchema.shape, async (connection: z.infer<typeof DeviceSchema>) => { try { validate(connection, DeviceSchema); return { content: (await listApps(connection)).map((app) => ({ type: "text", text: app.packageName, })), }; } catch (error) { return { isError: true, content: [ { type: "text", text: error instanceof Error ? error.message : "Unknown error", }, ], }; } } );
- src/schema.ts:3-5 (schema)Zod schema definition for the input to the list_apps tool, requiring a deviceId (serial number).export const DeviceSchema = z.object({ deviceId: z.string().describe("The device's serial number."), });
- src/tools/common.ts:38-59 (handler)The inline async handler function for the list_apps tool, which validates the device connection, calls listApps(connection) to fetch apps, and formats the package names as text content.async (connection: z.infer<typeof DeviceSchema>) => { try { validate(connection, DeviceSchema); return { content: (await listApps(connection)).map((app) => ({ type: "text", text: app.packageName, })), }; } catch (error) { return { isError: true, content: [ { type: "text", text: error instanceof Error ? error.message : "Unknown error", }, ], }; } }