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
| Name | Required | Description | Default |
|---|---|---|---|
| appId | Yes | App ID to persist these settings for. | |
| platform | Yes | Platform the app is built for. | |
| sourceDir | Yes | App source code directory. |
Implementation Reference
- src/server/configurationTools.ts:85-119 (handler)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."), });
- src/server/configurationTools.ts:81-120 (registration)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}`); }