Skip to main content
Glama
charlesmuchene

Android Preference Editor MCP Server

add_preference

Add a new preference to an Android app's configuration by specifying name, value, and type during development.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesThe name/key of the user preference
valueYesThe value of user preference
typeYesThe type of the preference value: integer, boolean, float, double, long or string
deviceIdYesThe device's serial number.
appIdYesThe application's package name.
filenameYesThe filename with or without the extension.

Implementation Reference

  • The handler function that executes the 'add_preference' tool logic: validates input, constructs Preference object using parseDataType, calls imported addPreference, returns success/error text response.
    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", }, ], }; } }
  • Registration of the 'add_preference' MCP tool using server.tool() with name, description, AddPrefSchema.shape, 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 definitions for preference tools, including AddPrefSchema = TypedPrefSchema.merge(FileSchema) used for input validation of 'add_preference'.
    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-22 (registration)
    Invocation of configurePreferenceTools which registers the 'add_preference' tool (and others) on the MCP server.
    configurePreferenceTools(server); configureCommonTools(server);

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