Skip to main content
Glama
charlesmuchene

Android Preference Editor MCP Server

add_preference

Adds a new user preference with specified name, value, and type to an Android app via the Android Preference Editor MCP Server. Requires device ID, app package name, and filename for precise configuration during development.

Instructions

Adds a new preference given the name, value and type.

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
typeYesThe type of the preference value: integer, boolean, float, double, long or string
valueYesThe value of user preference

Implementation Reference

  • The handler function that executes the 'add_preference' tool: validates input using AddPrefSchema, constructs a Preference object, calls the imported addPreference function, and returns a structured response or error.
    async (input: z.infer<typeof AddPrefSchema>) => { try { validate(input, AddPrefSchema); const { name, value, type, ...connection } = input; const pref: Preference = { key: name, value, type: parseDataType(type), }; await addPreference(pref, connection); return { content: [ { type: "text", text: `Preference added`, }, ], }; } catch (error) { return { isError: true, content: [ { type: "text", text: error instanceof Error ? error.message : "Unknown error", }, ], }; }
  • Direct registration of the 'add_preference' MCP tool using server.tool(), including name, description, input schema, and inline handler.
    server.tool( "add_preference", "Adds a new preference given the name, value and type.", AddPrefSchema.shape, async (input: z.infer<typeof AddPrefSchema>) => { try { validate(input, AddPrefSchema); const { name, value, type, ...connection } = input; const pref: Preference = { key: name, value, type: parseDataType(type), }; await addPreference(pref, connection); return { content: [ { type: "text", text: `Preference added`, }, ], }; } catch (error) { return { isError: true, content: [ { type: "text", text: error instanceof Error ? error.message : "Unknown error", }, ], }; } } );
  • Zod schema definition for 'add_preference' tool inputs: AddPrefSchema merges TypedPrefSchema (name, value, type) with FileSchema (device/app/file context).
    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);
  • src/index.ts:21-21 (registration)
    Top-level invocation of configurePreferenceTools(server), which registers the 'add_preference' tool among others on the MCP server.
    configurePreferenceTools(server);

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