Skip to main content
Glama

Android Preference Editor MCP Server

common.ts2.84 kB
import { listDevices, listApps, listFiles, readPreferences, } from "@charlesmuchene/pref-editor"; import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { DeviceSchema, AppSchema, FileSchema } from "../schema.js"; import { validate } from "../utils.js"; import { z } from "zod"; export const configureCommonTools = (server: McpServer) => { server.tool("devices", "Lists connected Android devices", async () => { try { return { content: (await listDevices()).map((device) => ({ type: "text", text: device.serial, })), }; } catch (error) { return { isError: true, content: [ { type: "text", text: error instanceof Error ? error.message : "Unknown error", }, ], }; } }); server.tool( "list_apps", "Lists apps installed on device", DeviceSchema.shape, async (connection: z.infer<typeof DeviceSchema>) => { try { validate(connection, DeviceSchema); return { content: (await listApps(connection)).map((app) => ({ type: "text", text: app.packageName, })), }; } catch (error) { return { isError: true, content: [ { type: "text", text: error instanceof Error ? error.message : "Unknown error", }, ], }; } } ); server.tool( "list_files", "Lists preference files for an app", AppSchema.shape, async (connection: z.infer<typeof AppSchema>) => { try { validate(connection, AppSchema); return { content: (await listFiles(connection)).map((file) => ({ type: "text", text: file.name, })), }; } catch (error) { return { isError: true, content: [ { type: "text", text: error instanceof Error ? error.message : "Unknown error", }, ], }; } } ); 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", }, ], }; } } ); };

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