Skip to main content
Glama
charlesmuchene

Android Preference Editor MCP Server

list_apps

Retrieve installed applications on an Android device by providing the device serial number. This tool supports app development by enabling access to app listings for preference management.

Instructions

Lists apps installed on device

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
deviceIdYesThe device's serial number.

Implementation Reference

  • The handler function for the list_apps tool. It validates the input connection (deviceId), calls listApps from the external library, and formats the app package names as text content. Handles errors by returning an error response.
    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", }, ], }; } }
  • DeviceSchema defines the input schema for list_apps, requiring a deviceId string.
    export const DeviceSchema = z.object({ deviceId: z.string().describe("The device's serial number."), });
  • Registers the list_apps tool on the MCP server within configureCommonTools, specifying name, description, input schema (DeviceSchema.shape), and the handler function.
    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", }, ], }; } } );
  • validate function used in the list_apps handler to validate the input against DeviceSchema.
    export const validate = (input: unknown, type: ZodType) => { const validationResult = type.safeParse(input); if (!validationResult.success) throw new Error( `Invalid input: ${validationResult.error.errors .map((err) => err.message) .join(", ")}` ); };

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/charlesmuchene/pref-editor-mcp-server'

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