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
| Name | Required | Description | Default |
|---|---|---|---|
| deviceId | Yes | The device's serial number. | |
| appId | Yes | The application's package name. |
Implementation Reference
- src/tools/common.ts:66-87 (handler)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", }, ], }; } }
- src/schema.ts:3-9 (schema)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."), });
- src/tools/common.ts:62-88 (registration)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", }, ], }; } } );
- src/utils.ts:12-20 (helper)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(", ")}` );