delete_preference
Remove specific user preferences in Android apps by specifying the preference name, device ID, app package name, and filename. Streamlines app development and testing workflows.
Instructions
Delete an existing preference
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. | |
| name | Yes | The name/key of the user preference |
Implementation Reference
- src/tools/prefs.ts:57-84 (handler)The handler function for the 'delete_preference' MCP tool. It validates the input, destructures the name and connection parameters, calls the external deletePreference function, and returns a success or error 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 for 'delete_preference' tool input: merges NameSchema (name field) and FileSchema (deviceId, appId, filename for connection).export const DeletePrefSchema = NameSchema.merge(FileSchema);
- src/tools/prefs.ts:53-85 (registration)Registration of the 'delete_preference' tool in configurePreferenceTools using McpServer.tool() with name, description, schema.shape, and handler function.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/schema.ts:11-35 (schema)Supporting schemas: FileSchema, NameSchema, and DeletePrefSchema = NameSchema.merge(FileSchema) used for delete_preference input validation.export const FileSchema = AppSchema.extend({ filename: z.string().describe("The filename with or without the extension."), }); export const NameSchema = z.object({ name: z.string().describe("The name/key of the user preference"), }); export const PrefSchema = NameSchema.extend({ value: z.string().describe("The value of user preference"), }); export const TypedPrefSchema = PrefSchema.extend({ type: z .string() .describe( "The type of the preference value: integer, boolean, float, double, long or string" ), }); export const AddPrefSchema = TypedPrefSchema.merge(FileSchema); export const EditPrefSchema = PrefSchema.merge(FileSchema); export const DeletePrefSchema = NameSchema.merge(FileSchema);
- src/index.ts:21-21 (registration)Invocation of configurePreferenceTools which registers the delete_preference tool (among others).configurePreferenceTools(server);