delete_preference
Remove a specific user preference from an Android app's configuration file during development by specifying the preference name, device ID, app package, and filename.
Instructions
Delete an existing preference
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | The name/key of the user preference | |
| 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/prefs.ts:57-83 (handler)Handler function that executes the logic for the 'delete_preference' tool: validates input, calls deletePreference, and returns response.
async (input: z.infer<typeof DeletePrefSchema>) => { try { validate(input, DeletePrefSchema); const { name, ...connection } = input; await deletePreference({ key: name }, connection); return { content: [ { type: "text", text: `Preference deleted`, }, ], }; } catch (error) { return { isError: true, content: [ { type: "text", text: error instanceof Error ? error.message : "Unknown error", }, ], }; } - src/schema.ts:35-35 (schema)Zod schema definition for delete_preference input: DeletePrefSchema = NameSchema.merge(FileSchema)
export const DeletePrefSchema = NameSchema.merge(FileSchema); - src/tools/prefs.ts:53-85 (registration)Registration of the 'delete_preference' tool on the MCP server using server.tool(name, description, schema, handler).
server.tool( "delete_preference", "Delete an existing preference", DeletePrefSchema.shape, async (input: z.infer<typeof DeletePrefSchema>) => { try { validate(input, DeletePrefSchema); const { name, ...connection } = input; await deletePreference({ key: name }, connection); return { content: [ { type: "text", text: `Preference deleted`, }, ], }; } catch (error) { return { isError: true, content: [ { type: "text", text: error instanceof Error ? error.message : "Unknown error", }, ], }; } } ); - src/utils.ts:13-21 (helper)Utility function 'validate' used in the handler to parse and validate input against the tool's Zod schema.
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(", ")}` ); };