read_preferences
Extract and view all user preferences stored in a specific file on an Android device using the device ID, app ID, and filename.
Instructions
Reads all user preferences in a file
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| appId | Yes | The application's package name. | |
| deviceId | Yes | The device's serial number. | |
| filename | Yes | The filename with or without the extension. |
Implementation Reference
- src/tools/common.ts:90-117 (registration)Registers the "read_preferences" tool with server.tool, providing description, FileSchema.shape for input, and inline async handler that validates input, reads preferences via readPreferences(connection), formats each as JSON text, handles errors.server.tool( "read_preferences", "Reads all user preferences in a file", FileSchema.shape, async (connection: z.infer<typeof FileSchema>) => { try { validate(connection, FileSchema); return { content: (await readPreferences(connection)).map((pref) => ({ type: "text", mimeType: "application/json", text: JSON.stringify(pref, null, 2), })), }; } catch (error) { return { isError: true, content: [ { type: "text", text: error instanceof Error ? error.message : "Unknown error", }, ], }; } } );
- src/schema.ts:11-13 (schema)FileSchema definition used for read_preferences tool input validation (requires deviceId, appId, filename).export const FileSchema = AppSchema.extend({ filename: z.string().describe("The filename with or without the extension."), });
- src/schema.ts:7-9 (schema)AppSchema extended by FileSchema (requires deviceId, appId).export const AppSchema = DeviceSchema.extend({ appId: z.string().describe("The application's package name."), });
- src/schema.ts:3-5 (schema)DeviceSchema base schema for tool inputs (deviceId).export const DeviceSchema = z.object({ deviceId: z.string().describe("The device's serial number."), });
- src/utils.ts:13-21 (helper)validate helper function used in read_preferences handler to validate input against FileSchema.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(", ")}` ); };