Skip to main content
Glama
charlesmuchene

Android Preference Editor MCP Server

change_preference

Modify Android app preference values during development by specifying device, app, and preference details.

Instructions

Changes the value of an existing preference

Input Schema

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

Implementation Reference

  • Handler function executing the tool logic: validates input with EditPrefSchema, constructs PartialPreference from name and value, calls external changePreference, returns success or error message.
    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",
            },
          ],
        };
      }
    }
  • Schema definitions culminating in EditPrefSchema = PrefSchema.merge(FileSchema), providing input validation for name, value, filename, appId, deviceId.
    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);
  • Registration of the change_preference tool using server.tool with name, description, EditPrefSchema.shape, and handler function.
      "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",
              },
            ],
          };
        }
      }
    );
  • src/index.ts:21-21 (registration)
    Top-level call to configurePreferenceTools(server), which registers the change_preference tool among others.
    configurePreferenceTools(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