Skip to main content
Glama
charlesmuchene

Android Preference Editor MCP Server

change_preference

Modify existing Android app preferences by updating their values. Use device ID, app package name, and filename to target specific settings during development.

Instructions

Changes the value of an existing preference

Input Schema

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

Implementation Reference

  • The handler function for the 'change_preference' tool. It validates the input using EditPrefSchema, destructures the preference name, value, and connection details, constructs a PartialPreference object, calls the external changePreference function, and returns a success message or error response.
    async (input: z.infer<typeof EditPrefSchema>) => { try { validate(input, EditPrefSchema); const { name, value, ...connection } = input; const pref: PartialPreference = { value, key: name, }; await changePreference(pref, connection); return { content: [ { type: "text", text: `Preference changed`, }, ], }; } catch (error) { return { isError: true, content: [ { type: "text", text: error instanceof Error ? error.message : "Unknown error", }, ], }; }
  • Registers the 'change_preference' tool with the MCP server, providing the tool name, description, input schema (EditPrefSchema.shape), and the handler function.
    server.tool( "change_preference", "Changes the value of an existing preference", EditPrefSchema.shape, async (input: z.infer<typeof EditPrefSchema>) => { try { validate(input, EditPrefSchema); const { name, value, ...connection } = input; const pref: PartialPreference = { value, key: name, }; await changePreference(pref, connection); return { content: [ { type: "text", text: `Preference changed`, }, ], }; } catch (error) { return { isError: true, content: [ { type: "text", text: error instanceof Error ? error.message : "Unknown error", }, ], }; } } );
  • Defines EditPrefSchema by merging PrefSchema (name and value) with FileSchema (deviceId, appId, filename for connection), used for input validation in change_preference tool. Related schemas are also defined here.
    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)
    Invokes configurePreferenceTools which registers the change_preference tool (among others) with the MCP server instance.
    configurePreferenceTools(server);
  • The validate helper function used in the change_preference handler to validate input against the EditPrefSchema.
    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(", ")}` ); };

Other Tools

Related Tools

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