Skip to main content
Glama
charlesmuchene

Android Preference Editor MCP Server

read_preferences

Extract user preferences from Android app files to view stored settings and configuration data during development.

Instructions

Reads all user preferences in a file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
deviceIdYesThe device's serial number.
appIdYesThe application's package name.
filenameYesThe filename with or without the extension.

Implementation Reference

  • Handler function for the 'read_preferences' tool. Validates input with FileSchema, calls external readPreferences(connection), formats each preference as formatted JSON text.
    async (connection: z.infer<typeof FileSchema>) => {
      try {
        validate(connection, FileSchema);
    
        return {
          content: (await readPreferences(connection)).map((pref) => ({
            type: "text",
            mimeType: "application/json",
            text: JSON.stringify(pref, null, 2),
          })),
        };
      } catch (error) {
        return {
          isError: true,
          content: [
            {
              type: "text",
              text: error instanceof Error ? error.message : "Unknown error",
            },
          ],
        };
      }
    }
  • Registration of the 'read_preferences' MCP tool via server.tool() call within configureCommonTools, including inline handler and FileSchema.shape as input schema.
    server.tool(
      "read_preferences",
      "Reads all user preferences in a file",
      FileSchema.shape,
      async (connection: z.infer<typeof FileSchema>) => {
        try {
          validate(connection, FileSchema);
    
          return {
            content: (await readPreferences(connection)).map((pref) => ({
              type: "text",
              mimeType: "application/json",
              text: JSON.stringify(pref, null, 2),
            })),
          };
        } catch (error) {
          return {
            isError: true,
            content: [
              {
                type: "text",
                text: error instanceof Error ? error.message : "Unknown error",
              },
            ],
          };
        }
      }
    );
  • FileSchema Zod schema used for input validation of read_preferences tool: extends AppSchema with 'filename' field.
    export const FileSchema = AppSchema.extend({
      filename: z.string().describe("The filename with or without the extension."),
    });
  • src/index.ts:21-22 (registration)
    Invocation of configureCommonTools(server) which registers the read_preferences tool (among others).
    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