Skip to main content
Glama
charlesmuchene

Android Preference Editor MCP Server

list_files

Lists preference files for an Android app to view and edit preferences during development. Specify device serial number and app package name.

Instructions

Lists preference files for an app

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
deviceIdYesThe device's serial number.
appIdYesThe application's package name.

Implementation Reference

  • The handler function for the 'list_files' tool. It validates the input using AppSchema, calls the external listFiles function with the connection, maps the results to text content, and handles errors.
    async (connection: z.infer<typeof AppSchema>) => { try { validate(connection, AppSchema); return { content: (await listFiles(connection)).map((file) => ({ type: "text", text: file.name, })), }; } catch (error) { return { isError: true, content: [ { type: "text", text: error instanceof Error ? error.message : "Unknown error", }, ], }; } }
  • Zod schemas defining the input structure for the 'list_files' tool. AppSchema extends DeviceSchema and is used as AppSchema.shape in the tool registration.
    export const DeviceSchema = z.object({ deviceId: z.string().describe("The device's serial number."), }); export const AppSchema = DeviceSchema.extend({ appId: z.string().describe("The application's package name."), });
  • Registration of the 'list_files' tool on the MCP server within the configureCommonTools function, specifying name, description, input schema, and handler.
    server.tool( "list_files", "Lists preference files for an app", AppSchema.shape, async (connection: z.infer<typeof AppSchema>) => { try { validate(connection, AppSchema); return { content: (await listFiles(connection)).map((file) => ({ type: "text", text: file.name, })), }; } catch (error) { return { isError: true, content: [ { type: "text", text: error instanceof Error ? error.message : "Unknown error", }, ], }; } } );
  • Helper function 'validate' used in the list_files handler to validate input against the AppSchema.
    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