Skip to main content
Glama
MCP SAP GUI Server

MCP SAP GUI Server

Servidor SAP GUI de MCP

Un servidor de Protocolo de Contexto de Modelo (MCP) para la automatización de SAP GUI. Este servidor proporciona herramientas para automatizar las interacciones con SAP GUI, lo que permite el control programático de las transacciones de SAP.

imagen

Requisitos

  • Python 3.8 o superior

  • SAP GUI instalado y configurado

  • Credenciales SAP válidas (sistema, cliente, usuario, contraseña)

  • Node.js (para npx)

Related MCP server: sapgui-mcp

Instalación

  1. Clonar la carpeta github y ejecutar la instalación automatizada usando el script de configuración:

setup.bat

Esto lo guiará a través del proceso de compilación y lo integrará directamente en Cline o Roo, si así lo selecciona.

  1. O Instalación manual mediante script de compilación..:

build.bat
  1. Configurar las credenciales de SAP:

  • Copiar .env.example a .env

  • Actualice los valores con sus credenciales de SAP

  1. Servidor de prueba usando el inspector mcp:

run.bat debug
  1. Utilice el script de integración para configurar automáticamente los ajustes de MCP:

integrate.bat cline  # Configure for Cline
integrate.bat roo    # Configure for Roo

El guión hará lo siguiente:

  • Determinar automáticamente la ruta correcta del archivo de configuración

  • Cree una copia de seguridad antes de realizar cualquier cambio

  • Actualice de forma segura la configuración de MCP

  • Validar los cambios para prevenir la corrupción

Configuración manual (si es necesario):

    "mcp-sap-gui": {
      "command": "python",
      "args": [
        "-m",
        "sap_gui_server.server"
      ],
      "cwd": "PATH_TO_YOUR_FOLDER/mcp-sap-gui",
      "disabled": false,
      "autoApprove": []
    }
  1. Utilice este mensaje para explicar la herramienta a su modelo de IA:

**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

Herramientas disponibles

El servidor SAP GUI de MCP proporciona las siguientes herramientas para la automatización de SAP:

Gestión de transacciones

  • launch_transaction : Iniciar un código de transacción de SAP específico

  • end_transaction : Finaliza la transacción SAP actual

Interacción de interfaz

  • sap_click : Haga clic en coordenadas específicas en la ventana de SAP GUI

  • sap_move_mouse : Mueve el cursor del ratón a coordenadas específicas

  • sap_type : Escribe texto en la posición actual del cursor

  • sap_scroll : desplazarse por la pantalla de SAP GUI (arriba/abajo)

Captura de pantalla

  • save_last_screenshot : Guarda la última captura de pantalla de la ventana de SAP GUI. Devuelve la ruta de acceso absoluta de la imagen guardada.

Formatos de retorno de captura de pantalla

Todas las herramientas que interactúan con la ventana SAP GUI (launch_transaction, sap_click, sap_move_mouse, sap_type, sap_scroll) admiten diferentes formatos de retorno de captura de pantalla controlados por el parámetro return_screenshot :

  1. none (predeterminado): solo devuelve mensajes de éxito/error

{
    "type": "text",
    "text": "Status: success"
}
  1. as_file : guarda la captura de pantalla en la carpeta de destino especificada y devuelve la ruta

{
    "type": "text",
    "text": "Screenshot saved as C:/path/to/file/screenshot.png"
}

Nota: Al usar as_file , debe especificar la carpeta de destino mediante el parámetro as_file_target_folder . La carpeta se creará si no existe.

  1. as_base64 : Devuelve la cadena base64 sin procesar

{
    "type": "text",
    "text": "base64_encoded_string_here"
}
  1. as_imagecontent : Devuelve el objeto ImageContent de MCP

{
    "type": "image",
    "data": "base64_encoded_string_here",
    "mimeType": "image/png"
}
  1. as_imageurl : Devuelve un recurso incrustado con la URL de datos

{
    "type": "resource",
    "resource": {
        "uri": "application:image",
        "mimeType": "image/png",
        "text": "data:image/png;base64,..."
    }
}

Ejemplo de uso:

# 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"
})

Resumen de parámetros de la herramienta:

Herramienta

Parámetro

Tipo

Por defecto

Descripción

launch_transaction

transaction

string

Código de transacción de SAP para el lanzamiento (por ejemplo, VA01, ME21N, MM03)

return_screenshot

string

none

Formato de retorno de captura de pantalla ( none , as_file , as_base64 , as_imagecontent , as_imageurl )

as_file_target_folder

string

Ruta de la carpeta de destino para guardar capturas de pantalla cuando se utiliza el formato de retorno 'as_file'

sap_click

x

integer

Coordenada de píxel horizontal (0-1920) donde debe producirse el clic

y

integer

Coordenada de píxel vertical (0-1080) donde debe ocurrir el clic

return_screenshot

string

none

Formato de retorno de captura de pantalla ( none , as_file , as_base64 , as_imagecontent , as_imageurl )

as_file_target_folder

string

Ruta de la carpeta de destino para guardar capturas de pantalla cuando se utiliza el formato de retorno 'as_file'

sap_move_mouse

x

integer

Coordenada de píxel horizontal (0-1920) para mover el cursor

y

integer

Coordenada de píxel vertical (0-1080) para mover el cursor

return_screenshot

string

none

Formato de retorno de captura de pantalla ( none , as_file , as_base64 , as_imagecontent , as_imageurl )

as_file_target_folder

string

Ruta de la carpeta de destino para guardar capturas de pantalla cuando se utiliza el formato de retorno 'as_file'

sap_type

text

string

Texto a introducir en la posición actual del cursor en la ventana de SAP GUI

return_screenshot

string

none

Formato de retorno de captura de pantalla ( none , as_file , as_base64 , as_imagecontent , as_imageurl )

as_file_target_folder

string

Ruta de la carpeta de destino para guardar capturas de pantalla cuando se utiliza el formato de retorno 'as_file'

sap_scroll

direction

string

Dirección para desplazarse por la pantalla ('arriba' mueve el contenido hacia abajo, 'abajo' lo mueve hacia arriba)

return_screenshot

string

none

Formato de retorno de captura de pantalla ( none , as_file , as_base64 , as_imagecontent , as_imageurl )

as_file_target_folder

string

Ruta de la carpeta de destino para guardar capturas de pantalla cuando se utiliza el formato de retorno 'as_file'

end_transaction

save_last_screenshot

filename

string

Ruta donde se guardará la captura de pantalla

Desarrollo

Ejecución de pruebas

  1. Servidor de prueba usando el inspector mcp (compilación + depuración):

./run.bat full
  1. O utilice el conjunto de pruebas: El conjunto de pruebas incluye pruebas en vivo que interactúan con SAP GUI. Asegúrese de tener SAP GUI instalado y configurado antes de ejecutar las pruebas.

Ejecutar pruebas:

run.bat test server

El conjunto de pruebas incluye:

  • Pruebas de SapGuiServer (test_server.py)

    • Registro de herramientas

    • Manejo de solicitudes

    • Formato de respuesta

    • Manejo de errores

Estructura del proyecto

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

Licencia

[Licencia 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