read_preferences
Extract user preferences from Android app files to view stored settings and configuration data during development.
Instructions
Reads all user preferences in a file
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| deviceId | Yes | The device's serial number. | |
| appId | Yes | The application's package name. | |
| filename | Yes | The filename with or without the extension. |
Implementation Reference
- src/tools/common.ts:94-116 (handler)Handler function for the 'read_preferences' tool. Validates input with FileSchema, calls external readPreferences(connection), formats each preference as formatted JSON text.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/tools/common.ts:90-117 (registration)Registration of the 'read_preferences' MCP tool via server.tool() call within configureCommonTools, including inline handler and FileSchema.shape as input schema.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 Zod schema used for input validation of read_preferences tool: extends AppSchema with 'filename' field.export const FileSchema = AppSchema.extend({ filename: z.string().describe("The filename with or without the extension."), });
- src/index.ts:21-22 (registration)Invocation of configureCommonTools(server) which registers the read_preferences tool (among others).configurePreferenceTools(server); configureCommonTools(server);