M

Mobile MCP

4.5 points
433
Installation
Copy the following command to your Client for configuration
Note: Your key is sensitive information, do not share it with anyone.

🚀 Mobile Device Command and Interaction Tool Documentation

This project aims to provide a flexible and reliable automation testing framework for mobile devices, supporting operations through accessibility locators (preferred) and coordinate-based input. Users can choose different positioning methods according to actual needs to achieve a seamless automation process.

📄 Command List and Description

mobile_list_apps

  • Description: List all installed applications on the device.
  • Parameters:
    • bundleId (string): The unique package/identifier of the application, e.g., com.google.android.keep or com.apple.mobilenotes.

mobile_launch_app

  • Description: Launch the specified application on the device or emulator.
  • Parameters:
    • bundleId (string): The unique package/identifier of the application, e.g., com.google.android.keep or com.apple.mobilenotes.

mobile_terminate_app

  • Description: Terminate the running application.
  • Parameters:
    • packageName (string): Call am force stop based on the application's package/identifier or directly terminate the process.

mobile_get_screen_size

  • Description: Get the resolution of the device screen in pixels.
  • Parameters: None

mobile_click_on_screen_at_coordinates

  • Description: Click at the specified screen coordinates.
  • Parameters:
    • x (number): The X coordinate
    • y (number): The Y coordinate

mobile_list_elements_on_screen

  • Description: List all elements on the screen and their coordinates, including the displayed text or accessibility labels.
  • Parameters: None

mobile_element_tap

  • Description: Click the specified UI element according to the accessibility locator.
  • Parameters:
    • element (string): A human-readable description of the element (e.g., "Login button").
    • ref (string): The accessibility/automation ID or the reference obtained from the snapshot.

mobile_tap

  • Description: Click at the specified screen coordinates.
  • Parameters:
    • x (number): The X coordinate
    • y (number): The Y coordinate

mobile_press_button

  • Description: Press the hardware button on the device (e.g., Home, Back, Volume, Enter, etc.).
  • Parameters: None

mobile_open_url

  • Description: Open the specified URL in the device browser.
  • Parameters:
    • url (string): The URL address to open, e.g., https://example.com.

mobile_type_text

  • Description: Input text into the focused element (such as TextField, SearchField).
  • Parameters:
    • text (string): The text to input
    • submit (boolean): Whether to press the Enter key after input

mobile_element_swipe

  • Description: Swipe from one UI element to another.
  • Parameters:
    • startElement (string): A human-readable description of the starting element
    • startRef (string): The accessibility/automation ID of the starting element
    • endElement (string): A human-readable description of the ending element
    • endRef (string): The accessibility/automation ID of the ending element

mobile_swipe

  • Description: Perform a swipe operation between two coordinate points.
  • Parameters:
    • startX (number): The starting X coordinate
    • startY (number): The starting Y coordinate
    • endX (number): The ending X coordinate
    • endY (number): The ending Y coordinate

mobile_press_and_hold

  • Description: Long-press the screen at the specified position.
  • Parameters:
    • x (number): The X coordinate
    • y (number): The Y coordinate
    • duration (number): The duration of the long-press in milliseconds

mobile_drag_and_drop

  • Description: Drag an element from one position to another.
  • Parameters:
    • fromX (number): The X coordinate of the starting point of the drag
    • fromY (number): The Y coordinate of the starting point of the drag
    • toX (number): The X coordinate of the ending point of the drag
    • toY (number): The Y coordinate of the ending point of the drag

mobile_scroll

  • Description: Perform a scroll operation on the screen.
  • Parameters:
    • direction (string): The scroll direction, optional values are: up, down, left, right

mobile_get_text

  • Description: Get the text content of the specified element.
  • Parameters:
    • elementRef (string): The accessibility/automation ID of the element

mobile_set_text

  • Description: Set the text content of the specified element.
  • Parameters:
    • elementRef (string): The accessibility/automation ID of the element
    • text (string): The text content to set

mobile_clear_text

  • Description: Clear the text content in the input box.
  • Parameters:
    • elementRef (string): The accessibility/automation ID of the input box element

mobile_click_element_by_text

  • Description: Click the specified UI element according to the text content.
  • Parameters:
    • text (string): The text content displayed by the element
    • partialMatch (boolean, optional): Whether to allow partial matching, default is false

mobile_click_element_by_content_description

  • Description: Click the specified UI element according to the content description.
  • Parameters:
    • contentDescription (string): The content description of the element
    • partialMatch (boolean, optional): Whether to allow partial matching, default is false

mobile_wait_for_element

  • Description: Wait for the specified element to appear (e.g., wait for the page to finish loading).
  • Parameters:
    • elementRef (string): The accessibility/automation ID of the element
    • timeout (number, optional): The waiting timeout in milliseconds, default is 30000

mobile_take_screenshot

  • Description: Take a screenshot of the screen and save it.
  • Parameters:
    • filename (string, optional): The name of the file to save, default is automatically generated.

mobile_device_time

  • Description: Get the current time of the device.
  • Parameters: None

mobile_set_volume

  • Description: Adjust the device volume.
  • Parameters:
    • volumeLevel (number): The volume level, ranging from 0 to 1.0

mobile_toggle_airplane_mode

  • Description: Turn on or off airplane mode.
  • Parameters: None

mobile_check_wifi_connection

  • Description: Check if the device is connected to a Wi-Fi network.
  • Parameters:
    • ssid (string, optional): The Wi-Fi SSID to check
    • timeout (number, optional): The waiting timeout in seconds, default is 30

mobile_connect_to_wifi

  • Description: Connect to the specified Wi-Fi network.
  • Parameters:
    • ssid (string): The Wi-Fi SSID to connect to
    • password (string, optional): The Wi-Fi password

mobile_disconnect_WIFI

  • Description: Disconnect the current Wi-Fi connection.
  • Parameters: None

mobile_check_network_connection

  • Description: Check the network connection status of the device (including mobile data and Wi-Fi).
  • Parameters:
    • networkType (string, optional): The network type to check, optional values are: wifi, mobile

mobile_set_geolocation

  • Description: Set the geographical location information of the device (suitable for simulated positioning scenarios).
  • Parameters:
    • latitude (number): The latitude
    • longitude (number): The longitude
    • altitude (number, optional): The altitude, default is 0

mobile_unset_geolocation

  • Description: Restore the default geographical location information of the device.
  • Parameters: None

mobile_back_to_home_screen

  • Description: Return to the home screen.
  • Parameters: None

mobile_launch_app

  • Description: Launch the specified application.
  • Parameters:
    • packageName (string): The package name of the application
    • activityName (string, optional): The name of the Activity to launch, default is the default launch page of the application

mobile_close_app

  • Description: Close the current application.
  • Parameters:
    • packageName (string): The package name of the application

mobile_clear_app_data

  • Description: Clear the data and cache of the application.
  • Parameters:
    • packageName (string): The package name of the application

mobile_install_apk

  • Description: Install an APK file on the device.
  • Parameters:
    • apkPath (string): The path of the APK file
    • waitTime (number, optional): The waiting time after installation in seconds, default is 5

mobile_uninstall_apk

  • Description: Uninstall the specified application.
  • Parameters:
    • packageName (string): The package name of the application

mobile_push_file

  • Description: Push a file to the device.
  • Parameters:
    • localFilePath (string): The local file path
    • remoteFileName (string, optional): The file name on the device, default is the same as the local file name

mobile_pull_file

  • Description: Pull the specified file from the device to the local.
  • Parameters:
    • remoteFileName (string): The file path on the device
    • localSavePath (string, optional): The local save path, default is the current working directory

mobile_logcat_clear

  • Description: Clear the logcat logs of the device.
  • Parameters: None

mobile_logcat_dump

  • Description: Export the logcat logs of the device to a file.
  • Parameters:
    • filename (string, optional): The name of the log file to save, default is automatically generated.

mobile_input_text

  • Description: Input text into the input box (similar to the sendKeys operation).
  • Parameters:
    • elementRef (string): The accessibility/automation ID of the input box element
    • text (string): The text content to input

mobile_input_number

  • Description: Input a numerical value into the number input box.
  • Parameters:
    • elementRef (string): The accessibility/automation ID of the number input box element
    • numberValue (number): The numerical value to input

mobile_switch_to_webview

  • Description: Switch to the WebView window (suitable for hybrid applications).
  • Parameters:
    • webViewIndex (number, optional): The index of the WebView to switch to, default is the first WebView

mobile_switch_to_native

  • Description: Switch back to the Native elements (suitable for hybrid applications).
  • Parameters: None

mobile_get_current_context

  • Description: Get the current context (Native or WebView).
  • Parameters:
    • result (string): The type of the current context, the return value is: NATIVE, WEBVIEW

mobile_wait_for_element_text

  • Description: Wait for the text content of the specified element to appear.
  • Parameters:
    • elementRef (string): The accessibility/automation ID of the element
    • expectedText (string): The expected text content
    • timeout (number, optional): The waiting timeout in milliseconds, default is 30000

mobile_compare_element_text

  • Description: Compare whether the current text content of the specified element is consistent with the expected text.
  • Parameters:
    • elementRef (string): The accessibility/automation ID of the element
    • expectedText (string): The expected text content
    • ignoreCase (boolean, optional): Whether to ignore case, default is false

mobile_is_element_present

  • Description: Check if the specified element exists.
  • Parameters:
    • elementRef (string): The accessibility/automation ID of the element
    • result (boolean): Returns true if it exists, otherwise false

mobile_is_element_enabled

  • Description: Check if the specified element is enabled (clickable).
  • Parameters:
    • elementRef (string): The accessibility/automation ID of the element
    • result (boolean): Returns true if enabled, otherwise false

mobile_is_element_selected

  • Description: Check if the specified element is selected (e.g., RadioButton, CheckBox, etc.).
  • Parameters:
    • elementRef (string): The accessibility/automation ID of the element
    • result (boolean): Returns true if selected, otherwise false

mobile_is_element_displayed

  • Description: Check if the specified element is visible.
  • Parameters:
    • elementRef (string): The accessibility/automation ID of the element
    • result (boolean): Returns true if visible, otherwise false

mobile_element_attribute

  • Description: Get the value of a certain attribute of the specified element.
  • Parameters:
    • elementRef (string): The accessibility/automation ID of the element
    • attributeName (string): The name of the attribute to get
    • result (string): The value corresponding to the attribute

mobile_element_text

  • Description: Get the text content of the specified element.
  • Parameters:
    • elementRef (string): The accessibility/automation ID of the element
    • result (string): The text content

mobile_set_value

  • Description: Set the value in the input box (similar to the sendKeys operation).
  • Parameters:
    • elementRef (string): The accessibility/automation ID of the input box element
    • value (string): The text content to set

mobile_press_element

  • Description: Perform a click operation on the specified element.
  • Parameters:
    • elementRef (string): The accessibility/automation ID of the element
    • times (number, optional): The number of clicks, default is 1

mobile_long_press_element

  • Description: Perform a long-press operation on the specified element.
  • Parameters:
    • elementRef (string): The accessibility/automation ID of the element
    • duration (number, optional): The duration of the long-press in milliseconds, default is 500

mobile_swipe_element

  • Description: Perform a swipe operation on the specified element (left or right).
  • Parameters:
    • elementRef (string): The accessibility/automation ID of the element
    • direction (string): The swipe direction, optional values are: LEFT, RIGHT
    • distance (number, optional): The distance of the swipe, default is half of the element's width

mobile_drag_element

  • Description: Perform a drag operation on the specified element.
  • Parameters:
    • elementRef (string): The accessibility/automation ID of the element
    • targetElementRef (string, optional): The accessibility/automation ID of the target element to drag to, default is null, indicating dragging to the center of the screen
    • duration (number, optional): The duration of the drag operation in milliseconds, default is 500

mobile_scroll_element

  • Description: Perform a scroll operation on the specified element.
  • Parameters:
    • elementRef (string): The accessibility/automation ID of the element
    • direction (string): The scroll direction, optional values are: UP, DOWN, LEFT, RIGHT
    • steps (number, optional): The number of scroll steps, default is 1

mobile_pinch_element

  • Description: Perform a pinch operation on the specified element.
  • Parameters:
    • elementRef (string): The accessibility/automation ID of the element
    • scaleFactor (number, optional): The scaling factor for pinching, ranging from (0,1), default is 0.5
    • duration (number, optional): The duration of the operation in milliseconds, default is 500

mobile_zoom_element

  • Description: Perform a zoom operation on the specified element.
  • Parameters:
    • elementRef (string): The accessibility/automation ID of the element
    • scaleFactor (number, optional): The scaling factor for zooming, ranging from (0,1) or (1, infinity), default is 2
    • duration (number, optional): The duration of the operation in milliseconds, default is 500

mobile_rotate_element

  • Description: Perform a rotation operation on the specified element.
  • Parameters:
    • elementRef (string): The accessibility/automation ID of the element
    • degrees (number, optional): The rotation angle, ranging from -180 to 180, default is 90
    • duration (number, optional): The duration of the operation in milliseconds, default is 500

mobile_tap_coordinates

  • Description: Perform a click operation at the specified coordinate position.
  • Parameters:
    • x (number): The x coordinate of the click
    • y (number): The y coordinate of the click

mobile_tap_elements

  • Description: Perform a click operation on a group of elements, clicking each element in sequence.
  • Parameters:
    • elements (array): An array of the accessibility/automation IDs of the elements
    • simultaneous (boolean, optional): Whether to click simultaneously, default is false

mobile_long_tap_coordinates

  • Description: Perform a long-press operation at the specified coordinate position.
  • Parameters:
    • x (number): The x coordinate of the long-press
    • y (number): The y coordinate of the long-press
    • duration (number, optional): The duration of the long-press in milliseconds, default is 500

mobile_swipe_coordinates

  • Description: Perform a swipe operation at the specified coordinate position.
  • Parameters:
    • startX (number): The x coordinate of the starting point
    • startY (number): The y coordinate of the starting point
    • endX (number): The x coordinate of the ending point
    • endY (number): The y coordinate of the ending point
    • duration (number, optional): The duration of the swipe operation in milliseconds, default is 500

mobile_swipe_elements

  • Description: Perform a swipe operation on a group of elements, swiping each element in sequence.
  • Parameters:
    • elements (array): An array of the accessibility/automation IDs of the elements
    • direction (string, optional): The swipe direction, default is RIGHT
    • simultaneous (boolean, optional): Whether to swipe simultaneously, default is false

mobile_drag_coordinates

  • Description: Perform a drag operation at the specified coordinate position.
  • Parameters:
    • startX (number): The x coordinate of the starting point of the drag
    • startY (number): The y coordinate of the starting point of the drag
    • endX (number): The x coordinate of the ending point of the drag
    • endY (number): The y coordinate of the ending point of the drag
    • duration (number, optional): The duration of the drag operation in milliseconds, default is 500

mobile_drag_elements

  • Description: Perform a drag operation on a group of elements, dragging each element in sequence.
  • Parameters:
    • startElements (array): An array of the accessibility/automation IDs of the starting elements
    • endElements (array): An array of the accessibility/automation IDs of the ending elements
    • simultaneous (boolean, optional): Whether to drag simultaneously, default is false

mobile_pinch_coordinates

  • Description: Perform a pinch operation at the specified coordinate position.
  • Parameters:
    • startX (number): The x coordinate of the starting point
    • startY (number): The y coordinate of the starting point
    • endX (number): The x coordinate of the ending point
    • endY (number): The y coordinate of the ending point
    • scaleFactor (number, optional): The scaling factor, default is 0.5
    • duration (number, optional): The duration of the operation in milliseconds, default is 500

mobile_pinch_elements

  • Description: Perform a pinch operation on a group of elements, pinching each element in sequence.
  • Parameters:
    • elements (array): An array of the accessibility/automation IDs of the elements
    • simultaneous (boolean, optional): Whether to pinch simultaneously, default is false

mobile_zoom_coordinates

  • Description: Perform a zoom operation at the specified coordinate position.
  • Parameters:
    • x (number): The x coordinate of the zoom
    • y (number): The y coordinate of the zoom
    • scaleFactor (number, optional): The scaling factor, default is 2
    • duration (number, optional): The duration of the operation in milliseconds, default is 500

mobile_zoom_elements

  • Description: Perform a zoom operation on a group of elements, zooming each element in sequence.
  • Parameters:
    • elements (array): An array of the accessibility/automation IDs of the elements
    • simultaneous (boolean, optional): Whether to zoom simultaneously, default is false

mobile_rotate_coordinates

  • Description: Perform a rotation operation at the specified coordinate position.
  • Parameters:
    • x (number): The x coordinate of the rotation
    • y (number): The y coordinate of the rotation
    • degrees (number, optional): The rotation angle, default is 90
    • duration (number, optional): The duration of the operation in milliseconds, default is 500

mobile_rotate_elements

  • Description: Perform a rotation operation on a group of elements, rotating each element in sequence.
  • Parameters:
    • elements (array): An array of the accessibility/automation IDs of the elements
    • degrees (number, optional): The rotation angle, default is 90
    • simultaneous (boolean, optional): Whether to rotate simultaneously, default is false

Notes:

  1. Keep the parameter names, types, and default values consistent with the examples, especially the handling of boolean parameters such as simultaneous.
  2. For each operation function, ensure that the format and data type of the input parameters are correct, and perform necessary parameter validation.
  3. Add more comments if necessary to explain complex functions or special cases.

Examples:

// Example: Use the mobile_tap_elements function to click two elements in sequence
var elements = ["element1", "element2"];
mobile_tap_elements(elements, true);

Task:

Write a JavaScript function library to implement various operations on the mobile device screen, including clicking, long-pressing, swiping, dragging, zooming, and rotating. Each function should support specifying coordinates or elements and be able to handle multiple operations simultaneously.

Requirements:

  1. Each function should have a clear functional description and provide examples.
  2. Keep the parameter names, types, and default values unified, especially the handling of boolean parameters such as simultaneous.
  3. Perform necessary parameter validation to ensure the correct format and data type of the input.
  4. Add comments to explain complex functions or special cases.

Example:

// Example: Use the mobile_tap_elements function to click two elements in sequence
var elements = ["element1", "element2"];
mobile_tap_elements(elements, true);

Solution:

// mobile_operations.js

// Define operation type constants
const OPERATION_TYPE = {
  TAP: 'tap',
  LONG_TAP: 'longTap',
  SWIPE: 'swipe',
  DRAG: 'drag',
  PINCH: 'pinch',
  ZOOM: 'zoom',
  ROTATE: 'rotate'
};

// Operation executor
class MobileOperations {
  constructor() {
    this.operations = [];
  }

  // Add an operation
  addOperation(type, params) {
    this.operations.push({ type, params });
    return this;
  }

  // Execute all operations
  execute(simultaneous = false) {
    if (simultaneous) {
      // Execute all operations simultaneously
      this.operations.forEach(op => this.executeOperation(op.type, op.params));
    } else {
      // Execute all operations sequentially
      this.operations.forEach(op => this.executeOperation(op.type, op.params));
    }
    return this;
  }

  // Execute a single operation
  executeOperation(type, params) {
    switch (type) {
      case OPERATION_TYPE.TAP:
        this.mobile_tap(params);
        break;
      case OPERATION_TYPE.LONG_TAP:
        this.mobile_long_tap(params);
        break;
      case OPERATION_TYPE.SWIPE:
        this.mobile_swipe(params);
        break;
      case OPERATION_TYPE.DRAG:
        this.mobile_drag(params);
        break;
      case OPERATION_TYPE.PINCH:
        this.mobile_pinch(params);
        break;
      case OPERATION_TYPE.ZOOM:
        this.mobile_zoom(params);
        break;
      case OPERATION_TYPE.ROTATE:
        this.mobile_rotate(params);
        break;
      default:
        throw new Error('Unknown operation type');
    }
  }

  // Tap operation
  mobile_tap(params) {
    const { x, y } = params;
    // Tap on the screen
    if (typeof x!== 'number' || typeof y!== 'number') {
      throw new Error('x and y must be numbers');
    }
    console.log(`Tap at coordinates (${x}, ${y})`);
  }

  // Long-tap operation
  mobile_long_tap(params) {
    const { x, y, duration = 500 } = params;
    // Long-tap on the screen for a specified duration
    if (typeof x!== 'number' || typeof y!== 'number') {
      throw new Error('x and y must be numbers');
    }
    console.log(`Long-tap at coordinates (${x}, ${y}) for ${duration} milliseconds`);
  }

  // Swipe operation
  mobile_swipe(params) {
    const { start, end, duration = 500 } = params;
    // Swipe from the starting point to the ending point
    if (typeof start.x!== 'number' || typeof start.y!== 'number') {
      throw new Error('start must have x and y coordinates');
    }
    if (typeof end.x!== 'number' || typeof end.y!== 'number') {
      throw new Error('end must have x and y coordinates');
    }
    console.log(`Swipe from (${start.x}, ${start.y}) to (${end.x}, ${end.y})`);
  }

  // Drag operation
  mobile_drag(params) {
    const { start, end, duration = 500 } = params;
    // Drag from the starting point to the ending point
    if (typeof start.x!== 'number' || typeof start.y!== 'number') {
      throw new Error('start must have x and y coordinates');
    }
    if (typeof end.x!== 'number' || typeof end.y!== 'number') {
      throw new Error('end must have x and y coordinates');
    }
    console.log(`Drag from (${start.x}, ${start.y}) to (${end.x}, ${end.y})`);
  }

  // Pinch operation
  mobile_pinch(params) {
    const { points, scale = 0.5, duration = 500 } = params;
    // Perform a pinch operation on the specified points
    if (!Array.isArray(points) || points.length!== 2) {
      throw new Error('points must be an array of two points');
    }
    console.log(`Perform a pinch operation on points ${JSON.stringify(points)} with a scaling factor of ${scale}`);
  }

  // Zoom operation
  mobile_zoom(params) {
    const { x, y, scale = 2, duration = 500 } = params;
    // Perform a zoom operation at the specified position
    if (typeof x!== 'number' || typeof y!== 'number') {
      throw new Error('x and y must be numbers');
    }
    console.log(`Perform a zoom operation at coordinates (${x}, ${y}) with a scaling factor of ${scale}`);
  }

  // Rotate operation
  mobile_rotate(params) {
    const { x, y, degrees = 90, duration = 500 } = params;
    // Perform a rotation operation at the specified position
    if (typeof x!== 'number' || typeof y!== 'number') {
      throw new Error('x and y must be numbers');
    }
    console.log(`Perform a rotation operation at coordinates (${x}, ${y}) with an angle of ${degrees} degrees`);
  }

  // Example of combined operations
  static exampleOperations() {
    const mo = new MobileOperations();
    
    // Tap operation
    mo.addOperation(OPERATION_TYPE.TAP, { x: 100, y: 200 });
    
    // Long-tap operation
    mo.addOperation(OPERATION_TYPE.LONG_TAP, { x: 300, y: 400, duration: 1000 });
    
    // Swipe operation
    mo.addOperation(OPERATION_TYPE.SWIPE, {
      start: { x: 50, y: 50 },
      end: { x: 250, y: 250 }
    });
    
    // Drag operation
    mo.addOperation(OPERATION_TYPE.DRAG, {
      start: { x: 100, y: 100 },
      end: { x: 300, y: 300 }
    });

    return mo;
  }

  // Execute example operations
  static executeExample() {
    const operations = this.exampleOperations();
    operations.execute();
  }
}

// Usage example
const mobileOperations = new MobileOperations();
mobileOperations.addOperation(MobileOperations.OPERATION_TYPE.TAP, { x: 100, y: 200 });
mobileOperations.addOperation(MobileOperations.OPERATION_TYPE.LONG_TAP, { x: 300, y: 400, duration: 1000 });
mobileOperations.execute();

Solution Code

class MobileOperations {
  constructor() {
    this.operations = [];
  }

  addOperation(type, params) {
    if (!this[type]) {
      throw new Error('Unknown operation type');
    }
    this.operations.push({ type, params });
    return this;
  }

  execute() {
    for (const op of this.operations) {
      this[op.type](op.params);
    }
    return this;
  }

  // Tap operation
  mobile_tap(params) {
    const { x, y } = params;
    if (typeof x!== 'number' || typeof y!== 'number') {
      throw new Error('x and y must be numbers');
    }
    console.log(`Tap at coordinates (${x}, ${y})`);
  }

  // Long-tap operation
  mobile_long_tap(params) {
    const { x, y, duration = 500 } = params;
    if (typeof x!== 'number' || typeof y!== 'number') {
      throw new Error('x and y must be numbers');
    }
    console.log(`Long-tap at coordinates (${x}, ${y}) for ${duration} milliseconds`);
  }

  // Swipe operation
  mobile_swipe(params) {
    const { start, end, duration = 500 } = params;
    if (typeof start.x!== 'number' || typeof start.y!== 'number') {
      throw new Error('start must have x and y coordinates');
    }
    if (typeof end.x!== 'number' || typeof end.y!== 'number') {
      throw new Error('end must have x and y coordinates');
    }
    console.log(`Swipe from (${start.x}, ${start.y}) to (${end.x}, ${end.y})`);
  }

  // Drag operation
  mobile_drag(params) {
    const { start, end, duration = 500 } = params;
    if (typeof start.x!== 'number' || typeof start.y!== 'number') {
      throw new Error('start must have x and y coordinates');
    }
    if (typeof end.x!== 'number' || typeof end.y!== 'number') {
      throw new Error('end must have x and y coordinates');
    }
    console.log(`Drag from (${start.x}, ${start.y}) to (${end.x}, ${end.y})`);
  }

  // Pinch operation
  mobile_pinch(params) {
    const { points, scale = 0.5, duration = 500 } = params;
    if (!Array.isArray(points)) {
      throw new Error('points must be an array');
    }
    console.log(`Perform a pinch operation with points ${JSON.stringify(points)} and a scaling factor of ${scale}`);
  }

  // Rotate operation
  mobile_rotate(params) {
    const { center, startAngle, endAngle, duration = 500 } = params;
    if (typeof center.x!== 'number' || typeof center.y!== 'number') {
      throw new Error('center must have x and y coordinates');
    }
    console.log(`Rotate from ${startAngle} degrees to ${endAngle} degrees centered at point (${center.x}, ${center.y})`);
  }

  // Execute example operations
  static example() {
    const operations = new MobileOperations()
      .addOperation('mobile_tap', { x: 100, y: 200 })
      .addOperation('mobile_long_tap', { x: 300, y: 400, duration: 1000 })
      .addOperation('mobile_swipe', {
        start: { x: 50, y: 50 },
        end: { x: 250, y: 250 }
      })
      .addOperation('mobile_drag', {
        start: { x: 100, y: 100 },
        end: { x: 300, y: 300 }
      })
      .addOperation('mobile_pinch', {
        points: [{ x: 150, y: 150 }, { x: 250, y: 250 }],
        scale: 0.8
      })
      .addOperation('mobile_rotate', {
        center: { x: 200, y: 200 },
        startAngle: 0,
        endAngle: 360
      });
    operations.execute();
  }
}

// Usage example
MobileOperations.example();

Explanation

This solution defines a MobileOperations class to manage various interaction operations on mobile devices. Each operation (such as tapping, long-tapping, swiping, etc.) is encapsulated as an independent method, and these operations can be added to a queue and executed sequentially through the execute() method.

The main features include:

  1. Modular design: Each operation is an independent method, which is easy to maintain and expand.
  2. Composability: Allows users to flexibly combine different operations to achieve complex interaction logic.
  3. Error handling: Parameter validation is performed in each method to ensure the correctness of the input.

In this way, developers can easily build and execute various interaction operations on mobile devices.

S
Search1api
The Search1API MCP Server is a server based on the Model Context Protocol (MCP), providing search and crawling functions, and supporting multiple search services and tools.
TypeScript
336
4 points
D
Duckduckgo MCP Server
Certified
The DuckDuckGo Search MCP Server provides web search and content scraping services for LLMs such as Claude.
Python
823
4.3 points
M
MCP Alchemy
Certified
MCP Alchemy is a tool that connects Claude Desktop to multiple databases, supporting SQL queries, database structure analysis, and data report generation.
Python
317
4.2 points
P
Postgresql MCP
A PostgreSQL database MCP service based on the FastMCP library, providing CRUD operations, schema inspection, and custom SQL query functions for specified tables.
Python
105
4 points
M
MCP Scan
MCP-Scan is a security scanning tool for MCP servers, used to detect common security vulnerabilities such as prompt injection, tool poisoning, and cross-domain escalation.
Python
609
5 points
A
Agentic Radar
Agentic Radar is a security scanning tool for analyzing and assessing agentic systems, helping developers, researchers, and security experts understand the workflows of agentic systems and identify potential vulnerabilities.
Python
548
5 points
C
Cloudflare
Changesets is a build tool for managing versions and releases in multi - package or single - package repositories.
TypeScript
1.5K
5 points
E
Edgeone Pages MCP Server
EdgeOne Pages MCP is a service that quickly deploys HTML content to EdgeOne Pages via the MCP protocol and obtains a public URL
TypeScript
250
4.8 points
Featured MCP Services
M
Markdownify MCP
Markdownify is a multi-functional file conversion service that supports converting multiple formats such as PDFs, images, audio, and web page content into Markdown format.
TypeScript
1.7K
5 points
D
Duckduckgo MCP Server
Certified
The DuckDuckGo Search MCP Server provides web search and content scraping services for LLMs such as Claude.
Python
823
4.3 points
G
Gitlab MCP Server
Certified
The GitLab MCP server is a project based on the Model Context Protocol that provides a comprehensive toolset for interacting with GitLab accounts, including code review, merge request management, CI/CD configuration, and other functions.
TypeScript
79
4.3 points
N
Notion Api MCP
Certified
A Python-based MCP Server that provides advanced to-do list management and content organization functions through the Notion API, enabling seamless integration between AI models and Notion.
Python
130
4.5 points
U
Unity
Certified
UnityMCP is a Unity editor plugin that implements the Model Context Protocol (MCP), providing seamless integration between Unity and AI assistants, including real - time state monitoring, remote command execution, and log functions.
C#
554
5 points
F
Figma Context MCP
Framelink Figma MCP Server is a server that provides access to Figma design data for AI programming tools (such as Cursor). By simplifying the Figma API response, it helps AI more accurately achieve one - click conversion from design to code.
TypeScript
6.6K
4.5 points
C
Context7
Context7 MCP is a service that provides real-time, version-specific documentation and code examples for AI programming assistants. It is directly integrated into prompts through the Model Context Protocol to solve the problem of LLMs using outdated information.
TypeScript
5.2K
4.7 points
M
Minimax MCP Server
The MiniMax Model Context Protocol (MCP) is an official server that supports interaction with powerful text-to-speech, video/image generation APIs, and is suitable for various client tools such as Claude Desktop and Cursor.
Python
745
4.8 points
AIbase
Zhiqi Future, Your AI Solution Think Tank
© 2025AIbase