list_files
Lists preference files for an Android app using device ID and app package name, aiding developers in efficient preference management during app development.
Instructions
Lists preference files for an app
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| appId | Yes | The application's package name. | |
| deviceId | Yes | The device's serial number. |
Implementation Reference
- src/tools/common.ts:66-87 (handler)The handler function that executes the list_files tool logic: validates input, lists files using listFiles(connection), formats as text list, 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/tools/common.ts:62-88 (registration)Registers the list_files tool on the MCP server with name, description, AppSchema.shape as input schema, and inline 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/schema.ts:7-9 (schema)Input schema for list_files tool: requires deviceId and appId.export const AppSchema = DeviceSchema.extend({ appId: z.string().describe("The application's package name."), });
- src/index.ts:21-22 (registration)Invokes configureCommonTools which includes registration of list_files tool.configurePreferenceTools(server); configureCommonTools(server);