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
安装
克隆 github 文件夹并使用安装脚本运行自动安装:
setup.bat这将指导您完成构建过程,并将其直接集成到 Cline 或 Roo 中(如果您选择这样做)。
或使用构建脚本手动安装..:
build.bat配置 SAP 凭据:
将
.env.example复制到.env使用您的 SAP 凭证更新值
使用 mcp 检查器测试服务器:
run.bat debug使用集成脚本自动配置 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": []
}使用此提示向您的 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参数控制的不同屏幕截图返回格式:
none(默认值):仅返回成功/错误消息
{
"type": "text",
"text": "Status: success"
}as_file:将截图保存到指定的目标文件夹并返回路径
{
"type": "text",
"text": "Screenshot saved as C:/path/to/file/screenshot.png"
}注意:使用as_file时,必须使用as_file_target_folder参数指定目标文件夹。如果文件夹不存在,则会创建该文件夹。
as_base64:返回原始 base64 字符串
{
"type": "text",
"text": "base64_encoded_string_here"
}as_imagecontent:返回 MCP ImageContent 对象
{
"type": "image",
"data": "base64_encoded_string_here",
"mimeType": "image/png"
}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"
})工具参数摘要:
工具 | 范围 | 类型 | 默认 | 描述 |
|
|
| 要启动的 SAP 事务代码(例如 VA01、ME21N、MM03) | |
|
|
| 截图返回格式( | |
|
| 使用“as_file”返回格式时保存屏幕截图的目标文件夹路径 | ||
|
|
| 点击发生的水平像素坐标(0-1920) | |
|
| 点击发生的垂直像素坐标(0-1080) | ||
|
|
| 截图返回格式( | |
|
| 使用“as_file”返回格式时保存屏幕截图的目标文件夹路径 | ||
|
|
| 光标移动到的水平像素坐标(0-1920) | |
|
| 光标移动到的垂直像素坐标(0-1080) | ||
|
|
| 截图返回格式( | |
|
| 使用“as_file”返回格式时保存屏幕截图的目标文件夹路径 | ||
|
|
| 在 SAP GUI 窗口的当前光标位置输入的文本 | |
|
|
| 截图返回格式( | |
|
| 使用“as_file”返回格式时保存屏幕截图的目标文件夹路径 | ||
|
|
| 滚动屏幕的方向(“向上”使内容向下移动,“向下”使内容向上移动) | |
|
|
| 截图返回格式( | |
|
| 使用“as_file”返回格式时保存屏幕截图的目标文件夹路径 | ||
| ||||
|
|
| 屏幕截图保存的路径 |
发展
运行测试
使用 mcp 检查器测试服务器(构建 + 调试):
./run.bat full或者使用测试套件:测试套件包含与 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 toolsend_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_screenARead-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
Scored across 12 tools
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.
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.
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.
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
Related MCP Connectors
Browser automation MCP for whole web tasks in a cloud browser: saved logins, bot checks, replays.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Web scraping, browser automation, screenshots and AI data extraction for AI agents via MCP.
Build and run AI workflows, agents, data tables and 1000+ API integrations from any MCP client.
Related MCP Servers
- AlicenseAqualityBmaintenanceAn MCP server that enables AI assistants to interact with SAP GUI for Windows through the SAP GUI Scripting API.61505 PyPI61MIT
- AlicenseAqualityBmaintenanceEnables 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.1MIT
- AlicenseNot gradedqualityCmaintenanceEnables Windows GUI automation through the Model Context Protocol, providing tools, workflows, and generative capabilities for natural language-driven interaction with desktop applications.MIT
- AlicenseNot gradedqualityCmaintenanceEnables 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