kts982/mcp-sap-gui
SAP GUI for Windows through the Scripting API, deliberately client-agnostic, with CI, docs, a dependency audit and tagged releases wired up around it.
Takes the same Scripting API and puts release engineering around it: workflows for CI, documentation, dependency auditing and tag-based releases, and a README that says the Claude examples are only examples — anything that can launch a local stdio server works, Codex, Copilot and Gemini CLI included. Same author as sap-odata-explorersap-odata-explorerA Rust CLI and desktop app for exploring and testing SAP OData services against real systems — catalog discovery, metadata browsing, an F4 value-help picker and a Fiori-readiness linter — with an agent skill shipped beside it.independent, btp, and the same habit of stating scope precisely: the current release is described as local Windows use over stdio, with a streamable HTTP transport for team use that binds to localhost.
Facts
Where it sits
Who is behind it
In the atlas: maintains 2, contributes to 5@kts982maintainerJStrader-MirionContributes to this
In the atlas: contributes to 1@JStrader-Mirion1 contributor
Before choosing this
Conditions
PracticalFunctional boundary
Driving the GUI reaches whatever a user can reach, which is business data and not a development surface. Decide what an agent may do in a session before granting one, not after. Windows only. The HTTP transport is meant for team use but binds to localhost, and unattended multi-user operation is listed as not yet available — a limitation and also the safer default.
PolicySAP API Policy 4.2026a§ 2.2.2, 3from Driving the SAP GUIAn MCP server drives SAP GUI for an agent, through its Scripting API or the screen.
- § 2.2.2 AI call sequences and data extraction. Outside SAP-endorsed architectures, data services or expressly identified pathways, the policy prohibits specified agentic API use and systematic or large-scale extraction.
- § 3 Monitoring and remedies. SAP states that it may monitor API use and take enforcement actions when use does not comply with the documentation and policy.
Driving the user interface for an agent is still an agent executing a sequence of actions against the system. Check whether section 2.2.2 applies to the design, and that the user interface is not used as a way around the controls section 3 names.
SAP API Policy 4.2026a →What it declares
Every artifact
- Type
- MCP server
- Origin
- Independently maintained
As an MCP server
- Runs as
- central serverbeside SAP GUIlocal process
- Transport
- stdioHTTP
- Authentication
- user and password
- Tools
- 59
- Read-only
- nostates it is not
- Guardrails
11 quoted from README show all
Sensitive transactions blocked by default:
preventing circumvention of the transaction policy
--read-onlyflag disables all mutating operations--allowed-transactionslimits execution to specific approved t-codes.--profilecontrols which tools are visible:exploration(read-only),operator(read + write),full(all, default).All tools carry MCP
readOnlyHint/destructiveHintannotationsIf the client does not support elicitation, the save is blocked instead of proceeding silently.
The gate is enforced server-side by middleware
Secrets in arguments are masked automatically
Passwords are never accepted as MCP tool parameters
User-supplied SAP window and element IDs are validated before
findById()is called.
Connections
Operating the SAP GUI programmatically
Download
Architecture
Download
stdio (default) and streamable HTTP transports”README
quoted from kts982/mcp-sap-gui under MIT, readMCP SAP GUI Server
An MCP (Model Context Protocol) server that enables AI assistants to interact with SAP GUI for Windows through the SAP GUI Scripting API.
It is client-agnostic: if your MCP client can launch a local stdio server, it can use this project. Examples in this README use Claude because the setup is easy to demonstrate, but the same server can be used from Codex, GitHub Copilot, Gemini CLI, and similar MCP-capable tools.
Current release: 0.5.2 for local Windows use over MCP stdio.
Status
- GitHub workflows are included for
CI,Docs,Dependency Audit, and tag-basedRelease. - Primary repository: GitHub (
kts982/mcp-sap-gui).
What's New
0.5.2 asks you before a popup answer that may save, as it does for F11, and makes table-control writes after a scroll land on the row you meant. Three of its fixes come from @nelz0n. Every change, release by release: CHANGELOG.
sap_preview — see it before it happens. The agent can now show you an approval card at any checkpoint: before a batch write, before saving, or whenever you ask ("before adding country GR, show me the values"). It carries the current screenshot, session context, and the exact values about to be written — password-shaped values masked. On MCP Apps hosts (VS Code Copilot Chat) it renders as a rich inline card; everywhere else you get the same summary as text plus the screenshot. Saving still goes through the confirmation gate. Details: Rendered Preview Cards.
Confirmation points — nothing is written without you. Tell the agent once ("ask me before every field write") and the server enforces it: sap_set_confirmation_points activates categories of write operations that pause for your explicit approval before anything reaches SAP. Enforced server-side by middleware — declining blocks the call no matter what the agent does, removing a gate asks you first, and admins can pin gates for every session with --confirm. Details: Security Considerations.
What This Does
This server allows AI assistants to:
- Connect to SAP systems (like double-clicking in SAP Logon Pad)
- Execute transactions (MM03, VA01, /SCWM/MON, etc.)
- Read and write screen fields, checkboxes, radio buttons, comboboxes, and tabs
- Use F4 value help: hit lists, restriction dialogs, date and time pickers
- Select menu items from the menu bar (Table View, Edit, Selection, etc.)
- Navigate through SAP screens using keyboard keys and buttons
- Extract data from ALV grids (GuiGridView) and classic table controls (GuiTableControl)
- Read classic report lists (
WRITEoutput) as text, including the colour of a line - Interact with ALV toolbar buttons and context menus
- Read and interact with tree controls (TableTree, ColumnTree, SimpleTree), including the docked dialog structure of view clusters
- Take screenshots of SAP windows, inline or saved as a full-resolution file
- Discover screen elements for automation
- Show you previews before writing, and pause for your approval at confirmation points you choose
Example Conversation
User: "What's the description for material MAT-001 in system D01?"
Assistant: [connects to D01]
[executes MM03]
[enters material number]
[reads description field]
"The material MAT-001 is described as 'High-Grade Steel Plate 10mm'
in system D01."
Quick Start
- Install uv (it ships with
uvx), if not already installed:
pip install uv
-
Start SAP Logon Pad and open an SAP GUI session, or at least have SAP Logon running.
-
Configure your MCP client to launch this server. No clone or manual install needed —
uvxfetches the released package from PyPI and runs it in an isolated environment:
Command: uvx
Arguments: mcp-sap-gui[screenshots]
Transport: stdio
(Working from a source checkout instead? See Installation.)
- Try one of these prompts:
Connect to my open SAP session and tell me what system I'm on
Show me the current screen info
List all editable fields on this screen
Read the first 20 rows of the visible table
sap_connect intentionally does not accept a password parameter. The safer pattern is to log in through SAP GUI first and then attach with sap_connect_existing.
Requirements
- Windows (SAP GUI only runs on Windows)
- SAP GUI for Windows installed
- Live compatibility verified with SAP GUI for Windows 8.10 64-bit Patch 0. SAP supports 8.10 until 30 June 2029 and 8.00 until 12 January 2027 (restricted support until 31 July 2027); 7.70 and older are out of SAP support and run best effort. Dates, sources and what needs which release: SAP GUI Versions
- 7.70 Patch Level 3 or later reads a whole screen, popup, list page or table control in one call (
GetObjectTree); older releases fall back to reading element by element, which is much slower on large screens (seconds instead of a fraction of a second for a full list page)
- SAP Logon Pad running, or a SAP GUI session hosted by SAP Business Client (experimental, see below) or another embedded SAP GUI (for COM connections)
- SAP GUI Scripting enabled on your SAP systems
- Python 3.10+
- uv (recommended Python package manager)
SAP Business Client (experimental)
- Classic transactions in SAP Business Client run in embedded SAP GUI for Windows, so the server-side scripting parameter is still required.
sapgui/nwbc_scriptinggives read-only scripting (same effect assapgui/user_scripting+sapgui/user_scripting_set_readonly): write tools refuse, and grids cannot be scrolled, so a table read stops at the rows on screen. - Sessions are discovered through the SAP GUI server process's COM Running Object Table entries (
SAPGUISERVER-<pid>), next to the usual SAP Logon entry.sap_list_connectionsreportshost: "sapguiserver"for them. - Tabs of one Business Client window are sessions of one connection; a second system is a second connection.
- Business Client connections have no SAP Logon description; the list shows the system and client instead (e.g.
DEV (100)). - Pressing Back repeatedly closes the tab instead of landing on the SAP Easy Access menu (SAP Business Client FAQ).
- Fiori Launchpad connections may render a transaction as SAP GUI for HTML; such a transaction is invisible to scripting.
Supported Scope
Supported:
- SAP GUI for Windows via the SAP GUI Scripting COM API
- MCP
stdio(default) andstreamable HTTPtransports - Per-client session isolation (multiple MCP clients can hold independent SAP sessions)
- Interactive use from MCP-compatible clients
- Read and write SAP GUI automation within the permissions of the logged-in SAP user
Not yet available:
- SAP GUI for Java or SAP GUI for HTML
- Browser-based Fiori automation
- Unattended multi-user production orchestration
Enabling SAP GUI Scripting
SAP GUI Scripting must be enabled both client-side and server-side:
Client-side (SAP GUI Options):
- Open SAP GUI → Options → Accessibility & Scripting → Scripting
- Check "Enable scripting"
- Optionally uncheck "Notify when a script..." for smoother automation
Server-side (SAP System):
- Transaction
RZ11→ Parametersapgui/user_scripting→ Set toTRUE - Requires SAP Basis administrator access
Deploying Where Scripting Is Restricted
Many organizations disable SAP GUI Scripting globally as a hardening default. Enabling it does not have to be all-or-nothing: SAP ships graduated server-side controls that let a Basis team enable scripting narrowly — typically for named users on a development system — while keeping it off for everyone else.
Profile parameter (RZ11/RZ10) | Effect |
|---|---|
sapgui/user_scripting = TRUE | Master switch; required for any scripting |
sapgui/user_scripting_per_user = TRUE | Scripting works only for users holding authorization object S_SCR (class BC_A, activity 16); all other users stay blocked (SAP Note 983990) |
sapgui/user_scripting_set_readonly = TRUE | Scripts may read screen state but cannot send anything that changes server state (SAP Note 692245) |
sapgui/user_scripting_force_notification = TRUE | Users always see a notification/consent dialog when a script attaches; cannot be suppressed in local SAP GUI options (SAP Note 3591984) |
sapgui/user_scripting_disable_recording = TRUE | Blocks recording of new scripts; playback still works |
Useful facts when proposing this to a Basis/security team:
- Per-user and read-only modes are combinable since SAP GUI 7.40 PL17 / 7.50 PL4: full API for
S_SCRholders, read-only for everyone else (SAP Note 2565390). - On a read-only session this server reports
scripting_read_only: truein the session info and refuses every write tool up front with the reason, instead of letting each action fail inside SAP GUI. All read tools keep working. - A dynamic
RZ11change tosapgui/user_scriptingis not persistent — it reverts at the next application server restart, which suits a time-boxed evaluation on a development system. - Server-side, scripted actions run under the SAP user's normal authorizations and appear in logs as ordinary user activity. The user's authorization profile is the effective security boundary — pair a dedicated minimal-authorization account with this server's transaction policy (
--policy-preset,--policy-file),--profile, and--audit-logoptions for defense in depth. - Authoritative reference: SAP GUI Scripting Security Guide (help.sap.com).
Why the Scripting API is required at all: SAP GUI for Windows draws dynpro screens on a custom canvas that exposes no usable structure to Windows UI Automation or other accessibility APIs — the Scripting API is the only structured way to read and drive SAP GUI screens. Commercial RPA products have the same dependency and fall back to screenshot/OCR-based automation when scripting is disabled; this project deliberately avoids that approach because it is imprecise and brittle.
Installation
From PyPI (recommended for users)
Nothing to clone. uvx downloads the latest release and runs it in an isolated environment:
# Smoke test the published package
uvx "mcp-sap-gui[screenshots]" --help
The [screenshots] extra adds screenshot optimization (reduces screenshot size by 70-90%) and is recommended. It needs Python 3.11 or newer; on 3.10 it installs nothing and screenshots stay unoptimized. Point your MCP client at uvx with argument mcp-sap-gui[screenshots] — see MCP Setup below.
From source (for development)
# Clone the repository
git clone https://github.com/kts982/mcp-sap-gui.git
cd mcp-sap-gui
# Install uv (if not already installed)
pip install uv
# Install all dependencies (creates .venv automatically)
uv sync
# With screenshot optimization (recommended - reduces screenshot size by 70-90%)
uv sync --extra screenshots
# With dev dependencies (for testing, linting, type checking)
uv sync --extra dev --extra screenshots
Windows note for source checkouts: while an MCP server launched from this checkout is running, its process holds locks on native DLLs in .venv (pywin32, watchfiles). Running uv sync or upgrading dependencies during that time can fail with "Access is denied" or leave .venv half-updated — stop or restart the MCP client first, then sync. If two MCP clients (e.g. Claude Code and VS Code) launch the server from the same checkout, point the second one at an isolated environment instead of the shared .venv:
Command: uv
Arguments: run --isolated --no-project --with "mcp-sap-gui[screenshots,apps] @ file:///<path-to-checkout>" python -m mcp_sap_gui.server
(uvx mcp-sap-gui users are unaffected — every uvx launch uses its own cached environment.)
Usage
Connection recommendation: prefer sap_connect_existing for already authenticated sessions. Use sap_connect mainly for SSO flows or to open the SAP login screen before the user completes manual login.
Running the MCP Server Directly
# Standard mode (stdio, default)
uv run python -m mcp_sap_gui.server
# Read-only mode (safer for exploration)
uv run python -m mcp_sap_gui.server --read-only
# With transaction whitelist
uv run python -m mcp_sap_gui.server --allowed-transactions MM03 VA03 ME23N
# HTTP transport (for team/remote use, binds to localhost)
uv run python -m mcp_sap_gui.server --transport http
# HTTP on custom host/port
uv run python -m mcp_sap_gui.server --transport http --host 0.0.0.0 --port 9000
# Policy profile (restrict visible tools)
uv run python -m mcp_sap_gui.server --profile exploration
# Confirmation points (ask the user before these categories run, every session)
uv run python -m mcp_sap_gui.server --confirm field_writes transactions
# Audit log to file (JSON lines)
uv run python -m mcp_sap_gui.server --audit-log sap_audit.jsonl
# EXPERIMENTAL: code mode — replaces the tool catalog with search/get_schema/
# tags/execute meta-tools; agents script chained SAP flows in a sandbox.
# Faster and cheaper on long chained flows (e.g. full table dumps), slower on
# quick one-shot questions. Requires: uv sync --extra code-mode
uv run --extra code-mode python -m mcp_sap_gui.server --code-mode
# Same, from the published PyPI package (no checkout needed)
uvx "mcp-sap-gui[screenshots,code-mode]" --code-mode
# Debug mode
uv run python -m mcp_sap_gui.server --debug
MCP Setup
This server communicates over stdio (stdin/stdout JSON-RPC), which is the standard MCP transport. You don't need to configure ports or URLs — the MCP client starts the server process and talks to it directly.
For any client, the core launch configuration is the same:
Command: uvx
Arguments: mcp-sap-gui[screenshots]
Transport: stdio
Running from a source checkout instead of PyPI? Use
uv run --directory <path-to-mcp-sap-gui> python -m mcp_sap_gui.server
as the command.
Client Setup Links
- Claude Code / Claude Desktop: setup examples are included below
- Codex: configure an MCP server in Codex and point it at the command above. Official MCP docs: https://developers.openai.com/learn/docs-mcp
- GitHub Copilot: configure a local MCP server in Copilot Chat / agent mode. Official docs: https://docs.github.com/en/copilot/how-tos/provide-context/use-mcp
- Gemini CLI: add the server under
mcpServersin your Gemini CLI settings. Official docs: https://github.com/google-gemini/gemini-cli/blob/main/docs/tools/mcp-server.md
Below are full examples for the most common local SAP GUI setup paths.
For a client-by-client setup guide, see docs/CLIENTS.md.
Option 1: Claude Code (Recommended for development)
The repository includes a .mcp.json at the project root. When you open this project in Claude Code, the MCP server is automatically discovered — no manual configuration needed.
To use it:
cd mcp-sap-gui
claude
Claude Code will detect .mcp.json and start the SAP GUI MCP server automatically.
If you want to configure it globally for Claude Code (available in any project), add it to your user settings at ~/.claude/.mcp.json:
{
"mcpServers": {
"sap-gui": {
"type": "stdio",
"command": "uvx",
"args": ["mcp-sap-gui[screenshots]"]
}
}
}
Option 2: Claude Desktop
Add to your Claude Desktop config file:
- Windows:
%APPDATA%\Claude\claude_desktop_config.json - macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
Standard mode:
{
"mcpServers": {
"sap-gui": {
"command": "uvx",
"args": ["mcp-sap-gui[screenshots]"]
}
}
}
Note: Running from a source checkout instead of PyPI? Use
"command": "uv"with"args": ["run", "--directory", "<path-to-mcp-sap-gui>", "python", "-m", "mcp_sap_gui.server"]— the--directoryflag is required souvfinds the project's virtual environment regardless of the working directory Claude Desktop uses.
Read-only mode (recommended when exploring/querying data):
{
"mcpServers": {
"sap-gui": {
"command": "uvx",
"args": ["mcp-sap-gui[screenshots]", "--read-only"]
}
}
}
With transaction whitelist (only allow specific transactions):
{
"mcpServers": {
"sap-gui": {
"command": "uvx",
"args": [
"mcp-sap-gui[screenshots]",
"--allowed-transactions", "MM03", "VA03", "ME23N"
]
}
}
}
After editing the config, restart Claude Desktop for changes to take effect.
Option 3: Any MCP-compatible client
The server uses stdio transport. Point any MCP client at:
Command: uvx mcp-sap-gui[screenshots]
Arguments: [--read-only] [--profile exploration|operator|full] [--confirm POINT ...] [--audit-log FILE] [--debug] [--policy-preset default|abap-dev|strict] [--policy-file FILE] [--allowed-transactions T1 T2 ...]
Transport: stdio
For a source checkout, use uv run --directory <path-to-mcp-sap-gui> python -m mcp_sap_gui.server instead.
Verifying the Setup
Once configured, you can verify the MCP server is working by asking Claude:
"List all available SAP GUI tools"
Claude should respond with the full list of sap_* tools. If SAP GUI is running, try:
"Connect to my open SAP session and tell me what system I'm on"
Then try:
"Show me the current screen info"
"List all editable fields on this screen"
"Read the first 20 rows from the visible table"
Built-in Agent Guidance
The server includes built-in navigation knowledge that helps any MCP client (Claude Code, Copilot, Cursor, Cline, etc.) use SAP GUI effectively:
- MCP Instructions — Injected into every client's system prompt during initialization. Covers screen discovery workflow, popup handling, table pagination, SPRO tree navigation, key reference, and common mistakes to avoid.
docs://sap-gui-guideResource — Detailed reference guide available on-demand viaresources/read. Covers element types, ID naming conventions, transaction code formats, table type comparison, status bar messages, and step-by-step patterns for SPRO and table maintenance views.
These prevent common agent mistakes like guessing element IDs, ignoring popups, pressing F5 (="New Entries") when meaning to refresh, using double_click_tree_node in SPRO (which opens docs instead of executing the activity) or in a view cluster (where it does nothing), or reading a classic report list from a screenshot instead of with sap_read_list.
Available Tools
The server currently exposes 60 MCP tools.
| Category | Count | What it covers |
|---|---|---|
| Connection & Policy | 7 | Connect to SAP, attach to open sessions, inspect sessions, disconnect, set policy profile, set confirmation points |
| Navigation | 3 | Execute transactions, send keys, inspect current screen |
| Fields & UI | 13 | Read/write fields, buttons, tabs, comboboxes, textedit, focus |
| Tables & Grids | 17 | ALV grids, TableControls, row selection, column info, cell ops |
| Popup / Toolbar / Shell / Lists | 5 | Popup inspection and handling, toolbar discovery, shell content, classic report lists |
| Trees | 10 | Read/search/expand/select/click SAP tree controls |
| Discovery | 2 | Screen element discovery and screenshots |
| Preview | 1 | Show the user the current screen plus the values the agent is about to write |
| Workflow Guidance | 1 | Return step-by-step guidance for known multi-tool SAP workflows |
| Transaction Guidance | 1 | Return a generic, read-first guide for supported SAP transactions |
The most important patterns:
sap_get_screen_elementsto discover IDs instead of guessingsap_read_tableto start with any SAP table/gridsap_read_listwhen a report prints a plain list instead of an ALV grid- Every action response carries a short
popupdigest when a popup opened (classification, texts, button labels, andprefilled_inputswith a notice when inputs already hold values or options are preselected);sap_get_popup_windowgives the full details and suggests a safe next step sap_handle_popup(action="auto")when you want the server to dismiss only clearly safe informational popups and otherwise leave the dialog untouchedsap_previewbefore significant writes (batch field fills,F11/ Save) so the user sees the screen and the pending values firstsap_set_confirmation_pointsto make categories of writes ask the user for approval before they runsap_get_workflow_guidewhen you want the proven sequence for a known workflowsap_get_transaction_guidewhen you want a generic guide for a supported transaction:/SCWM/MON(alsowarehouse monitor), orSM30for table/view maintenance and view clusters (alsoSM34,view cluster)sap_read_treeplus search/expand helpers for SPRO-style navigation
For the full tool catalog, grouped by category with short descriptions, see docs/TOOLS.md.
Rendered Preview Cards
sap_preview is read-only and always returns a written summary plus the screenshot as an image, so it works in every MCP client. Clients that support the MCP Apps UI extension (for example VS Code Copilot) instead get a rendered card with the screenshot and a pending-values table. Install the optional extra to enable the card:
uv sync --extra apps # or: uvx "mcp-sap-gui[screenshots,apps]"
Restricted or offline networks: by default the card renderer is loaded from the jsDelivr CDN, so the card silently fails to render on workstations without outbound internet access. Set PREFAB_BUNDLED_RENDERER=1 in the server's environment to make the renderer self-contained (a ~6.3 MB inline resource, no third-party domains):
{
"mcpServers": {
"sap-gui": {
"command": "uvx",
"args": ["mcp-sap-gui[screenshots,apps]"],
"env": { "PREFAB_BUNDLED_RENDERER": "1" }
}
}
}
Security Considerations
This server provides powerful automation capabilities. Use responsibly.
Built-in Safeguards
-
Transaction Policy - Which transactions an agent may start. What is dangerous depends on who runs the server and against which system, so it is configurable:
--policy-preset default(the default) blocks user and role administration (SU01,SU10,SU01D,PFCG,SU53), logs and dumps (SM21,ST22), development and program execution (SE38,SA38,SE80,SE37,SE16N), and system administration (STMS,SCC4,RZ10,RZ11,SM36,SM49,SM69,SM59,STRUST,SICF,SM01,SM18,SM19). Customizing and display work (SM30,SM34,SPRO,SE16,SE11) stays open--policy-preset abap-devadditionally allowsSA38,SE11andSE80, for developers testing their own programs--policy-preset strictblocks everything the policy file does not allow--policy-file policy.jsonadds to the preset:{"preset": "abap-dev", "block": ["ZHR*"], "allow": ["SM59"]}. Entries are codes or glob patterns (SU*,/SCWM/*);allowalways wins overblock. Without the flag the server reads$MCP_SAP_GUI_POLICY_FILE, else%APPDATA%\mcp-sap-gui\policy.jsonif it exists. Keep the file outside the agent's workspace- Two examples ship in
examples/:policy.example.jsonstarts fromdefault, additionally blocks a customer namespace (ZHR*) andSE16, and allowsST22for dump analysis;policy.strict.example.jsonis an allowlist for a display-only agent. To make one your per-user policy on Windows:New-Item -ItemType Directory -Force "$env:APPDATA\mcp-sap-gui"; Copy-Item examples\policy.example.json "$env:APPDATA\mcp-sap-gui\policy.json" - The policy is read once at startup and written to the audit log (with the file's SHA-256). No tool can change it, and a policy file that cannot be read stops the server instead of falling back to something more permissive
- Case-insensitive matching; handles
/n,/o,/*prefixes and whitespace - It is a guardrail against agent mistakes, not a security boundary: a blocked transaction can often be reached another way (a menu path, a screen you left open). The SAP user's authorizations are the boundary
-
OK-Code Bypass Prevention - Setting likely SAP command fields such as
tbar[0]/okcd,txtOK_CODE, or similar command-code aliases to a blocked transaction is also blocked, preventing circumvention of the transaction policy -
Read-Only Mode -
--read-onlyflag disables all mutating operations (field writes, button presses, transaction execution, key sends, tree/table interactions) -
Transaction Whitelist - For production use an allowlist: the
strictpolicy preset with anallowlist in the policy file (supports patterns such as/SCWM/*). The older--allowed-transactions T1 T2 ...flag still works and restricts on top of the policy. -
Policy Profiles -
--profilecontrols which tools are visible:exploration(read-only),operator(read + write),full(all, default). Profiles can also be switched per-session viasap_set_policy_profile— but the server--profileis a floor: a session can restrict itself further, never grant itself more than the server allows -
Tool Tags - Every tool is tagged
readorwritefor policy profile filtering. All tools carry MCPreadOnlyHint/destructiveHintannotations so clients can display appropriate UI hints -
Save Confirmation -
sap_send_key("F11")andsap_send_key("Save")now require explicit user confirmation via MCP elicitation. If the client does not support elicitation, the save is blocked instead of proceeding silently. -
Confirmation Points - Named categories of write operations that require blocking user approval before the server executes them.
save(theF11/Savekey and thewnd[0]/tbar[0]/btn[11]Save toolbar button) is always on.transactions,batch_fields,field_writes,all_writesandattachcan be activated per session withsap_set_confirmation_points, or for every session with--confirm POINT [POINT ...].attachis a choice, not a yes/no:sap_connect_existinglets the user pick the SAP session the agent works in (--confirm attachturns it on for every chat).The gate is enforced server-side by middleware, so it applies no matter what the agent does — including inside the experimental
--code-modesandbox. Adding a point is silent; removing a session point asks the user first, and points set by--confirmcannot be removed at all. Declining returns an error and nothing is executed, and clients without elicitation support fail closed (the gated call errors instead of running unconfirmed). Every confirmation is written to the audit log with its outcome (accepted,declined,unsupported_client).The client has to show these prompts. The Claude Code CLI does; the Claude Code desktop app (tested 2026-10-19) declined every one within milliseconds without showing it, so saves through the server cannot be approved there. The server then says that no dialog was shown, instead of reporting that you declined. See Confirmation Points.
On a client without elicitation support, removal fails closed too: a point activated there cannot be turned off again, so it blocks that whole category for the rest of the session. Points survive
sap_disconnect— their lifetime is the MCP session, not the SAP connection.all_writescovers every write-tagged tool, including selection, scrolling and navigation helpers that change no business data — it is deliberately strict and noisy, and under itsap_send_key("F11")prompts twice (once for the category, once for the unchanged save gate). -
Audit Logging -
--audit-log FILEwrites every tool call (name, arguments, timing, outcome, and the SAP system, client and user the chat is bound to) as JSON lines. Secrets in arguments are masked automatically -
Secure Credential Resolution -
sap_connectresolves credentials from a.envfile (SAP_USER,SAP_PASSWORD,SAP_CLIENT,SAP_LANGUAGE). Passwords are never accepted as MCP tool parameters and never appear in client logs, tool-call history, or audit logs. Copy.env.exampleto.envto get started -
ID Validation And Normalization - User-supplied SAP window and element IDs are validated before
findById()is called. Standard IDs likewnd[0]/usr/...are accepted, and full session paths like/app/con[0]/ses[0]/wnd[0]/usr/...are normalized to the short form automatically.
Recommendations for Production Use
- Never expose to untrusted users
- Use read-only mode for exploration/queries
- Implement transaction whitelists for automation
- Enable audit logging on SAP side
- Use dedicated service accounts with minimal authorizations
- Enable scripting per-user, not globally —
sapgui/user_scripting_per_userwith theS_SCRauthorization limits scripting to named users (see Deploying Where Scripting Is Restricted) - Run on isolated systems (test/sandbox, not production)
SAP Licensing
Consult your SAP licensing agreement regarding:
- Automated access and scripting
- Indirect access considerations
- Named vs. concurrent user licensing
Example Workflows
Display Material Master
# Claude would execute these tools:
sap_connect("D01 - Development System")
sap_execute_transaction("MM03")
sap_set_field("wnd[0]/usr/ctxtRMMG1-MATNR", "MAT-001")
sap_send_key("Enter")
# Select views...
sap_send_key("Enter")
description = sap_read_field("wnd[0]/usr/txtMAKT-MAKTX")
Extract Purchase Order List
sap_execute_transaction("ME2M")
sap_set_field("wnd[0]/usr/ctxtEN_LIFNR-LOW", "1000") # Vendor
sap_send_key("Execute") # F8
data = sap_read_table("wnd[0]/usr/cntlGRID1/shellcont/shell", max_rows=50)
Navigate Sales Order
sap_execute_transaction("VA03")
sap_set_field("wnd[0]/usr/ctxtVBAK-VBELN", "12345")
sap_send_key("Enter")
# Read header data
customer = sap_read_field("wnd[0]/usr/subSUBSCREEN.../txtVBAK-KUNNR")
# Navigate to items
sap_press_button("wnd[0]/usr/tabsTAXI_TABSTRIP.../tabpT\\01")
items = sap_read_table("wnd[0]/usr/.../cntlGRID1/shellcont/shell")
Filter Customizing Table (GuiTableControl)
# In SPRO or SM30 table maintenance view
# Use Selection -> By Contents to filter
sap_select_menu("wnd[0]/mbar/menu[3]/menu[0]") # Selection > By Contents
# Select the field to filter on, enter value
sap_select_table_row("wnd[1]/usr/tblSAPLSVIXTCTRL_SEL_FLDS", 0)
sap_send_key("Enter")
sap_set_field("wnd[1]/usr/.../txtQUERY_TAB-BUFFER[3,0]", "EXTSYS001")
sap_send_key("Execute")
# Read the filtered table
data = sap_read_table("wnd[0]/usr/tblSAPLBD41TCTRL_V_TBDLS")
Batch Fill And Validate A Form
sap_set_batch_fields(
{
"wnd[0]/usr/ctxtFIELD1": "VALUE1",
"wnd[0]/usr/txtFIELD2": "VALUE2",
},
validate=True,
skip_readonly=True,
)
# Returns per-field results plus post-Enter screen feedback
Show The User What Is About To Change
"Before adding country GR, show me the values."
# Read-only: renders the current screen plus the pending values.
sap_preview(
note="About to add country GR to V_T005",
pending_fields={
"Country Key (V_T005-LAND1)": "GR",
"Name": "Greece",
"Currency": "EUR",
},
)
# The user confirms in chat, then the agent writes and saves:
sap_set_batch_fields({...}, validate=True)
sap_send_key("Save") # still requires explicit confirmation via elicitation
Project Structure
mcp-sap-gui/
├── docs/
│ ├── CLIENTS.md # Client-specific MCP setup notes
│ ├── OVERVIEW.md # Product overview and roadmap direction
│ └── TOOLS.md # Full MCP tool catalog
├── scripts/
│ └── check_docs.py # Markdown link checker used by docs workflows
├── src/
│ └── mcp_sap_gui/
│ ├── __init__.py # Package exports
│ ├── server.py # MCP server implementation (tool definitions)
│ ├── session_manager.py # Per-client SAP session isolation
│ ├── sap_controller.py # Facade class (composes all mixins)
│ ├── models.py # VKey enum, SessionInfo, exceptions
│ ├── controller.py # Base controller (connection, navigation, screen info)
│ ├── fields.py # FieldsMixin (read/write fields, buttons, combos)
│ ├── tables.py # TablesMixin (ALV grid + TableControl operations)
│ ├── trees.py # TreesMixin (tree read, expand, select, click)
│ ├── discovery.py # DiscoveryMixin (popups, toolbars, screenshots)
│ ├── confirmation.py # Confirmation points + blocking-confirmation middleware
│ └── preview.py # sap_preview text + Prefab card builders
├── tests/
│ ├── test_sap_controller.py # Controller unit tests
│ ├── test_confirmation.py # Confirmation points: gate, tool, CLI floor
│ ├── test_preview.py # sap_preview builders + card/text branches
│ └── test_server.py # Server security & routing tests
├── examples/
│ └── basic_usage.py # Direct controller example
├── .mcp.json # MCP server config (auto-detected by Claude Code)
├── CONTRIBUTING.md # Contribution guidelines for public changes
├── LICENSE # MIT license
├── pyproject.toml
├── uv.lock # Dependency lock file (managed by uv)
└── README.md
Troubleshooting
"Cannot connect to SAP GUI"
- Ensure SAP Logon Pad, SAP Business Client or another SAP GUI session is running
- Check that SAP GUI Scripting is enabled in SAP GUI options
"Scripting disabled" error
sap_list_connectionsreports such systems withscripting_disabled: trueand no sessions- Enable scripting server-side:
RZ11→sapgui/user_scripting=TRUE - Requires SAP Basis administrator
- Organization won't enable scripting globally? See Deploying Where Scripting Is Restricted for per-user and read-only enablement options
"Element not found"
- Use
sap_get_screen_elements()to discover available field IDs - Field IDs vary between SAP systems due to customization
COM errors on startup
- Ensure dependencies are installed:
uv sync - Run
uv run python -m win32com.client.makepyif COM registration issues occur
"No SAP tools appear in my MCP client"
- Confirm the client is launching the server from the project root
- Restart the MCP client after changing its MCP configuration
- Run
uv syncfirst so the environment and dependencies exist
SAP Logon exits during a read
- On SAP GUI 8.00 with 0.5.0, table-control and classic-list reads can take SAP Logon down: upgrade to 0.5.1 (issue #22)
- Another SAP GUI build that fails on the one-call read: turn it off per call site with
MCP_SAP_GUI_DISABLE_OBJECT_TREE, and find the call withMCP_SAP_GUI_TRACE_FILE. See Switches for a misbehaving SAP GUI build
"The tool is available, but the action is blocked"
- Check whether the server is running with
--read-only - Check whether the transaction policy blocks it: the error names the active preset. Allow the transaction in a policy file (
--policy-file, see Security Considerations) or pick another--policy-preset, then restart the server. The policy cannot be changed from inside a session - Check whether you started the server with
--allowed-transactions
Development
# Install all dependencies (dev + screenshots)
uv sync --extra dev --extra screenshots
# Run tests
uv run pytest
# Type checking
uv run mypy src/
# Linting
uv run ruff check src/
Related
- SAP GUI Scripting API Documentation
- MCP Specification
- Contributing Guide
- Security Policy
- Client Setup Guide
- Tool Catalog
- Project Overview
License
MIT. See LICENSE.
Disclaimer
This project is not affiliated with, endorsed by, or sponsored by SAP SE. SAP, SAP GUI, and other SAP products mentioned are trademarks of SAP SE.
Use of this software with SAP systems should comply with your SAP licensing agreement and your organization's security policies.
History
Fixes 6, Dependencies 1, Other 6
Notes
Popup answers that ask first, and table writes on the right row. Three of these fixes were contributed by @nelz0n; all were checked live on SAP GUI 8.10 and 8.00.
Safety
- A popup answer that may save asks first, as F11 does (#27). This covers
sap_handle_popup(confirm,press) andsap_press_buttonon a popup button by ID. A popup is save-shaped when the button saves, or when its text is about saving and it offers more than one answer. - Popup questions the server cannot read. SAP's confirmation popup (SAPLSPO1, e.g. "Save before exiting editor?", "Data may be lost") draws its question in an HTML viewer. With the Internet Explorer browser control the question is read into
texts. With Edge (the default) scripting cannot read it: the popup reportsquestion_readable: falsewith aquestion_note, is classifiedconfirmation, and any answer but Cancel asks the user first. cancelnever presses No. It presses a Cancel-type button (in the common logon languages) or F12. On a save prompt, No left the editor and dropped the changes.sap_send_keychecks the key before asking to save. F11 / Save on a screen where it is not active is refused with the available keys, without a save prompt first.- Table-control writes after a scroll land on the right row. Setting
VerticalScrollbar.Positioncan put a different row on top than the one asked for (SE16's multiple selection: row 7 or 8 for 9, 14 for 15).sap_modify_cell,sap_set_current_cellandsap_double_click_cellcounted visible rows from the requested position, so a write could go into another row and still report success. They now count from the row SAP put on top, and refuse with "Nothing was changed" when the row is still not visible. Row selection was not affected.
Fixed
- Element IDs with any SAP screen name (#24). Unnamed elements (
%#AUTOTEXT001),*work areas (SE24),=>and->attributes (SLIN), field symbols<FS>and+ & ' ! ? " ( ) {were refused by the tools that take an element ID. A path segment is now a type prefix plus anything but whitespace and/ [ ]; thewnd[n]prefix and the top-level children are still checked. - A closed SAP window fails at once (#31).
RPC_E_DISCONNECTED(0x80010108) andRPC_S_SERVER_UNAVAILABLE(0x800706BA) raise a "reconnect withsap_connect_existing" error at once, instead of three retries (about 2 s) and the raw COM error.RPC_E_SERVERFAULT(0x80010105) is SAP GUI's stale-reference error and is no longer retried: the retry re-ran the whole tool body, presses and keys included. OnlyRPC_E_CALL_REJECTEDandRPC_E_SERVERCALL_RETRYLATERare retried, and the HRESULT names in the code are now right. sap_scroll_table_controlreports the row actually on top.positionis the row SAP put at the top;requested_positionand anoteare added when it differs from the one asked for.sap_read_tablewithstart_row=0on a table control starts at the first row. It read from wherever the table was scrolled. Withoutstart_rowthe read still starts at the current scroll position, e.g. after "Position...".- ALV toolbar: a plain button is pressed, not opened as a menu. On SAP GUI 8.10
PressToolbarContextButtonon a plain button runs it instead of failing, so Find opened its popup and was reported asmenu_opened. The button's type on the toolbar now picks the press. sap_handle_popup: when the Enter or F12 fallback leaves the popup as it was, the result isaction: "no_effect"instead ofconfirmed.
Dependencies
mcp1.28.1 → 1.30.0 (through fastmcp) for GHSA-84m7-p3x7-pcfv (CVE-2026-59951): the Streamable HTTP transport kept every session, so a client could exhaust the server's memory. This affects--transport httponly. With 1.30.0, an HTTP session idle for 30 minutes is closed (a client that does not keep the event stream open then has to initialize a new session, which starts without the old session's SAP binding), and a server holds at most 10,000 sessions. stdio is unchanged.
Release
SHA256SUMS.txtno longer listsdist/.gitignore, which was never a release asset.
Other 4
Notes
A crash fix for SAP GUI 8.00, and screens that say more.
- No more SAP Logon crashes on SAP GUI 8.00. On 8.00, reading a table control or a classic list in one call could take SAP Logon down with every session in it (issue #22). The cause was one property in that call: the server no longer asks for it and reads checkboxes one by one, still about 3x faster than reading cell by cell. Two environment variables, contributed by @nelz0n in #23, turn the one-call read off per call site and trace each call to a file, for any other SAP GUI build that misbehaves. Which SAP GUI releases SAP still supports, and what needs which: SAP GUI Versions.
- Screen info names sub-screens and the cursor. Every action response lists the active window's sub-screens (
subscreens, asprogram:dynnr) and the field the cursor is in (cursor), so an RF step, a tab page or a redisplay that only moves the cursor shows without a screenshot. - Table controls say where their data ends.
sap_read_tableon a table control reportsempty_rows_from, the first padding line:total_rowsalso counts the empty lines that pad an SM30 view. - Confirmed writes say so. After you approve a save or another confirmation point, the result carries
confirmed_by_user: true, so the agent can tell an approved write from an ungated one.
Other 6
Notes
The SAP GUI Scripting API, used to the full. This round went through the 8.10 Scripting API guide on a trial system and closed the gaps it found:
- Much faster on large screens. On SAP GUI 7.70 PL3 or later a whole screen, popup, list page or table control is read in one call (
GetObjectTree): a 1,139-cell list page takes 0.2 s instead of 4.7 s. Older releases fall back to reading element by element. - Value help that agents get right. F4 popups are recognised for what they are (hit list, restriction dialog, date picker, time picker) and never auto-cancelled, and a rewritten
search_helpguide covers each case. Dropdowns are set withsap_set_fieldandsap_set_batch_fieldsby key or text, and discovery shows their selected key instead of 200 padded characters. - Safer popups. SAP's message popups are recognised in any logon language, and only an information message is ever auto-confirmed: a warning standing between you and a save is always left to you.
- Keys that mean what they say.
sap_send_keyrefuses a key the screen does not accept and lists the ones it does, andCtrl+F/Ctrl+G/Ctrl+Pnow send Find / Find next / Print (they sent Ctrl+F8 to Ctrl+F10 before). - More of SAP's own metadata. Session info reports the SAP GUI release and whether the server only allows read-only scripting (write tools then refuse up front); ALV cells report their type, error or warning state, F4 help and hotspots; an ALV toolbar menu lists its items when it opens; a status message with a long text says so, and pressing the status bar opens it.
- SAP Business Client (experimental). Sessions of Business Client's embedded SAP GUI are discovered next to SAP Logon's. Details: SAP Business Client.
Changed behaviour when upgrading: discovery elements no longer carry
visible(SAP GUI Scripting has no such property, so it was always true); F4 hit lists are classifiedlistinstead ofinformation; a key the screen does not accept returns an error withavailable_keysinstead of a COM error.- Much faster on large screens. On SAP GUI 7.70 PL3 or later a whole screen, popup, list page or table control is read in one call (
Other 6
Notes
Shaped by two days of real agent work on a live system. The lesson was that token cost per call hurts more than missing tools, and that a few screens could not be reached at all:
- Lighter responses. A table control is one discovery element instead of one per cell (an SM30 screen went from 231 elements to 3), element IDs come back in the short
wnd[0]/...form, and batch fills and popup actions report what matters instead of echoing everything. sap_read_listreads a classic report list (WRITEoutput, F4 hit lists) as lines of text with list colours and paging — 43 lines instead of 492 label elements, and no screenshot needed.- View clusters work. Docking containers (
wnd[0]/shellcont) are valid IDs and discovery points to them, so the dialog structure of SM34 and most IMG activities can be navigated. A newSM30transaction guide covers table maintenance and view clusters end to end. - Your transaction policy. Presets (
default,abap-dev,strict) plus a policy file with glob patterns replace the hard-coded blocklist. Details: Security Considerations. - Popups announce pre-filled values. When an action opens a popup, its response already says what the popup is and which inputs hold values you never chose — such as a customizing request pre-filled with another project's request.
- Screenshots to a file.
sap_screenshot(save_path=...)writes a full-resolution PNG for documents and never overwrites a file.
- Lighter responses. A table control is one discovery element instead of one per cell (an SM30 screen went from 231 elements to 3), element IDs come back in the short
Notes
See the GitHub release pages. 0.3.0 (2026-08-30) brought
sap_previewapproval cards and confirmation points: see What's New in the README.
Others providing
Compare all 5 on the Driving the SAP GUI page →- sapgui.mcpsapgui.mcpDrives the SAP desktop GUI and the Web GUI, and is built for the jobs a REST client cannot do — end-to-end testing against the real screen, visual validation, and screenshots for documentation.independent, abapMCP server driving SAP GUI and Web GUI for end-to-end testing
- tool-bitool-biBuilds an ABAP batch input transaction through chained method calls, one per screen, field and value, then runs it directly or writes it to a batch input session.independent, abapChained-call builder for ABAP batch input transactions
- mcp-sap-guimcp-sap-guiThe earliest of the SAP GUI servers in the atlas. It works the screen by coordinates and hands back a screenshot after each action, with a setup script and a short path from clone to a driven transaction.independent, abapMCP server working SAP GUI by screen coordinates
- SAPient MCPSAPient MCPAn MCP server for SAP GUI automation built on RoboSAPiens, the Robot Framework library, rather than on the Scripting API directly, over stdio or SSE depending on the client.independent, abapSAP GUI automation MCP server built on RoboSAPiens
Details
Sources
Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.
Compatibility and provenance
Flavors
“enables AI assistants to interact with SAP GUI for Windows through the SAP GUI Scripting API.” — kts982/mcp-sap-gui — README
Contributors
History in the atlas
- practical boundaries only
- corrected against the README
- Triaged out of data/crawled/mcp-candidates.json, the sap-ai-mcp-servers sweep. Written from the repository's own README.
- First seen.
For your agent
- Ref
artifact:kts982-mcp-sap-gui- JSON
- /artifacts/kts982-mcp-sap-gui.json
- MCP
- Connecting an agent