Skip to content

feat(session): consolidate device actions into appium_mobile_device_control#259

Open
Mochxd wants to merge 2 commits intoappium:mainfrom
Mochxd:feat/mobile-device-lock-consolidation
Open

feat(session): consolidate device actions into appium_mobile_device_control#259
Mochxd wants to merge 2 commits intoappium:mainfrom
Mochxd:feat/mobile-device-lock-consolidation

Conversation

@Mochxd
Copy link
Copy Markdown
Contributor

@Mochxd Mochxd commented Apr 10, 2026

Consolidates lock, unlock, shake, and open notifications into one intent-based tool: appium_mobile_device_control.

What changed

  • Replaced separate tools with a single tool:
    • action: "lock" | "unlock" | "shake" | "open_notifications"
    • optional seconds only for action="lock" (timed lock via mobile: lock)
  • shake: iOS XCUITest sessions only
  • open_notifications: Android only (UiAutomator2 openNotifications(), or mobile: openNotifications for remote sessions)
  • Updated tool registration in src/tools/index.ts
  • Updated docs (README.md, src/tools/README.md)

Behavior

  • action="lock"mobile: lock (optional seconds)
  • action="unlock"mobile: unlock
  • action="shake" → device shake (XCUITest)
  • action="open_notifications" → open notifications panel (Android)
  • Validation: seconds is rejected when action is not lock.

@Mochxd Mochxd force-pushed the feat/mobile-device-lock-consolidation branch 2 times, most recently from a1243fe to 9c13fce Compare April 13, 2026 13:07
@Mochxd Mochxd changed the title feat(session): consolidate lock and unlock into appium_mobile_device_lock feat(session): consolidate device actions into appium_mobile_device_control Apr 13, 2026
@Mochxd
Copy link
Copy Markdown
Contributor Author

Mochxd commented Apr 13, 2026

@KazuCocoa @saikrishna321 @SrinivasanTarget
there’s a lot of overlap with #260, so I compared the two approaches:

Design preference

  • I think we should keep device info (read-only / query: model, battery, time, etc.) and device mobile control (mutating: lock, unlock, shake, notifications) as separate MCP tools clearer responsibilities, smaller parameter surface per tool, and easier for clients to treat "read state" vs "act on device" differently.

Naming

Behavior / review notes

i think we should not align on naming and action strings only but I’d prefer not folding device info into the same tool as lock/shake/notifications.

@Mochxd Mochxd force-pushed the feat/mobile-device-lock-consolidation branch from 39727c9 to 9c13fce Compare April 13, 2026 13:47
@SrinivasanTarget
Copy link
Copy Markdown
Member

@Mochxd thanks for your valuable contribution and suggestion. I agree with you on the suggestion. The design principle should be: one user intent = one tool, regardless of how many Appium APIs it takes underneath.

  • appium_mobile_device_control (lock, unlock, shake, open_notifications) = "control the physical device" one user intent, one tool. This is correct.
  • appium_mobile_device_info (info, battery, time) = "query device state" separate intent, separate tool. Also correct.

"control device" and "query device" are fundamentally different intents.

@navin772 @Delta456

PLATFORM,
} from '../../session-store.js';
import { execute } from '../../command.js';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like a giant. Can we do something like this?

async function handleLock(driver, seconds?: number): Promise { ... }
async function handleUnlock(driver): Promise { ... }
async function handleShake(driver): Promise { ... }
async function handleOpenNotifications(driver): Promise { ... }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch as usual, done extracted handleLock, handleUnlock, handleShake, and handleOpenNotifications into separate functions, the execute block is now a thin switch/case dispatcher

Comment thread src/tools/session/device-control.ts Outdated
action: z
.enum(['lock', 'unlock', 'shake', 'open_notifications'])
.describe(
'Action to perform: lock/unlock device, shake (iOS XCUITest only), or open notifications (Android only).'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.describe(
'Action to perform. ' +
'lock: lock the device (optional seconds for timed lock). ' +
'unlock: unlock the device. ' +
'shake: perform shake gesture (iOS XCUITest only). ' +
'open_notifications: open notifications panel (Android only).'
)

Comment thread src/tools/session/device-control.ts Outdated
server.addTool({
name: 'appium_mobile_device_control',
description:
'Control device-level actions in one tool. action=lock|unlock uses mobile: lock/unlock, action=shake performs iOS XCUITest shake, action=open_notifications opens Android notifications panel.',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tool description could be more intent-oriented

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e.g. Control device behavior: lock/unlock the screen, shake the device, or open the notifications panel. Use the action parameter to choose what to do.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, i adopted your suggested intent-oriented description

Comment thread README.md Outdated
| `create_session` | Create a new mobile automation session for Android, iOS, or `general` capabilities (see 'general' mode above). If a remote Appium server is referenced, `create_session` forwards the final capabilities to that server via the WebDriver `newSession` API - include device selection (e.g., `appium:udid`) in `capabilities` when targeting a remote server. |
| `delete_session` | Delete the current mobile session and clean up resources |
| `appium_mobile_shake` | Shake gesture (`mobile: shake`) on **iOS Simulator only** (XCUITest). Not supported on Android or physical iOS devices. |
| `appium_mobile_device_control` | Device controls in one tool (`action`: `lock` \| `unlock` \| `shake` \| `open_notifications`). `shake` requires iOS XCUITest; `open_notifications` is Android only; `seconds` is optional for timed lock. |
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drop "XCUITest" from the README

Mochxd added 2 commits April 15, 2026 15:41
…ontrol

Replace separate shake, notifications, and lock/unlock tools with one action-based tool (lock, unlock, shake, open_notifications) and platform-specific validation.
- Extract handler functions: handleLock, handleUnlock, handleShake,
  handleOpenNotifications for cleaner separation
- Use switch/case dispatch in execute
- Update action .describe() with per-action explanations
- Make tool description intent-oriented per reviewer suggestion
- Drop XCUITest reference from README description
@Mochxd Mochxd force-pushed the feat/mobile-device-lock-consolidation branch from 9c13fce to d7b22f7 Compare April 15, 2026 13:44
@Mochxd Mochxd requested a review from SrinivasanTarget April 15, 2026 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants