Skip to main content
Glama

setAppSource

Configure the source code path and platform for a specific app ID to ensure accurate automation and testing setup in the AutoMobile server.

Instructions

For a given appId, set the source code path and platform.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
appIdYesApp ID to persist these settings for.
platformYesPlatform the app is built for.
sourceDirYesApp source code directory.

Implementation Reference

  • Device-aware handler for the setAppSource tool. Validates that the app is installed on the device, then delegates to ConfigurationManager.setAppSource with wipeData set to false.
    async (device: BootedDevice, args: AppSourceArgs): Promise<any> => { try { const apps = await new ListInstalledApps(device).execute(); if (apps.find(app => app === args.appId) === undefined) { return createJSONToolResponse({ success: false, message: `App ${args.appId} is not installed on device ${device.deviceId}, use listApps and try again.` }); } // Update configuration with provided parameters await ConfigurationManager.getInstance().setAppSource( args.appId, args.sourceDir, args.platform, false ); // await SourceMapper.getInstance().scanProject(args.appId); logger.info("App source added successfully"); return createJSONToolResponse({ success: true, message: "App source added successfully" }); } catch (error) { logger.error("Failed to configure MCP server:", error); const result = { success: false, message: `Failed to configure MCP server: ${error}` }; return createJSONToolResponse(result); } }
  • Zod input schema for the setAppSource tool, defining sourceDir, appId, and platform parameters.
    const AppSourceSchema = z.object({ sourceDir: z.string().describe("App source code directory."), appId: z.string().describe("App ID to persist these settings for."), platform: z.enum(["android", "ios"]).describe("Platform the app is built for."), });
  • Registration of the setAppSource tool using ToolRegistry.registerDeviceAware, specifying name, description, schema, and inline handler function.
    ToolRegistry.registerDeviceAware( "setAppSource", "For a given appId, set the source code path and platform.", AppSourceSchema, async (device: BootedDevice, args: AppSourceArgs): Promise<any> => { try { const apps = await new ListInstalledApps(device).execute(); if (apps.find(app => app === args.appId) === undefined) { return createJSONToolResponse({ success: false, message: `App ${args.appId} is not installed on device ${device.deviceId}, use listApps and try again.` }); } // Update configuration with provided parameters await ConfigurationManager.getInstance().setAppSource( args.appId, args.sourceDir, args.platform, false ); // await SourceMapper.getInstance().scanProject(args.appId); logger.info("App source added successfully"); return createJSONToolResponse({ success: true, message: "App source added successfully" }); } catch (error) { logger.error("Failed to configure MCP server:", error); const result = { success: false, message: `Failed to configure MCP server: ${error}` }; return createJSONToolResponse(result); } } );
  • Helper method in ConfigurationManager that implements the core logic: validates source directory existence, updates app source configuration in memory, and saves to disk.
    public async setAppSource(appId: string, sourceDir: string, platform: "android" | "ios", wipeData: boolean): Promise<void> { if (!require("fs").existsSync(sourceDir)) { throw new ActionableError(`Source directory does not exist: ${sourceDir}`); } const existing = this.appSourceConfigs.get(appId); const newMap = new Map<string, string>(); const data = wipeData ? newMap : (existing?.data || newMap); this.appSourceConfigs.set(appId, { appId, sourceDir, platform, data }); await this.saveAppConfigs(); logger.debug(`[SOURCE] Set app source: ${appId} -> ${sourceDir}`); }

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/zillow/auto-mobile'

If you have feedback or need assistance with the MCP directory API, please join our Discord server