Skip to main content
Glama

MCP Appium Server

by Rahulec08

MCP Appium サーバー

Appium を使用したモバイル アプリ自動化のためのモデル コンテキスト プロトコル (MCP) サーバー実装。

前提条件

  1. Node.js (v14以上)
  2. Java開発キット(JDK)
  3. Android SDK(Android テスト用)
  4. Xcode (iOS テスト用、macOS のみ)
  5. Appiumサーバー
  6. Androidデバイスまたはエミュレータ / iOSデバイスまたはシミュレータ

環境設定

コマンドを実行する前に、環境変数が適切に設定されていることを確認してください。

  1. .bash_profile.zshrc 、またはその他のシェル構成ファイルに必要な環境変数が含まれていることを確認します。
# 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 の実際のデバイスをテストする場合は、Xcode で Apple Developer アカウントが適切に設定されていることを確認してください。
    • Xcodeを開く
    • 「設定」>「アカウント」へ移動
    • Apple IDをまだ追加していない場合は追加してください
    • 必要なプロビジョニングプロファイルをダウンロードする
  2. 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を使用してデバイスが接続されていることを確認する
  2. 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デバイスに合わせて更新します
    • APKファイルへのappを設定するか、
    • インストールされたアプリのappPackageappActivityを更新する
  2. 共通機能の構成:
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 で要素までスクロールする
    • 長押し
  2. アプリ管理:
    • アプリを起動/閉じる
    • アプリをリセット
    • 現在のパッケージ/アクティビティを取得する
  3. デバイスコントロール:
    • 画面の向き
    • キーボード操作
    • デバイスのロック/ロック解除
    • スクリーンショット
    • バッテリー情報
  4. 高度な機能:
    • コンテキスト切り替え(ネイティブ/WebView)
    • ファイル操作
    • 通知
    • カスタムジェスチャー
  5. Xcode コマンドラインツール (iOS のみ):
    • iOS シミュレーターの管理 (起動、シャットダウン)
    • シミュレータ上でのアプリのインストール/アンインストール
    • アプリの起動/終了
    • スクリーンショットを撮る
    • ビデオを録画する
    • シミュレータの作成/削除
    • デバイスの種類とランタイムを取得する

W3C標準ジェスチャー

MCP-Appium ライブラリは、モバイル自動化の最新標準であるタッチ ジェスチャ用の W3C WebDriver Actions API を実装するようになりました。

タップ要素のW3Cアクション

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 ジェスチャー

executeMobileCommandメソッドを使用して、独自のカスタム W3C ジェスチャを作成できます。

// 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]);

W3C 標準ジェスチャ実装の詳細な例についてはexamples/w3c-actions-swipe-demo.ts参照してください。

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デバッグが有効になっていることを確認する
    • デバイスを再接続してみてください
  2. アプリがインストールされません:
    • APKパスが正しいことを確認する
    • デバイスに十分なストレージがあるか確認する
    • アプリがデバッグ用に署名されていることを確認する
  3. 要素が見つかりません:
    • Appium Inspectorを使用してセレクタを検証する
    • 画面上に要素が表示されているかどうかを確認する
    • さまざまなロケーター戦略を試す
  4. 接続の問題:
    • Appiumサーバーが実行中であることを確認する
    • ポートの競合を確認する
    • 正しい機能が設定されていることを確認する
  5. iOS シミュレータの問題:
    • Xcodeコマンドラインツールがインストールされていることを確認します: xcode-select -p
    • xcrun simctl list devicesを使用してシミュレータのUDIDが正しいことを確認します。
    • シミュレータが応答しなくなった場合は閉じて再起動してください

貢献

追加機能やバグ修正に関する問題やプル リクエストをお気軽に送信してください。

ライセンス

マサチューセッツ工科大学

Install Server
A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

local-only server

The server can only run on the client's local machine because it depends on local resources.

Appium を使用してモバイル アプリの自動化を可能にし、標準化されたプロトコルを通じてさまざまなデバイスのインタラクション、要素の操作、アプリの管理をサポートするモデル コンテキスト プロトコル (MCP) サーバーです。

  1. 前提条件
    1. 環境設定
      1. Xcode コマンドラインツールの設定
    2. 設定
      1. テストの実行
        1. テスト構成
          1. Androidの設定
          2. iOS 設定
        2. 利用可能なアクション
          1. W3C標準ジェスチャー
            1. タップ要素のW3Cアクション
            2. スクロールのためのW3Cアクション
            3. カスタム W3C ジェスチャー
          2. Xcodeコマンドラインツールの使用
            1. クリック機能の使用
              1. トラブルシューティング
                1. 貢献
                  1. ライセンス

                    Related MCP Servers

                    • -
                      security
                      F
                      license
                      -
                      quality
                      A Model Context Protocol (MCP) server implementation for interacting with Phabricator API. This server allows LLMs to interact with Phabricator through a standardized interface.
                      Last updated -
                      5
                      Python
                    • A
                      security
                      A
                      license
                      A
                      quality
                      A beginner-friendly Model Context Protocol (MCP) server that helps users understand MCP concepts, provides interactive examples, and lists available MCP servers. This server is designed to be a helpful companion for developers working with MCP. Also comes with a huge list of servers you can install.
                      Last updated -
                      3
                      9
                      36
                      JavaScript
                      Apache 2.0
                    • -
                      security
                      A
                      license
                      -
                      quality
                      This MCP server implementation allows users to manage and expose actions as tools from their Integration App workspace through the Model Context Protocol.
                      Last updated -
                      10
                      22
                      TypeScript
                      ISC License
                    • A
                      security
                      F
                      license
                      A
                      quality
                      A Model Context Protocol (MCP) server that interacts with system APIs, allowing users to check connections, search employees, register breakfast, and update chemical information by shifts.
                      Last updated -
                      21
                      26
                      JavaScript

                    View all related MCP servers

                    MCP directory API

                    We provide all the information about MCP servers via our MCP API.

                    curl -X GET 'https://glama.ai/api/mcp/v1/servers/Rahulec08/appium-mcp'

                    If you have feedback or need assistance with the MCP directory API, please join our Discord server