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.
README
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
- Tools README - Complete guide to development utilities
- Port Management Guide - Server and port management
- VS Code Integration - Development environment setup
📚 Technical Documentation
- Documentation Index - Complete documentation overview
- Table Access Guide - SAP table operations
- Integration Success - 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.jsonconfiguration - 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 VS Code Integration Guide 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 Contributing Guidelines 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 LICENSE file for details.
🆘 Support
Common Issues
Getting Help
- 📧 Email: sap-rfc-mcp@example.com
- 🐛 Report Issues
- 💬 Discussions
🔄 Changelog
See CHANGELOG.md 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.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。