setDeviceMode
Configure device-specific parameters for test authoring and exploration modes on Android and iOS platforms. Set app IDs, mode persistence, and deep link skipping options.
Instructions
Set parameters for a particular device in a given mode.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| deviceId | Yes | Device ID for which these settings will apply. | |
| exploration | No | ||
| platform | Yes | Target platform | |
| testAuthoring | No |
Implementation Reference
- src/server/configurationTools.ts:61-78 (handler)The handler function that executes the setDeviceMode tool logic by calling ConfigurationManager to update the device session.async (args: DeviceSessionArgs): Promise<any> => { try { // Update configuration with provided parameters await ConfigurationManager.getInstance().updateDeviceSession(args, args.platform); return createJSONToolResponse({ success: true, message: `Device configuration updated 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 setDeviceMode tool.const ConfigSchema = z.object({ exploration: z.object({ deepLinkSkipping: z.boolean() }).optional(), testAuthoring: z.object({ appId: z.string().describe("App ID to be used for test authoring."), description: z.string().describe("Rough description of the test to be authored."), persist: z.enum(["never", "devicePresent", "always"]).describe("What conditions to stay in test authoring mode. Default devicePresent"), }).optional(), deviceId: z.string().describe("Device ID for which these settings will apply."), platform: z.enum(["android", "ios"]).describe("Target platform") });
- src/server/configurationTools.ts:57-79 (registration)Registration of the setDeviceMode tool in ToolRegistry with schema and handler.ToolRegistry.register( "setDeviceMode", "Set parameters for a particular device in a given mode.", ConfigSchema, async (args: DeviceSessionArgs): Promise<any> => { try { // Update configuration with provided parameters await ConfigurationManager.getInstance().updateDeviceSession(args, args.platform); return createJSONToolResponse({ success: true, message: `Device configuration updated 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); } } );
- Core helper method in ConfigurationManager that sets the device configuration based on args and persists it.public async updateDeviceSession(args: DeviceSessionArgs, platform: "android" | "ios"): Promise<void> { let newConfig: DeviceConfig | undefined; if (args.testAuthoring) { newConfig = { platform: platform, activeMode: "testAuthoring", deviceId: args.deviceId, testAuthoring: { appId: args.testAuthoring.appId, description: args.testAuthoring.description, persist: args.testAuthoring.persist }, }; } else if (args.exploration) { newConfig = { platform: platform, activeMode: "exploration", deviceId: args.deviceId, exploration: { deepLinkSkipping: args.exploration.deepLinkSkipping, } }; } if (newConfig) { this.deviceSessionConfigs.set(args.deviceId, newConfig); } await this.saveAppConfigs(); }
- src/server/index.ts:32-32 (registration)Top-level call to registerConfigurationTools() which registers the setDeviceMode tool.registerConfigurationTools();