Content
SAP ADT / RFC MCP Tool
This is an MCP tool for SAP ABAP scenarios, providing a unified entrance that supports two backend modes through the same set of Java services:
- ADT Mode: Access SAP ADT via HTTP, suitable for source code browsing, object search, synchronization, learning, and rollback.
- RFC Mode: Directly connect to SAP using Java + SAP JCo, suitable for RFC calls, table reading, and system information queries.
The current version is `0.0.2`, and the copyright belongs to Wu Dehan, Wang Xiaofeng, and Wang Gang.
This project adopts the `Apache License 2.0`, and the full license text can be found in [`LICENSE`](LICENSE).
## Source Code and Artifacts
The repository can be divided into two layers:
- Source code: `src/`, `pom.xml`, `scripts/`
- Initialization artifacts: `sap-abap-mcp-init/`
If you only want to obtain a distributable initialization package, download or package `sap-abap-mcp-init/`.
If you want to modify the implementation, debug the tool, or recompile, look at the source code in the repository root directory.
`sap-abap-mcp-init/` has been organized into a delivery-oriented directory. It saves documentation, scripts, examples, and copyright information; the target directory generates `.mcp.json` and `sap-abap-mcp-lib/`, and pre-creates `SAP_EXPORT_DIR` and `SAP_STATE_DIR`.
The default mode is `adt`. If you switch to `rfc` in `.mcp.json`, the service will switch to RFC connections.
If you are primarily concerned with "source code synchronization", this Java tool supports:
- Reading source code by object
- Automatically detecting scope and synchronizing source code to a local directory
- Synchronizing source code by object type
- Package-level synchronization / repository-level synchronization
- DDIC / where-used / version detection
## Quick Start
Download `sap-abap-mcp-init/` as an initialization package to your local machine, then select a target directory to execute the initialization script. The script will generate `.mcp.json` and `sap-abap-mcp-lib/` in the target directory, and pre-create `SAP_EXPORT_DIR` and `SAP_STATE_DIR`.
If you already have a target directory, such as `~/workspaces/test-abap`, it will eventually read:
- `~/workspaces/test-abap/.mcp.json`
You only need to modify the environment variables in it, then start Claude Code MCP Host in that target directory.
## Configuration Overview
The configuration of this MCP can be divided into three layers:
1. Public information: system, user, client, language
2. Mode information: current ADT or RFC mode
3. Mode-specific information: ADT base URL / SSL or RFC JCo local library
### Public Parameters
- `SAP_SYSTEM_ID`: system identifier, e.g., `HRD`
- `SAP_HOST`: SAP host address
- `SAP_PORT`: port; if you have configured a complete `SAP_BASE_URL`, this parameter can be omitted
- `SAP_SYSNR`: system number, commonly used in RFC
- `SAP_CLIENT`: client number
- `SAP_USER`: username
- `SAP_PASSWORD`: password
- `SAP_LANG`: login language, e.g., `ZH`
- `SAP_EXPORT_DIR`: source code synchronization output directory, default `sap/sap-code-repository/gm`
- `SAP_STATE_DIR`: local learning / snapshot / rollback state directory,-mcp-state`
### ADT-specific Parameters
- `SAP_MCP_MODE=adt`
- `SAP_BASE_URL`: ADT base address, e.g., `https://10.249.22.11:44300`
- `SAP_AUTH_MODE`: authentication mode, `basic` or `bearer`
- `SAP_VERIFY_SSL`: whether to verify the certificate, `true` or `false`
### RFC-specific Parameters
- `SAP_MCP_MODE=rfc`
- `SAP_JCO_LIBRARY_DIR`: directory of `sapjco3.jar` and local library
If you use RFC mode on macOS usually need to add the following startup parameters:
```text
-Djava.library.path=/path/to/jco/lib
```
This way, Java can find both `sapjco3.jar` and the local dynamic library.
## Understanding the Two Modes
### ADT Mode
ADT mode accesses SAP ADT via HTTP. It is more like "performing object-level operations around the `/sap/bc/adt/` entrance".
Suitable for:
- Searching ABAP objects
- Reading source code or metadata of classes, programs, interfaces, tables, or structures
- Synchronizing packages, function groups, or individual objects
- Recording learning cards and local snapshots
If you are using ADT for the first time, the recommended understanding sequence is:
1. Use `sap_ping` to confirm if `/sap/bc/adt/` is reachable
2. Use `sap_get_system_info` to confirm system information and authentication status
3. Then start object search and source code synchronization
This sequence is beneficial because it is intuitive: first check if the road is passable, then check if the door entered, and finally enter the house to retrieve materials.
### RFC Mode
RFC mode is currently implemented in Java and directly connects to SAP using SAP JCo.
Suitable for:
- Calling RFC functions
- Reading SAP tables
- Querying system information
- Reading abstract query results of some common business objects
If you are using RFC for the first time, the recommended understanding sequence is:
1. Use `sap_system_info` to see which system you are currently connected to
2. Use `sap_call_rfc` to call a basic function and confirm if the channel is3. Then use `_table` or encapsulated business query tools
RFC mode does not use `sap_ping`;_ping` is a tool in ADT mode.
### Additional Dependencies for RFC
RFC mode requires SAP JCo:
- `sapjco3.jar`
- `libsapjcoylib` / `jco3.so` / `sapjco3It is recommended to put these files in your local `lib/` directory.
Then configure `SAP_JCO_LIBRARY_DIR` in `.mcp.json`.
## `.mcp.json` Example
Local configuration file location:
- `~/workspaces/test-abap/.mcp.json`
### Example
```json
{
"mcpServers": {
"sap-abap-mcp": {
"type": "stdio",
"command": "/opt/homebrew/opt/openjdk@17/libexec.jdk/Contents/Home/bin/java",
"args": [
"-Djava=/absolute/path/to/map-tools/lib",
"-jar",
"/absolute/mcp-abap-tools/target/abap-adt-mcp-<version>.jar",
"--transport=stdio"
],
"env": {
SAP_MCP_MODE": "rfc",
"SAP_SYSTEM_ID": "HRD",
"SAP_HOST": "10.249.22.11",
"SAP_SYSNR": "00",
"SAP_CLIENT": "200",
"SAP_USER": "YOUR_USER",
"SAP_PASSWORD": "YOUR_PASSWORD",
"SAP_LANG": "ZH",
"SAP_JCO_LIBRARY_DIR": "/absolute/path/to/mcp-abap-tools/lib"
}
}
}
}
```
### ADT Mode Example
```json
{
"mcpServers": {
"sap-abap-mcp": {
"type": "stdio",
"command": "/brew/opt/openjdk@exec/openjdk.jdk/Contents/Home/bin/java",
args": [
"-jar",
"/absolute/mcp-abap-tools/target/abap-adt-mversion>.jar",
"--transport=stdio"
"env": {
"SAP_MCP_MODE":",
"SAP_BASE_URL": "https://10.249.22.11:44300",
"SAP": "basic",
"SAP_CLIENT": " "SAP_USER": "YOUR_USER",
"SAP_PASSWORD": "YOUR_PASSWORD",
"SAP_VERIFY_SSL": "false",
"SAP_EXPORT_DIR": "sap/sap-code-repository/gm",
"SAP_STATE_DIR": ".sap-mcp-state"
}
}
}
}
```
## Running and Building
### Building
```bash
mvn test
mvn -DskipTests package
```
No additional preparation of the old RFC proxy environment is needed; RFC has been completely switched to Java + SAP JCo.
### Running
```bash17_HOME=/opt/opt/openjdk@exec/openjdk.jdk/Home \
"$_HOME/bin/java" -jar target/abap-adt-mcp-<version>.jar --transport=stdio
```
This service is for MCP Host usage and is suitable for clients like Claude Code, Codex, or Cursor.
Note: It needs to be started by MCP Hostio mode; running it manually in the terminal will fail when stdin is closed.
## Tool Description
### RFC Mode- `sap_system_info`: view system information, connectivity, and login environment
- `sap_call_rfc`: call any RFC function
- `sap_read_table`: read SAP tables
- `sap_switch_system`: switch default system
- `sap_get_cost_center`
- `sap_get_profit_center`
- `sap_get_employee`
- `sap_get_org_units`
### RFC Getting Started
idea of RFC mode is "first confirm which system you are connected to, and then gradually expand the query range".
Use `sap_system_info` to see which system you are currently connected to; if you have configured multiple RFC systems, use `sap_switch_system` to switch to the target system. Once the connection is stable, start with a basic RFC, then read tables and business objects, which will make troubleshooting faster.
### ADT Mode Tools
- `sap_ping`: check ADT root path connectivity
- `sap_get_system_info`: get system information
- `sap_search_objects`: search ABAP objectssap_get_source`: read source code
- `sap_get_class_source`: read source code by class
- `sap_get_program_source`: read source code by program
- `sap_get_metadata`: read object metadata
- `sap_get_package_objects`: list objects in a package
- `sap_get_ddic_object`: resolve DDIC objects
- `sap_where_used`: query object references
- `sap_resolve_scope`: detect which object a name will be recognized as
- `sap_get_sap_version`: read SAP version information
- `sap_check_source`: perform lightweight source code checking
- `sap_sync_scope`: automatically detect object type and synchronize source code to a local directory (including function groups)
- `sap_sync_function_group`: explicitly synchronize function groups
- `sap_sync_object`: synchronize source code to a local directory by specified object type
- `sap_sync_package`: synchronize objects in a package
- `sap_sync_repository`: synchronize repository objects with matching package prefixes
- `sap_sync_status`: view local synchronization status
- `sap_sync_recent_changes`: view recent synchronization changes
- `sap_learn_from_object`: read a single ABAP object and precipitate it as a local learning card
- `sap_learn_status`: view local learning statistics
- `sap_learn_recent_discoveries`: view recent learning discoveries
- `sap_skill_learn_insight`: manually write a reusable knowledge card and automatically create a snapshot
- `sap_skill_create_snapshot`: create a snapshot for learning / synchronization status
- `sap_skill_list_snapshots`: list snapshots
- `sap_skill_changelog`: view local change records
- `sap_skill_rollback`: roll back local learning or synchronization status by snapshot
- `sap_preview_update`: preview source code updates and generate confirmation tokens
- `sap_update_and_activate`: apply confirmed updates and activate objects ADT Getting Started
are using ADT for time, understand it in this order:
1sap_ping`
`sap_get_system_info`
3. `_objects` / `_source`
4. `sap_sync_scope` /_sync_package`
The goal of this sequence is not to "do more steps" but to separate troubleshooting and usage confirm system reachability, then confirm authentication and object entrance, and finally perform synchronization and learning.
## Initialization Package
If you want to initialize basic resources to a new target directory, use:
- `sap-abap-mcp-initThis directory contains:
- Functional documentation in Markdown versions
- `..json` examples for ADT / RFC
- Version copyright information
- and skill descriptions
`sap-abap-init/` in the documentation, skills, and example configurations
- The target directory generates `.mcp.json` and `ap-mcp-lib/ pre-creates `_DIR` and `SAP_STATE_DIR`
- `ap-mcp-lib/` only contains runtime librariesCo, and mode records
- Supports `--mode adt|rfc` switching when generating to the target directory
### Learning and Rollback Description
This Java MCP reads SAP source code but also precipitates local knowledge:
- `sap_learn_from_object`: suitable for extracting patterns from classes, programs, interfaces, or function groups
- `sap_skill_learn_insight`: suitable for manually sorting out experiences, specifications, anti-patterns, or example fragments
- `sap_skill_create_snapshot`: manually leave a rollback point before major changes
- `sap_skill_rollback`: use when learning content is contaminated or you want to restore the synchronization status
By default, these contents are written to `SAP_STATE_DIR`, so you can treat it as a local "rollable knowledge repository".
## Frequently Asked Questions
### 1) ADT is reachable but returns 401
This usually indicates:
- The server is online, and `/sap/bc/adt/` is accessible
- But authentication failed, or the current user does not have ADT permissions
Prioritize checking:
- Is the username / password correct?
- Is `SAP_CLIENT` correct?
- Does the user have ADT access permissions?
- Is the user status, lock status, or password expiration statusSU01` that needs to be checked?
If the response already contains `sap-client=100`, prioritizeSAP_CLIENT` to `100` and do with other client numbers.
### 2) Why does `sap_sync_package` return 404 for `ZDTDHR_SHARE`?
This indicates that the current system does not expose `ZDTDHR_SHARE` as an accessible ADT package entrance.
In this case, use:
- `sap_sync_scope(name="ZDTDHR_SHARE")`
It will detect and download
MCP Config
Below is the configuration for this MCP Server. You can copy it directly to Cursor or other MCP clients.
mcp.json
Connection Info
You Might Also Like
No recommendations available