How to Connect SAP HANA to MCP for AI Agents
Connect SAP S/4HANA, SAP Business One, and SAP ERP to AI agents via MCP. Access OData services and REST APIs through the AnythingMCP dashboard.
SAP Meets AI: The MCP Bridge
SAP systems power the world's largest enterprises, managing everything from supply chains to financial reporting. By connecting SAP to MCP with AnythingMCP, AI agents can access accounts, orders, materials, and financial data through natural language.
SAP Integration Methods
AnythingMCP connects to SAP through its standard APIs:
| Method | SAP System | Connector Type | |---|---|---| | OData v2/v4 | S/4HANA, BTP | REST connector | | REST API | SAP BTP, SuccessFactors | REST connector | | SOAP/RFC | ECC, PI/PO | SOAP connector |
Step-by-Step Guide
Step 1: Deploy AnythingMCP
git clone https://github.com/HelpCode-ai/anythingmcp.git
cd anythingmcp && docker compose up -d
This starts PostgreSQL, the backend API (port 4000), and the dashboard (port 3000).
Step 2: Create a REST Connector for SAP OData
Open the AnythingMCP dashboard at http://localhost:3000 and create a new REST connector. For SAP S/4HANA OData services, provide the base URL (e.g., https://your-sap.com/sap/opu/odata/sap) and import the OData metadata as an OpenAPI spec.
Step 3: Configure SAP Authentication
In the connector settings, configure authentication:
- On-Premise SAP: Use Basic auth with your SAP technical user
- SAP BTP / Cloud: Use OAuth 2.0 with your Azure AD or SAP IAS credentials
- SAP API Hub: Use API key authentication
Set the sap-client header and x-csrf-token: fetch header for write operations.
Step 4: Review and Customize Tools
AnythingMCP generates MCP tools from the SAP OData service definition. In the dashboard, review each tool, customize names and descriptions, and select which operations to expose.
Step 5: Test and Connect
Test each tool in the dashboard, then configure your MCP client:
{
"mcpServers": {
"sap": {
"url": "http://localhost:4000/mcp"
}
}
}
Real-World AI Use Cases with SAP
- "What's the inventory level for material 4711 across all plants?"
- "Create a purchase order for 500 units of raw material X"
- "Show me all overdue invoices from customer ABC Corp"
- "What's our revenue this quarter compared to last?"
- "Find all open sales orders for the EMEA region"
Best Practices
- Start with read-only OData — Query business partners, materials, and orders before enabling write operations
- Use SAP API Business Hub — Test with sandbox APIs before connecting to production
- CSRF tokens — Set
x-csrf-token: fetchheader for write operations - Use a technical user — Create a dedicated SAP user with minimal required authorizations
- Test in sandbox — Always test in a non-production SAP system first
Next Steps
- SOAP to MCP Guide — For SAP systems using SOAP/RFC
- REST to MCP Guide — General REST patterns