adb_set_default_device
Set the default Android device for ADB operations to streamline device management and automation tasks.
Instructions
Set the default device for subsequent operations
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| deviceId | Yes | Device ID to set as default |
Implementation Reference
- src/tools/device.ts:57-81 (handler)The primary handler function for the 'adb_set_default_device' tool. It checks if the specified device is connected, sets it as the default using AdbClient, and returns a structured response.async setDefaultDevice(deviceId: string) { try { const connected = await this.adbClient.isDeviceConnected(deviceId); if (!connected) { return { success: false, error: 'Device not connected', message: 'Cannot set default device - device is not connected' }; } this.adbClient.setDefaultDevice(deviceId); return { success: true, data: { deviceId }, message: `Default device set to ${deviceId}` }; } catch (error: any) { return { success: false, error: error.message, message: 'Failed to set default device' }; } }
- src/index.ts:74-87 (schema)Input schema definition for the tool, specifying that 'deviceId' is required.{ name: 'adb_set_default_device', description: 'Set the default device for subsequent operations', inputSchema: { type: 'object', properties: { deviceId: { type: 'string', description: 'Device ID to set as default', }, }, required: ['deviceId'], }, },
- src/index.ts:437-438 (registration)Registers the tool handler in the switch statement for CallToolRequestSchema, delegating to deviceTools.setDefaultDevice.case 'adb_set_default_device': return await this.handleToolCall(this.deviceTools.setDefaultDevice(args?.deviceId as string));
- src/adb-client.ts:125-127 (helper)Helper method in AdbClient that sets the defaultDevice property, used by all subsequent ADB commands to target the correct device.setDefaultDevice(deviceId: string): void { this.defaultDevice = deviceId; }