setAppSource
Configure source code directory and platform for mobile apps in the AutoMobile automation suite. Specify app ID, source path, and target platform (Android or iOS) for test execution.
Instructions
For a given appId, set the source code path and platform.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sourceDir | Yes | App source code directory. | |
| appId | Yes | App ID to persist these settings for. | |
| platform | Yes | Platform the app is built for. |
Implementation Reference
- src/server/configurationTools.ts:85-119 (handler)The handler function for the setAppSource MCP tool. Validates that the appId is installed on the device, sets the app source using ConfigurationManager, logs success, and returns a standardized JSON response.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 schema defining the input parameters for the setAppSource tool.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, which associates the name, description, schema, and 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 validates the source directory exists, updates the in-memory app config map, and saves the configuration to disk (~/.auto-mobile/config.json).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}`); }
- src/server/index.ts:32-32 (registration)Invocation of registerConfigurationTools() during MCP server initialization, which registers the setAppSource tool among others.registerConfigurationTools();