Skip to main content
Glama
MCP SAP GUI Server

MCP SAP GUI Server

MCP SAP GUI 服务器

用于 SAP GUI 自动化的模型上下文协议 (MCP) 服务器。该服务器提供用于自动化与 SAP GUI 交互的工具,从而支持对 SAP 事务进行编程控制。

图像

要求

  • Python 3.8 或更高版本

  • SAP GUI 安装和配置

  • 有效的 SAP 凭证(系统、客户端、用户、密码)

  • Node.js(用于 npx)

Related MCP server: sapgui-mcp

安装

  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_transaction

transaction

string

要启动的 SAP 事务代码(例如 VA01、ME21N、MM03)

return_screenshot

string

none

截图返回格式( none 、 as_file 、 as_base64 、 as_imagecontent 、 as_imageurl )

as_file_target_folder

string

使用“as_file”返回格式时保存屏幕截图的目标文件夹路径

sap_click

x

integer

点击发生的水平像素坐标(0-1920)

y

integer

点击发生的垂直像素坐标(0-1080)

return_screenshot

string

none

截图返回格式( none 、 as_file 、 as_base64 、 as_imagecontent 、 as_imageurl )

as_file_target_folder

string

使用“as_file”返回格式时保存屏幕截图的目标文件夹路径

sap_move_mouse

x

integer

光标移动到的水平像素坐标(0-1920)

y

integer

光标移动到的垂直像素坐标(0-1080)

return_screenshot

string

none

截图返回格式( none 、 as_file 、 as_base64 、 as_imagecontent 、 as_imageurl )

as_file_target_folder

string

使用“as_file”返回格式时保存屏幕截图的目标文件夹路径

sap_type

text

string

在 SAP GUI 窗口的当前光标位置输入的文本

return_screenshot

string

none

截图返回格式( none 、 as_file 、 as_base64 、 as_imagecontent 、 as_imageurl )

as_file_target_folder

string

使用“as_file”返回格式时保存屏幕截图的目标文件夹路径

sap_scroll

direction

string

滚动屏幕的方向(“向上”使内容向下移动,“向下”使内容向上移动)

return_screenshot

string

none

截图返回格式( none 、 as_file 、 as_base64 、 as_imagecontent 、 as_imageurl )

as_file_target_folder

string

使用“as_file”返回格式时保存屏幕截图的目标文件夹路径

end_transaction

save_last_screenshot

filename

string

屏幕截图保存的路径

发展

运行测试

  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许可证]

Available Tools

12 tools
end_transactionA

End only the configured session's current transaction. Unsaved work in that transaction can be lost.

Inputs: no named parameters.

launch_transactionC

Start a transaction in the configured session; preserves unrelated SAP sessions.

Inputs: transaction (required), return_screenshot, as_file_target_folder.

sap_clickC

Click physical screenshot pixels relative to the selected SAP window.

Inputs: x (required), y (required), return_screenshot, as_file_target_folder.

sap_get_screenA
Read-only

Read up to 300 SAP COM controls and text (password fields redacted), optionally with screenshot.

Inputs: return_screenshot, as_file_target_folder.

sap_move_mouseC

Move within the selected SAP window using physical screenshot pixels.

Inputs: x (required), y (required), return_screenshot, as_file_target_folder.

sap_pressC

Press a SAP GUI button through its COM interface.

Inputs: element_id (required).

sap_run_guixt_scriptA

Submit a preinstalled GuiXT InputScript to this exact SAP window; requires configured GuiXT opt-in. Completion is asynchronous.

Inputs: script (required).

sap_scrollC

Scroll the selected SAP window.

Inputs: direction (required), return_screenshot, as_file_target_folder.

sap_send_vkeyC

Send a documented SAP virtual key (0 is Enter) to the configured session.

Inputs: key (required).

sap_set_fieldC

Set literal text through SAP GUI ActiveX/COM scripting, scoped to wnd[N] in this session.

Inputs: text (required), element_id (required).

sap_typeA

Type WScript SendKeys text/special keys in the selected SAP window. Use sap_set_field for literal text.

Inputs: text (required), return_screenshot, as_file_target_folder.

save_last_screenshotB

Save the last requested screenshot under SAP_OUTPUT_ROOT without overwriting a file.

Inputs: filename (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 12 tools

    Disambiguation4/5

    Most tools target distinct actions (pixel click, mouse move, scroll, transaction lifecycle, COM field set, button press, virtual key, screenshot). Two pairs overlap somewhat: sap_type vs sap_set_field for entering text, and sap_press vs sap_send_vkey for triggering controls; descriptions mitigate by recommending COM for literal text and documenting vkey behavior.

    Naming Consistency4/5

    All names use snake_case and mostly follow a verb_noun pattern, with a consistent sap_ prefix on interaction tools. However, three lifecycle/screenshot tools (launch_transaction, end_transaction, save_last_screenshot) omit the sap_ prefix, a minor inconsistency.

    Tool Count5/5

    Twelve tools is well-scoped for a GUI automation server: transaction lifecycle, screen reading, several input modalities, screenshots, and GuiXT scripting each earn a place without obvious redundancy.

    Completeness4/5

    The surface covers core GUI automation: transaction start/end, screen scraping, pixel and COM input, scrolling, screenshots, and GuiXT scripting. Minor gaps remain for explicit window selection, waiting for screen readiness, and targeted field value extraction, but agents can work around these with existing tools.

    Maintenance

    ActivityStale
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      An MCP server that enables AI assistants to interact with SAP GUI for Windows through the SAP GUI Scripting API.
      61
      505 PyPI
      61
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI agents to execute SAP tasks through a cost-routing MCP server that tries API, recorded scripts, WebGUI, and computer-use vision in cheapest-first order, falling back only when needed. It can also promote an interactive GUI routine into a reusable recorded script to make repeat runs nearly free.
      1
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables Windows GUI automation through the Model Context Protocol, providing tools, workflows, and generative capabilities for natural language-driven interaction with desktop applications.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI assistants to drive SAP GUI for Windows through the SAP GUI Scripting API — connecting to systems, running transactions, reading and writing screen fields, extracting ALV grid, table, tree, and report-list data, and capturing screenshots. Includes server-enforced confirmation points and previews so nothing is written to SAP without explicit user approval.
      MIT