MCP SAP GUI Server

by mario-andreschak
Verified

local-only server

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

Integrations

  • Provides tools to automate interactions with SAP GUI, enabling programmatic control of SAP transactions including launching transactions, clicking at coordinates, moving the mouse, typing text, and scrolling the SAP GUI screen.

MCP SAP GUI サーバー

SAP GUI自動化のためのモデルコンテキストプロトコル(MCP)サーバー。このサーバーは、SAP GUIとのやり取りを自動化するツールを提供し、SAPトランザクションのプログラムによる制御を可能にします。

要件

  • Python 3.8以上
  • SAP GUIがインストールおよび設定されている
  • 有効な SAP 資格情報 (システム、クライアント、ユーザー、パスワード)
  • Node.js (npx 用)

インストール

  1. github フォルダーを複製し、セットアップ スクリプトを使用して自動インストールを実行します。
setup.bat

これにより、ビルド プロセスがガイドされ、選択した場合は Cline または Roo に直接統合されます。

  1. またはビルド スクリプトを使用して手動でインストールします。
build.bat
  1. SAP 資格情報を構成します。
  • .env.example.envにコピーする
  • SAP資格情報で値を更新します
  1. mcp インスペクタを使用したテストサーバー:
run.bat debug
  1. 統合スクリプトを使用して、MCP 設定を自動的に構成します。
integrate.bat cline # Configure for Cline integrate.bat roo # Configure for Roo

スクリプトは次のようになります。

  • 正しい設定ファイルのパスを自動的に決定する
  • 変更を加える前にバックアップを作成してください
  • MCP構成を安全に更新する
  • 破損を防ぐために変更を検証する

手動構成(必要な場合):

"mcp-sap-gui": { "command": "python", "args": [ "-m", "sap_gui_server.server" ], "cwd": "PATH_TO_YOUR_FOLDER/mcp-sap-gui", "disabled": false, "autoApprove": [] }
  1. このプロンプトを使用して、AI モデルにツールを説明します。
**Important Safety Notice:** SAP is a highly sensitive system where incorrect interactions can have serious consequences. Every action must be performed with utmost precision and care. When in doubt about any action, STOP immediately and request user assistance. **Available Tools:** The `mcp-sap-gui` server provides tools for SAP GUI interaction: * `launch_transaction`: Start a new transaction * `sap_click`: Click at specific coordinates * `sap_move_mouse`: Move mouse to coordinates * `sap_type`: Enter text into fields * `end_transaction`: Close the current transaction **Technical Limitations and Requirements:** 1. You will receive only screenshot images of the SAP GUI window after each action 2. No direct access to screen element metadata or technical representation 3. You must use image recognition to: * Identify UI elements (fields, buttons, etc.) * Determine precise x/y coordinates for interactions * Verify element sizes and positions 4. All coordinates must be exact - approximate clicking is not acceptable **Step-by-Step Process:** 1. Start SAP GUI Session: * Call `launch_transaction` with desired transaction code * Analyze the returned screenshot carefully 2. Interact with Screen: * Use image recognition to identify needed elements * Calculate exact coordinates for interaction * Execute appropriate action (`sap_click`, `sap_type`, etc.) * Verify result in next screenshot 3. Capture Screenshots: * Save screenshots at key points in the process 4. End Session: * Call `end_transaction` when finished **Best Practices:** 1. Always verify screen state before any action 2. Double-check coordinates before clicking 3. Document each step with clear annotations 4. If uncertain about any element position, request user verification 5. Maintain consistent screenshot naming convention

利用可能なツール

MCP SAP GUI サーバーは、SAP 自動化用の次のツールを提供します。

トランザクション管理

  • launch_transaction : 特定のSAPトランザクションコードを起動する
  • end_transaction : 現在のSAPトランザクションを終了する

インターフェースの相互作用

  • sap_click : SAP GUIウィンドウ内の特定の座標をクリックします
  • sap_move_mouse : マウスカーソルを特定の座標に移動する
  • sap_type : 現在のカーソル位置にテキストを入力します
  • sap_scroll : SAP GUI画面をスクロールする(上/下)

スクリーンキャプチャ

  • save_last_screenshot : SAP GUIウィンドウの最後にキャプチャしたスクリーンショットを保存します。保存された画像の絶対ファイルパスを返します。

スクリーンショットの返却形式

SAP GUI ウィンドウと対話するすべてのツール (launch_transaction、sap_click、sap_move_mouse、sap_type、sap_scroll) は、 return_screenshotパラメータによって制御されるさまざまなスクリーンショットの戻り形式をサポートしています。

  1. none (デフォルト): 成功/エラーメッセージのみを返します
{ "type": "text", "text": "Status: success" }
  1. as_file : スクリーンショットを指定されたターゲットフォルダに保存し、パスを返します。
{ "type": "text", "text": "Screenshot saved as C:/path/to/file/screenshot.png" }

注: as_fileを使用する場合は、 as_file_target_folderパラメータを使用してターゲットフォルダを指定する必要があります。フォルダが存在しない場合は作成されます。

  1. as_base64 : 生のbase64文字列を返す
{ "type": "text", "text": "base64_encoded_string_here" }
  1. as_imagecontent : MCP ImageContentオブジェクトを返します
{ "type": "image", "data": "base64_encoded_string_here", "mimeType": "image/png" }
  1. as_imageurl : データ URL を含む埋め込みリソースを返します。
{ "type": "resource", "resource": { "uri": "application:image", "mimeType": "image/png", "text": "data:image/png;base64,..." } }

使用例:

# Default - no screenshot result = await client.call_tool("launch_transaction", { "transaction": "VA01" }) # Save to specific folder result = await client.call_tool("launch_transaction", { "transaction": "VA01", "return_screenshot": "as_file", "as_file_target_folder": "C:/screenshots" }) # Get base64 string result = await client.call_tool("launch_transaction", { "transaction": "VA01", "return_screenshot": "as_base64" })

ツールパラメータの概要:

道具パラメータタイプデフォルト説明
launch_transactiontransactionstring起動するSAPトランザクションコード(例:VA01、ME21N、MM03)
return_screenshotstringnoneスクリーンショットの返される形式 ( noneas_fileas_base64as_imagecontentas_imageurl )
as_file_target_folderstring'as_file' 戻り形式を使用する場合のスクリーンショットの保存先フォルダ パス
sap_clickxintegerクリックが発生する水平ピクセル座標(0~1920)
yintegerクリックが発生する垂直ピクセル座標(0~1080)
return_screenshotstringnoneスクリーンショットの返される形式 ( noneas_fileas_base64as_imagecontentas_imageurl )
as_file_target_folderstring'as_file' 戻り形式を使用する場合のスクリーンショットの保存先フォルダ パス
sap_move_mousexintegerカーソルを移動する水平ピクセル座標(0~1920)
yintegerカーソルを移動する垂直ピクセル座標(0~1080)
return_screenshotstringnoneスクリーンショットの戻り形式 ( noneas_fileas_base64as_imagecontentas_imageurl )
as_file_target_folderstring'as_file' 戻り形式を使用する場合のスクリーンショットの保存先フォルダ パス
sap_typetextstringSAP GUIウィンドウの現在のカーソル位置に入力するテキスト
return_screenshotstringnoneスクリーンショットの戻り形式 ( noneas_fileas_base64as_imagecontentas_imageurl )
as_file_target_folderstring'as_file' 戻り形式を使用する場合のスクリーンショットの保存先フォルダ パス
sap_scrolldirectionstring画面をスクロールする方向(「上」でコンテンツが下に移動し、「下」で上に移動します)
return_screenshotstringnoneスクリーンショットの戻り形式 ( noneas_fileas_base64as_imagecontentas_imageurl )
as_file_target_folderstring'as_file' 戻り形式を使用する場合のスクリーンショットの保存先フォルダ パス
end_transaction
save_last_screenshotfilenamestringスクリーンショットを保存するパス

発達

テストの実行

  1. mcp インスペクタを使用したテスト サーバー (ビルド + デバッグ):
./run.bat full
  1. または、テストスイートを使用します。テストスイートには、SAP GUIと連携するライブテストが含まれています。テストを実行する前に、SAP GUIがインストールおよび設定されていることを確認してください。

テストを実行します:

run.bat test server

テスト スイートには次のものが含まれます。

  • SapGuiServer テスト (test_server.py)
    • ツール登録
    • リクエスト処理
    • 応答のフォーマット
    • エラー処理

プロジェクト構造

mcp-sap-gui/ ├── src/ │ └── sap_gui_server/ │ ├── __init__.py │ ├── sap_controller.py # SAP GUI interaction logic │ └── server.py # MCP server implementation ├── tests/ │ ├── __init__.py │ ├── test_sap_controller.py │ └── test_server.py ├── build.bat # Build and test script ├── integrate.bat # Integration script for Cline/Roo ├── integrate.py # Python script for safe MCP settings updates ├── requirements.txt # Production dependencies └── requirements-dev.txt # Development dependencies

ライセンス

[MITライセンス]

-
security - not tested
A
license - permissive license
-
quality - not tested

モデル コンテキスト プロトコルを使用して SAP GUI とのやり取りを自動化し、クリック、入力、スクロール、トランザクション管理などのツールを通じて SAP トランザクションを正確に制御できるようにします。

  1. Requirements
    1. Installation
      1. Available Tools
        1. Transaction Management
        2. Interface Interaction
        3. Screen Capture
        4. Screenshot Return Formats
      2. Development
        1. Running Tests
      3. Project Structure
        1. License
          ID: jrsv7188i3