Skip to main content
Glama
charlesmuchene

Android Preference Editor MCP Server

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

TableJSON Schema
NameRequiredDescriptionDefault
nameYesThe name/key of the user preference
deviceIdYesThe device's serial number.
appIdYesThe application's package name.
filenameYesThe filename with or without the extension.

Implementation Reference

  • 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", }, ], }; }
  • Zod schema definition for delete_preference input: DeletePrefSchema = NameSchema.merge(FileSchema)
    export const DeletePrefSchema = NameSchema.merge(FileSchema);
  • 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", }, ], }; } } );
  • 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(", ")}` ); };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/charlesmuchene/pref-editor-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server