Token导航 LogoToken导航TokenDH.com
MCP Appium Server logo
开发工具未说明官方级别未说明来源级核验

MCP Appium Server

MCP Server

MCP SERVER for appium

工具数

0

提示词数

0

GitHub Stars

62

资源数

0
TypeScript开发工具命令行工具

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

Rahulec08

提供方

Rahulec08

最后核验

2026/5/18 02:51

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

Build ](https://www.npmjs.com/package/mcp-appium-visual) ![License](LICENSE) ![Issues](https://github.com/Rahulec08/appium-mcp/issues) ![Last Commit](https://github.com/Rahulec08/appium-mcp/commits/main)

mcp-appium-visual 是一个集成了模型上下文协议(MCP)的AI驱动的移动自动化平台。它通过Appium实现了对Android和iOS设备的无缝控制,具有智能视觉元素检测和恢复功能。

特性

  • 与Appium集成以实现设备控制
  • 视觉元素检测和恢复(基于AI)
  • MCP支持高级代理驱动的测试工作流程
  • 支持Android和iOS平台
  • 专为与AI代理配合使用而设计,实现智能自动化

先决条件

  1. Node.js(v14或更高版本)
  2. Java开发工具包(JDK)
  3. Android SDK(用于Android测试)
  4. Xcode(用于iOS测试,仅限macOS)
  5. Appium服务器
  6. 安卓设备或模拟器/iOS设备或模拟器

环境设置

在执行任何命令之前,请确保您的环境变量已正确设置:

  1. 确保你的 .bash_profile, .zshrc 或其他shell配置文件包含必要的环境变量:
# Example environment variables in ~/.bash_profile
export JAVA_HOME=/path/to/your/java
export ANDROID_HOME=/path/to/your/android/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
  1. 在运行MCP Appium之前获取环境文件:
source ~/.bash_profile  # For bash
# OR
source ~/.zshrc         # For zsh
备注:系统将尝试获取您的 .bash_profile 初始化驱动程序时会自动执行,但建议在新的终端会话中运行测试之前手动确保正确的环境设置。

Xcode命令行工具配置

对于iOS测试,正确的Xcode命令行工具配置至关重要:

  1. 如果尚未安装Xcode命令行工具,请安装:
xcode-select --install
  1. 验证安装并检查当前Xcode路径:
xcode-select -p
  1. 如果需要,请设置正确的Xcode路径(特别是如果您有多个Xcode版本):
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
  1. 接受Xcode许可协议:
sudo xcodebuild -license accept
  1. 对于iOS真实设备测试,请确保您的Apple Developer帐户在Xcode中配置正确:

- 打开Xcode - 转到“首选项”>“帐户” - 如果尚未添加,请添加您的Apple ID - 下载必要的配置文件

  1. 为iOS开发设置环境变量:
# Add these to your ~/.bash_profile or ~/.zshrc
export DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer"
export PATH="$DEVELOPER_DIR/usr/bin:$PATH"
  1. 获取更新的配置:
source ~/.bash_profile  # For bash
# OR
source ~/.zshrc         # For zsh

设置

  1. 安装依赖项:
npm install
  1. 安装并启动Appium服务器:
npm install -g appium
appium
  1. 设置Android设备/模拟器:

- 在您的Android设备上启用开发人员选项 - 启用USB调试 - 通过USB连接设备或启动模拟器 - 使用验证设备是否已连接 adb devices

  1. 对于iOS测试(仅限macOS):

- 确保安装了Xcode命令行工具: xcode-select --install - 设置iOS模拟器或连接真实设备 - 如果使用真实设备,请信任iOS设备上的开发计算机

运行测试

  1. 构建项目:
npm run build
  1. 启动MCP服务器:
npm run dev
  1. 在新终端中,运行测试:
npm test

测试配置

Android配置

示例测试使用Android设置应用程序作为演示。要测试自己的应用程序:

  1. 编辑 examples/appium-test.ts:

- 更新 deviceName 匹配您的设备 - 集 app APK文件的路径,或 - 更新 appPackageappActivity 对于已安装的应用程序

  1. 通用功能配置:
const capabilities: AppiumCapabilities = {
  platformName: "Android",
  deviceName: "YOUR_DEVICE_NAME",
  automationName: "UiAutomator2",
  // For installing and testing an APK:
  app: "./path/to/your/app.apk",
  // OR for testing an installed app:
  appPackage: "your.app.package",
  appActivity: ".MainActivity",
  noReset: true,
};

iOS配置

对于使用新Xcode命令行支持的iOS测试:

  1. 示例配置 examples/xcode-appium-example.ts:
const capabilities: AppiumCapabilities = {
  platformName: "iOS",
  deviceName: "iPhone 13", // Your simulator or device name
  automationName: "XCUITest",
  udid: "DEVICE_UDID", // Get this from XcodeCommands.getIosSimulators()
  // For installing and testing an app:
  app: "./path/to/your/app.app",
  // OR for testing an installed app:
  bundleId: "com.your.app",
  noReset: true,
};

可用操作

MCP服务器支持各种Appium操作:

  1. 元素交互:

- 查找元素 - 使用W3C Actions API点击/点击元素(请参阅“W3C标准手势”部分) - 键入文本 - 使用W3C Actions API滚动到元素 - 长按

  1. 应用程序管理:

- 启动/关闭应用程序 - 重置应用程序 - 获取当前包/活动

  1. 设备控制:

- 屏幕方向 - 键盘操作 - 设备锁定/解锁 - 截图 - 电池信息

  1. 高级功能:

- 上下文切换(原生/WebView) - 文件 操作 - 通知 - 自定义手势

  1. Xcode命令行工具(仅限iOS):

- 管理iOS模拟器(启动、关闭) - 在模拟器上安装/卸载应用程序 - 启动/终止应用程序 - 截图 - 录制视频 - 创建/删除模拟器 - 获取设备类型和运行时

W3C标准手势

MCP-Appium库现在实现了用于触摸手势的W3C WebDriver Actions API,这是移动自动化的现代标准。

W3C对Tap元素的操作

tapElement 方法现在使用W3C Actions API进行智能回退:

// The method will try in this order:
// 1. Standard WebdriverIO click()
// 2. W3C Actions API
// 3. Legacy TouchAction API (fallback for backward compatibility)
await appium.tapElement("//android.widget.Button[@text='OK']");
// or using the click alias
await appium.click("//android.widget.Button[@text='OK']");

W3C滚动操作

scrollToElement 方法现在使用W3C Actions API:

// Uses W3C Actions API for more reliable scrolling
await appium.scrollToElement(
  "//android.widget.TextView[@text='About phone']", // selector
  "down", // direction: "up", "down", "left", "right"
  "xpath", // strategy
  10 // maxScrolls
);

自定义W3C手势

您可以使用以下命令创建自己的自定义W3C手势 executeMobileCommand 方法:

// Create custom W3C Actions API gesture
const w3cActions = {
  actions: [
    {
      type: "pointer",
      id: "finger1",
      parameters: { pointerType: "touch" },
      actions: [
        // Move to start position
        { type: "pointerMove", duration: 0, x: startX, y: startY },
        // Press down
        { type: "pointerDown", button: 0 },
        // Move to end position over duration milliseconds
        {
          type: "pointerMove",
          duration: duration,
          origin: "viewport",
          x: endX,
          y: endY,
        },
        // Release
        { type: "pointerUp", button: 0 },
      ],
    },
  ],
};

// Execute the W3C Actions using executeScript
await appium.executeMobileCommand("performActions", [w3cActions.actions]);

examples/w3c-actions-swipe-demo.ts 了解W3C标准手势实现的更多示例。

使用Xcode命令行工具

新的 XcodeCommands 类为iOS测试提供了强大的工具:

import { XcodeCommands } from "../src/lib/xcode/xcodeCommands.js";

// Check if Xcode CLI tools are installed
const isInstalled = await XcodeCommands.isXcodeCliInstalled();

// Get available simulators
const simulators = await XcodeCommands.getIosSimulators();

// Boot a simulator
await XcodeCommands.bootSimulator("SIMULATOR_UDID");

// Install an app
await XcodeCommands.installApp("SIMULATOR_UDID", "/path/to/app.app");

// Launch an app
await XcodeCommands.launchApp("SIMULATOR_UDID", "com.example.app");

// Take a screenshot
await XcodeCommands.takeScreenshot("SIMULATOR_UDID", "/path/to/output.png");

// Shutdown a simulator
await XcodeCommands.shutdownSimulator("SIMULATOR_UDID");

使用点击功能

click() 该方法提供了一种更直观的替代方案 tapElement():

// Using the click method
await appium.click("//android.widget.Button[@text='OK']");

// This is equivalent to:
await appium.tapElement("//android.widget.Button[@text='OK']");

故障排除

  1. 未找到设备:

- 检查 adb devices 输出 - 验证USB调试是否已启用 - 尝试重新连接设备

  1. 应用程序未安装:

- 验证APK路径是否正确 - 检查设备是否有足够的存储空间 - 确保应用程序已签名以进行调试

  1. 未找到元素:

- 使用Appium检查器验证选择器 - 检查屏幕上是否可见元素 - 尝试不同的定位器策略

  1. 连接问题:

- 验证Appium服务器是否正在运行 - 检查端口冲突 - 确保设置了正确的功能

  1. iOS模拟器问题:

- 验证Xcode命令行工具是否已安装: xcode-select -p - 使用以下工具检查模拟器UDID是否正确 xcrun simctl list devices - 如果模拟器变得无响应,请关闭并重新启动模拟器

贡献

请随时提交问题,并提取对其他功能或错误修复的请求。

许可证

麻省理工学院

目录标签

目录标签

TypeScript开发工具命令行工具developer-tools移动自动化本地部署Appium集成视觉检测AI测试跨平台测试

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

none

部署方式(deploymentType,部署类型)

local-only

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明nonelocal-only

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP