thupalo/sap-rfc-mcp-server
If you are the rightful owner of sap-rfc-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 henry@mcphub.com.
A Model Context Protocol (MCP) server that integrates with SAP systems using RFC connections, enabling AI assistants and applications to interact with SAP functions.
SAP RFC MCP Server
A Model Context Protocol (MCP) server that provides seamless integration with SAP systems through RFC (Remote Function Call) connections. This server enables AI assistants and applications to interact with SAP functions, retrieve metadata, and perform operations with enhanced caching and version compatibility.
๐ Features
Core Functionality
- SAP RFC Integration: Direct connection to SAP systems using pyrfc
- MCP Server: Full Model Context Protocol implementation for AI assistant integration
- HTTP Server: RESTful API for web-based integrations
- Version-Aware: Automatic detection and compatibility with SAP R/3 4.5B through S/4HANA
Enhanced Metadata Management
- Intelligent Caching: Persistent file-based cache with TTL and compression
- Metadata Search: Fast text-based search through cached RFC function metadata
- Bulk Operations: Parallel loading and processing of multiple functions
- RAG Optimization: Export metadata in formats optimized for Retrieval-Augmented Generation
Advanced Development Tools
- Port Management: Automatic port conflict detection and resolution
- Smart Startup: Intelligent server startup with process management
- VS Code Integration: Complete development environment with tasks and snippets
- Table Access Tools: Enhanced SAP table operations with comprehensive error handling
Language Support
- Multi-Language: Support for English, Polish, German, French, Spanish descriptions
- Version-Aware Language Handling: Automatic detection of SAP version and appropriate language code mapping
- Legacy Compatibility: Proper handling of single-letter language codes for older SAP systems (R/3 4.5B)
Security & Configuration
- Interactive Security Manager: Secure credential setup with multiple storage methods (encrypted files, system keyring, environment variables)
- Secure Configuration: Encrypted storage of SAP connection parameters with automatic method detection
- Environment Variables: Support for secure credential management
- Connection Pooling: Efficient connection management and reuse
๐ Requirements
System Requirements
- Python 3.9 or higher
- SAP NetWeaver RFC SDK (for pyrfc)
- Access to SAP system with RFC connectivity
SAP System Compatibility
- โ SAP R/3 4.5B and higher
- โ SAP ECC 6.0/6.1
- โ SAP ECC with Enhancement Packages
- โ SAP S/4HANA (all versions)
๐ Installation
Automated Setup (Recommended)
# Clone the repository
git clone https://github.com/thupalo/sap-rfc-mcp-server.git
cd sap-rfc-mcp-server
# Automated development environment setup (includes SAP NetWeaver RFC SDK validation)
python tools/setup_dev.py
๐ Enhanced Setup: The automated setup now includes comprehensive SAP NetWeaver RFC SDK validation and provides detailed troubleshooting guidance if prerequisites are not met.
Manual Installation
1. Install SAP NetWeaver RFC SDK
Download and install the SAP NetWeaver RFC SDK from SAP Service Marketplace:
2. Install Python Package
# Clone the repository
git clone https://github.com/thupalo/sap-rfc-mcp-server.git
cd sap-rfc-mcp-server
# Install dependencies
pip install -e .
# For development
pip install -e ".[dev]"
3. Configure SAP Connection
๐ Recommended: Interactive Security Manager (Preferred Method)
The SAP Security Manager provides secure, interactive configuration with multiple storage options:
# Interactive setup with secure credential management
python -m sap_rfc_mcp_server.sap_security_manager setup
# Test your configuration with connection validation
python -m sap_rfc_mcp_server.sap_security_manager test
# View your security configuration status
python -m sap_rfc_mcp_server.sap_security_manager info
Available Security Methods:
- Environment Variables: Direct system environment (always available)
- .env Files: File-based configuration (requires python-dotenv)
- System Keyring: OS credential manager (requires keyring package)
- Encrypted Files: Password-protected encrypted storage (requires cryptography package)
๐ Alternative: Manual .env Configuration
For quick setup or CI/CD environments, create a .env
file in the project root:
# SAP Connection Parameters
SAP_ASHOST=your-sap-hostname
SAP_SYSNR=00
SAP_CLIENT=100
SAP_USER=your-username
SAP_PASSWD=your-password
SAP_LANG=EN
# Optional: Advanced Connection Settings
SAP_SAPROUTER=your-saprouter
SAP_POOL_SIZE=10
SAP_TRACE=0
๐ Migration Between Methods
# Migrate from .env to encrypted storage
python -m sap_rfc_mcp_server.sap_security_manager migrate
๐ Quick Start
๐ Secure Configuration Setup (Recommended)
# Interactive secure configuration with the Security Manager
python -m sap_rfc_mcp_server.sap_security_manager setup
# Test your SAP connection
python -m sap_rfc_mcp_server.sap_security_manager test
Smart Server Startup (Recommended)
# Intelligent startup with automatic port management
python tools/start_mcp_smart.py
# Alternative PowerShell startup
.\tools\start_sap_mcp_server.ps1 -Mode http -Port 8000
Manual Server Startup
MCP Server (for AI Assistants)
# Start the MCP server
python -m sap_rfc_mcp_server.server
# The server will be available via stdio for MCP clients
HTTP Server (for Web Applications)
# Start the HTTP server
python -m sap_rfc_mcp_server.http_server 127.0.0.1 8000
# Server will be available at http://localhost:8000
# API documentation at http://localhost:8000/docs
Port Management
# Check port availability
python tools/port_manager.py --suggest
# Check specific port
python tools/port_manager.py --check 8000
# Release MCP processes
python tools/port_manager.py --release-mcp 8000 8020
Python API Usage
from sap_rfc_mcp_server import SAPRFCManager, RFCMetadataManager
# Initialize SAP client
sap_client = SAPRFCManager()
# Call RFC function
result = sap_client.call_rfc_function(
function_name="RFC_READ_TABLE",
parameters={
"QUERY_TABLE": "T001",
"DELIMITER": "|",
"ROWCOUNT": 10
}
)
# Initialize metadata manager for enhanced capabilities
metadata_manager = RFCMetadataManager(
connection_params=sap_client.config.to_connection_params()
)
# Get function metadata with caching
metadata = metadata_manager.get_function_metadata(
"RFC_READ_TABLE",
language="EN"
)
# Search for functions
search_results = metadata_manager.search_functions("table")
# Bulk load metadata
functions = ["RFC_READ_TABLE", "DDIF_FIELDINFO_GET", "RFC_GET_FUNCTION_INTERFACE_US"]
bulk_metadata = metadata_manager.bulk_load_metadata(functions, language="EN")
๐ Documentation
๐ Project Structure
sap-rfc-mcp-server/
โโโ sap_rfc_mcp_server/ # Main application package
โโโ tools/ # Development tools and utilities
โ โโโ start_mcp_smart.py # Smart server startup
โ โโโ port_manager.py # Port management utility
โ โโโ sap_dev_helper.py # Development helper tools
โ โโโ setup_dev.py # Environment setup
โ โโโ README.md # Tools documentation
โโโ docs/ # Technical documentation
โ โโโ VSCODE_INTEGRATION_GUIDE.md
โ โโโ PORT_MANAGEMENT_GUIDE.md
โ โโโ TABLE_ACCESS_REPAIR_SUMMARY.md
โ โโโ README.md # Documentation index
โโโ tests/ # Unit and integration tests
โโโ examples/ # Usage examples
โโโ README.md # This file
๐ ๏ธ Development Tools
- - Complete guide to development utilities
- - Server and port management
- - Development environment setup
๐ Technical Documentation
- - Complete documentation overview
- - SAP table operations
- - Project achievements
๐งช Testing
Automated Testing
# Test development tools
python tools/sap_dev_helper.py --system-info
python tools/sap_dev_helper.py --test-table T000
# Run unit tests
pytest tests/
# Run with coverage
pytest --cov=sap_rfc_mcp_server
Development Environment Testing
# Test VS Code integration
python tools/test_vscode_integration.py
# Verify SAP connection
python tools/test_direct_sap.py
# Test MCP server functionality
python tools/test_metadata_stdio.py
๏ฟฝ๏ธ VS Code Integration (MCP 2025)
The SAP RFC MCP server integrates natively with VS Code through the Model Context Protocol for enhanced AI-assisted development.
Quick VS Code Setup
# Automated setup creates .vscode/mcp.json configuration
python tools/setup_dev.py
Manual VS Code MCP Configuration
Create .vscode/mcp.json
in your workspace:
{
"servers": {
"sap-rfc-server": {
"command": "./venv/Scripts/python.exe",
"args": ["-m", "sap_rfc_mcp_server.server"],
"cwd": "./",
"env": {
"SAP_RFC_MCP_CONFIG": "./.env"
}
}
}
}
Features Available in VS Code
- ๐ค Agent Mode Integration: SAP tools available to VS Code's built-in agent
- ๐ง GitHub Copilot Enhancement: Copilot can access SAP data and metadata
- ๐ Workspace-Specific: MCP configuration isolated per workspace
- ๐ Auto-Discovery: VS Code automatically loads MCP servers on workspace open
Usage in VS Code
- Open workspace with
.vscode/mcp.json
configuration - Enable GitHub Copilot agent mode (if using Copilot)
- Ask questions like:
- "Get SAP system information"
- "Search for SAP functions containing 'USER'"
- "Show metadata for RFC_READ_TABLE function"
- "List SAP tables starting with 'T0'"
๐ Complete Guide: See for detailed setup instructions.
๏ฟฝ๐ง Development
Quick Development Setup
# Automated setup (recommended)
python tools/setup_dev.py
# Manual VS Code setup
code . # Open in VS Code
# Select Python interpreter: ./venv/Scripts/python.exe
Development Tools Usage
# Security configuration management
python -m sap_rfc_mcp_server.sap_security_manager --help
# Port management
python tools/port_manager.py --help
# Development helpers
python tools/sap_dev_helper.py --help
# Smart server startup
python tools/start_mcp_smart.py
Code Quality
# Install development dependencies
pip install -e ".[dev]"
# Run code formatting
black sap_rfc_mcp_server tests
isort sap_rfc_mcp_server tests
# Type checking
mypy sap_rfc_mcp_server
Project Structure
sap-rfc-mcp-server/
โโโ sap_rfc_mcp_server/ # Main package
โ โโโ __init__.py
โ โโโ server.py # MCP server implementation
โ โโโ http_server.py # HTTP server implementation
โ โโโ sap_client.py # SAP RFC client
โ โโโ metadata_manager.py # Enhanced metadata management
โ โโโ metadata_cache.py # Persistent caching system
โ โโโ config.py # Configuration management
โ โโโ secure_config.py # Secure configuration handling
โ โโโ sap_security_manager.py # Interactive security manager with multiple storage methods
โโโ tests/ # Test suite
โโโ examples/ # Usage examples
โโโ docs/ # Documentation
โโโ cache/ # Default cache directory
โโโ pyproject.toml # Project configuration
โโโ README.md # This file
โโโ LICENSE # MIT License
โโโ CHANGELOG.md # Version history
๐ Performance
Caching Benefits
- First Call: Direct SAP RFC call (~200-500ms)
- Cached Call: File-based cache retrieval (~1-5ms)
- Search: Indexed text search (~1-10ms)
- Bulk Operations: Parallel processing with connection pooling
Memory Usage
- Base Server: ~50MB
- With Cache: +10-50MB (depending on cached functions)
- Connection Pool: +5-20MB per connection
๐ค Contributing
We welcome contributions! Please see our for details.
Development Workflow
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Make your changes
- Add tests for new functionality
- Run the test suite (
pytest
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
๐ License
This project is licensed under the MIT License - see the file for details.
๐ Support
Common Issues
Getting Help
- ๐ง Email: sap-rfc-mcp@example.com
- ๐ Report Issues
- ๐ฌ Discussions
๐ Changelog
See for a list of changes and version history.
๐ Acknowledgments
- SAP AG for the RFC SDK and documentation
- The pyrfc project for Python RFC connectivity
- The Model Context Protocol community
- All contributors who have helped improve this project
Note: This is not an official SAP product. SAP and other SAP products mentioned herein are trademarks or registered trademarks of SAP SE in Germany and other countries.