serdarbeden/abap-adt-mcp-server
If you are the rightful owner of abap-adt-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
Model Context Protocol (MCP) server for accessing ABAP source code and metadata from SAP S/4HANA systems via the ABAP Development Tools (ADT) REST API.
ABAP ADT MCP Server
Model Context Protocol (MCP) server for accessing ABAP source code and metadata from SAP S/4HANA systems via the ABAP Development Tools (ADT) REST API.
Overview
This MCP server enables Claude to read and analyze ABAP code directly from your S/4HANA system using the same REST API that Eclipse ADT uses. Perfect for:
- 🔍 Code analysis and refactoring
- 📚 Understanding RAP business objects
- 🏗️ Architecture reviews
- 🔄 Modernization planning (move from classic ABAP to RAP)
- 📖 Learning from existing implementations
All operations are read-only - the server cannot modify any code in your SAP system.
Features
Tools Available
-
abap_read_object_source- Read source code of any ABAP object- Classes, interfaces, CDS views, behavior definitions, programs, function groups, etc.
- Support for both active and inactive versions
-
abap_browse_package- Browse package contents- List all objects in a package
- Filter by object types
- Include/exclude subpackages
-
abap_search_objects- Search for objects by name- Wildcard support (
*TRAVEL*,ZCL_*, etc.) - Filter by package and object type
- Wildcard support (
-
abap_read_rap_object- Read complete RAP business object- Interface CDS view, behavior definition, projection, metadata extension
- All related artifacts in one call
-
abap_get_where_used- Get where-used list- Impact analysis for refactoring
- See all objects that use a specific object
-
abap_read_ddic_structure- Read DDIC structure field definitions- Complete field list with data types, lengths, descriptions
- Key fields, includes, and nested structures
- Works for tables and structures
-
abap_read_ddic_metadata- Read DDIC object metadata- Data elements (DTEL): domain, labels, search help
- Domains (DOMA): data type, length, value range, conversion exit
- Table types (TTYP): row type, access type, key definition
Supported ABAP Object Types
- Object-Oriented: Classes (CLAS), Interfaces (INTF)
- CDS & RAP: CDS Views (DDLS), Metadata Extensions (DDLX), Behavior Definitions (BDEF), Service Definitions (SRVD), Service Bindings (SRVB)
- Classic ABAP: Programs (PROG), Function Groups (FUGR), Function Modules (FUNC)
- Dictionary: Tables (TABL), Structures (TABL/DS), Data Elements (DTEL), Domains (DOMA), Table Types (TTYP)
Prerequisites
- SAP S/4HANA system (on-premise or cloud)
- ADT REST API enabled (
/sap/bc/adt) - User account with appropriate SAP authorizations:
S_DEVELOP- Development authorizationS_RFC- RFC authorization (for ADT)- Read access to relevant packages
Installation
1. Build the Server
cd abap-adt-mcp-server
npm install
npm run build
This creates the compiled JavaScript in the dist/ folder.
2. Configure Claude Desktop
Add to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"abap-adt": {
"command": "node",
"args": ["/absolute/path/to/abap-adt-mcp-server/dist/index.js"],
"env": {
"ADT_BASE_URL": "https://your-s4hana-host:8000/sap/bc/adt",
"ADT_USERNAME": "YOUR_USERNAME",
"ADT_PASSWORD": "YOUR_PASSWORD",
"ADT_CLIENT": "100",
"ALLOWED_PACKAGES": "Z_RAP_*,Z_MYAPP,/DMO/"
}
}
}
}
3. Environment Variables
| Variable | Required | Description | Example |
|---|---|---|---|
ADT_BASE_URL | ✅ Yes | Full URL to ADT API endpoint | https://sap.company.com:8000/sap/bc/adt |
ADT_USERNAME | ✅ Yes | SAP username | DEVELOPER01 |
ADT_PASSWORD | ✅ Yes | SAP password | YourPassword123 |
ADT_CLIENT | ⚠️ Optional | SAP client number | 100 (default) |
ALLOWED_PACKAGES | ⚠️ Optional | Comma-separated package whitelist | Z_SALES,Z_RAP_* |
Security Note: Store credentials securely. Consider using environment variables or secure credential storage instead of hardcoding passwords in config files.
4. Package Access Control
Use ALLOWED_PACKAGES to restrict access to specific packages for security:
"ALLOWED_PACKAGES": "Z_RAP_TRAVEL,Z_RAP_SALES,Z_CORE_*,/DMO/"
Supports wildcards:
Z_RAP_*matches any package starting withZ_RAP_- Leave empty or omit to allow all packages (less secure)
5. Restart Claude Desktop
After configuration, restart Claude Desktop to load the MCP server.
Real-World Usage Scenarios
Scenario 1: RAP Refactoring - Modernizing Classic ABAP to RAP
Situation: You have a classic ABAP application and want to migrate it to RAP.
Conversation with Claude:
You: I need to refactor our classic ABAP travel booking application to use RAP.
The old code is in package Z_TRAVEL_CLASSIC. Can you analyze it and suggest
a RAP structure?
Claude: I'll analyze your current implementation and design a RAP structure for you.
[Reads package contents]
[Reads relevant programs and function groups]
[Analyzes the data model]
Based on your current implementation, here's my recommended RAP structure:
1. Data Model (CDS Views):
- Z_I_TRAVEL (Interface view)
- Z_I_BOOKING (Interface view)
- Z_C_TRAVEL (Consumption/Projection view)
- Z_C_BOOKING (Consumption/Projection view)
2. Behavior:
- Z_I_TRAVEL behavior definition with:
* create, update, delete actions
* determinations for travel_id, begin_date validation
* validations for dates, customer_id
- Association to Z_I_BOOKING
[Provides detailed implementation suggestions with code examples]
You: Can you show me the current BAPI implementation for creating bookings?
I want to understand the validations we're currently doing.
Claude: [Reads the relevant function module and shows the current validation logic]
You: Now help me create the behavior definition with those same validations.
Claude: [Generates a complete BDEF with all validations converted to RAP syntax]
Scenario 2: Code Quality Review
Situation: Review code quality before a production release.
You: I need to review all classes in package Z_SALES_ORDER for code quality.
Look for:
1. Classes with very long methods (>100 lines)
2. Duplicate code patterns
3. Poor naming conventions
4. Missing error handling
Claude: I'll analyze all classes in Z_SALES_ORDER for you.
[Browses package]
[Reads each class]
[Analyzes code patterns]
Found the following quality issues:
1. ZCL_SALES_PROCESSOR:
- Method PROCESS_ORDER is 247 lines (should be refactored)
- Three similar validation code blocks that could be extracted
- Exception handling missing in database operations
2. ZCL_SALES_HELPER:
- Method name 'DO_IT' is not descriptive
- [Additional issues...]
Recommendations:
[Detailed refactoring suggestions with code examples]
Scenario 3: Understanding RAP Business Object
Situation: Learning how a RAP BO is implemented.
You: I'm new to RAP. Can you explain how the SAP Demo Travel RAP
business object works? The root entity is /DMO/I_TRAVEL_M.
Claude: I'll read the complete RAP business object and explain its structure.
[Uses abap_read_rap_object to get all artifacts]
The Travel RAP business object demonstrates:
1. **Data Model** (/DMO/I_TRAVEL_M):
[Shows and explains the CDS view structure]
2. **Behavior Definition**:
- Managed implementation with save
- Actions: acceptTravel, rejectTravel, deductDiscount
- Determinations: setStatusToOpen (on modify)
- Validations: validateCustomer, validateDates
[Shows specific code examples]
3. **Projection Layer** (/DMO/C_TRAVEL_M):
[Explains consumption view and exposed actions]
4. **UI Annotations** (Metadata Extension):
[Shows how UI is defined]
Would you like me to explain any specific aspect in detail?
Scenario 4: Impact Analysis for Refactoring
Situation: Planning to change a shared utility class.
You: I want to refactor the method CALCULATE_PRICE in ZCL_PRICING_ENGINE.
First, tell me everywhere this class is used so I understand the impact.
Claude: Let me check the where-used list for ZCL_PRICING_ENGINE.
[Uses abap_get_where_used]
This class is used in 23 places:
1. Classes (12):
- ZCL_SALES_ORDER_PROCESSOR
- ZCL_INVOICE_GENERATOR
- [...]
2. Programs (3):
- Z_BATCH_PRICING_UPDATE
- [...]
The CALCULATE_PRICE method signature change will affect all callers.
Let me read some of the most critical usages to understand how the method
is being called...
[Reads specific implementations]
Here's my impact analysis and migration strategy:
[Detailed plan for safe refactoring]
Scenario 5: Performance Optimization
Situation: Analyzing CDS views for performance issues.
You: Our CDS view Z_I_SALES_ANALYTICS is slow. Can you analyze it and
suggest optimizations?
Claude: I'll read the CDS view and analyze its structure.
[Reads the CDS view]
I found several performance issues:
1. **No database hints**: Missing /*+ INDEX(...) */ hints
2. **Inefficient joins**: Left outer join on MARA could be inner join
3. **Too many fields**: Selecting all fields but only 10 are used
4. **Missing where clause**: No partition/filtering early
Optimized version:
[Shows optimized CDS view code with explanations]
Also, let me check if there's an associated consumption view...
[Analyzes the complete view stack]
Scenario 6: Learning RAP Patterns
Situation: Developer wants to learn RAP best practices.
You: Show me examples of RAP authorization handling. Search for behavior
definitions in /DMO/ package that use authorization.
Claude: I'll search for behavior definitions and show you authorization examples.
[Searches for BDEF objects in /DMO/]
[Reads several BDEFs]
Here are different authorization patterns used in SAP demo content:
1. **Instance Authorization** (/DMO/I_TRAVEL_M):
[Shows authorization master example]
2. **Global Authorization** (/DMO/I_BOOKING_M):
[Shows global authorization example]
3. **Dynamic Authorization** (with conditions):
[Shows conditional authorization example]
Best practices I can derive from these:
[Lists best practices with code examples]
Scenario 7: API Migration
Situation: Migrating from BAPI to RAP service.
You: We have consumers using BAPI_SALESORDER_CREATEFROMDAT2. I want to
provide the same functionality via a RAP service. Help me design the
service interface.
Claude: Let me read the BAPI implementation to understand the functionality.
[Reads function module]
[Analyzes parameters and implementation]
The BAPI provides these capabilities:
1. Order header creation
2. Item creation with pricing
3. Partner data handling
4. Validations: [lists validations]
Here's how to expose equivalent functionality via RAP:
1. **Service Definition**:
[Shows service definition code]
2. **Behavior Definition** (with actions):
[Shows BDEF with equivalent actions]
3. **Parameter mapping**:
Old BAPI | New RAP Action
[Shows mapping table]
4. **Implementation Class**:
[Shows example implementation]
Scenario 8: Understanding Data Dictionary Objects
Situation: Analyzing data structures and understanding data elements.
You: I need to understand the structure of table BAPIRET2.
What fields does it have and what are their data types?
Claude: Let me read the structure definition for you.
[Uses abap_read_ddic_structure]
The BAPIRET2 structure has 12 fields:
| Field | Data Element | Type | Length | Description |
|-------|-------------|------|--------|-------------|
| TYPE | BAPI_MTYPE | CHAR | 1 | Message type: E/W/I/S |
| ID | SYMSGID | CHAR | 20 | Message ID |
| NUMBER | SYMSGNO | NUMC | 3 | Message Number |
| MESSAGE | BAPI_MSG | CHAR | 220 | Message Text |
| LOG_NO | BALOGNR | CHAR | 20 | Application Log Number |
| LOG_MSG_NO | BALMNR | NUMC | 6 | Application Log Message Number |
| MESSAGE_V1 | SYMSGV | CHAR | 50 | Message variable 1 |
| MESSAGE_V2 | SYMSGV | CHAR | 50 | Message variable 2 |
| MESSAGE_V3 | SYMSGV | CHAR | 50 | Message variable 3 |
| MESSAGE_V4 | SYMSGV | CHAR | 50 | Message variable 4 |
| PARAMETER | BAPI_PARAM | CHAR | 32 | Parameter Name |
| ROW | BAPI_LINE | INT4 | 10 | Line in parameter |
This is the standard BAPI return message structure used across SAP.
You: Can you show me the details of the data element SYMSGV?
Claude: [Uses abap_read_ddic_metadata]
Data Element: SYMSGV
- Description: Message variable
- Based on Domain: SYMSGV
- Data Type: CHAR(50)
- Field Labels:
* Short: Mes. var.
* Medium: Message variable
* Long: Message variable
You: What about the domain SYMSGV itself?
Claude: [Uses abap_read_ddic_metadata]
Domain: SYMSGV
- Data Type: CHAR
- Length: 50 characters
- Output Length: 50
- Package: SAPMSSY1
- No conversion exit
- No fixed values
This domain provides a generic 50-character field suitable for
message variables, similar to SY-MSGV1 through SY-MSGV4 in standard SAP.
Advanced Configuration
Self-Signed Certificates (Development Only)
For development systems with self-signed certificates:
"env": {
"NODE_TLS_REJECT_UNAUTHORIZED": "0",
...
}
⚠️ Warning: Never use this in production. Use proper SSL certificates.
Multiple SAP Systems
Configure separate MCP servers for different systems:
{
"mcpServers": {
"abap-adt-dev": {
"command": "node",
"args": ["/path/to/dist/index.js"],
"env": {
"ADT_BASE_URL": "https://dev-system:8000/sap/bc/adt",
...
}
},
"abap-adt-prod": {
"command": "node",
"args": ["/path/to/dist/index.js"],
"env": {
"ADT_BASE_URL": "https://prod-system:8000/sap/bc/adt",
...
}
}
}
}
Troubleshooting
Connection Issues
Error: No response from SAP system
Solutions:
- Verify
ADT_BASE_URLis correct - Check SAP system is running:
ping your-sap-host - Test ADT endpoint:
curl https://your-sap-host:8000/sap/bc/adt - Check firewall rules allow access to SAP ports
Authentication Issues
Error: Authentication failed
Solutions:
- Verify username and password are correct
- Check user is unlocked in SAP (transaction SU01)
- Verify user has S_DEVELOP and S_RFC authorizations
- Check client number is correct
Object Not Found
Error: Object not found
Solutions:
- Verify object name is spelled correctly (case-sensitive)
- Check object type is correct
- Use
abap_search_objectsto find the object - Verify you have read authorization for the object
Package Access Denied
Error: Package not in allowed list
Solutions:
- Add package to
ALLOWED_PACKAGESenvironment variable - Use wildcards:
Z_RAP_*to allow all Z_RAP_* packages - Remove
ALLOWED_PACKAGESto allow all (less secure)
Performance Tips
- Use specific object types when browsing/searching to reduce results
- Use JSON format for large objects to reduce formatting overhead
- Limit search results with
max_resultsparameter - Use package filters to narrow searches
- Request specific artifacts instead of entire RAP objects when you only need one file
Security Best Practices
- ✅ Use package whitelisting (
ALLOWED_PACKAGES) - ✅ Create dedicated SAP user with minimal required authorizations
- ✅ Use display-only authorization (no change/delete authorization needed)
- ✅ Secure credential storage - don't hardcode passwords
- ✅ Enable SSL/TLS for SAP connection
- ✅ Audit access - monitor ADT API access logs in SAP
- ❌ Never expose to public internet
- ❌ Don't use
NODE_TLS_REJECT_UNAUTHORIZED=0in production
Architecture
┌─────────────┐ ┌─────────────────┐ ┌──────────────┐
│ Claude │ ◄─MCP──►│ ABAP ADT MCP │ ◄─HTTP─►│ S/4HANA │
│ Desktop │ │ Server │ │ ADT API │
└─────────────┘ └─────────────────┘ └──────────────┘
│ │
│ │
stdio transport /sap/bc/adt
(REST API)
Contributing
Contributions welcome! Areas for improvement:
- Additional object type support (service bindings metadata, more DDIC types)
- Syntax checking integration
- Code completion suggestions
- Unit tests and integration tests
- Better error messages
- Performance optimizations
- Support for ABAP Cloud restrictions validation
License
MIT
Disclaimer
This is an independent project and is not affiliated with, endorsed by, or supported by SAP SE or Anthropic.
Important:
- This tool provides READ-ONLY access to your SAP system
- Always follow your organization's security policies
- Test thoroughly in development before using with production systems
- The server cannot modify any code in your SAP system
- Ensure you have proper authorization to access ABAP source code
Support
For issues and questions:
- Check the troubleshooting section above
- Review Claude's error messages - they include helpful troubleshooting steps
- Check SAP ADT API documentation
- Verify SAP system authorizations
Version History
-
1.1.0 - DDIC Enhancements (Current)
- Added
abap_read_ddic_structure- Read structure/table field definitions - Added
abap_read_ddic_metadata- Read data element, domain, and table type metadata - Enhanced TABL support with automatic structure vs table detection
- Support for namespace objects with proper URI encoding
- Added
-
1.0.0 - Initial release
- Read ABAP objects (CLAS, INTF, DDLS, BDEF, PROG, FUGR)
- Browse packages
- Search objects
- Read RAP business objects
- Where-used lists
- Package access control
- Comprehensive error handling