SAP OData to MCP Server

SAP OData to MCP Server

Transforms SAP S/4HANA or ECC systems into conversational AI interfaces by exposing all OData services as dynamic MCP tools. Enables natural language interactions with ERP data for querying, creating, updating, and deleting business entities through SAP BTP integration.

Category
访问服务器

README

SAP OData to MCP Server for BTP🚀

🎯 Project Goal

Transform your SAP S/4HANA or ECC system into a conversational AI interface by exposing all OData services as dynamic MCP tools. This enables natural language interactions with your ERP data:

  • "Show me 10 banks" → Automatically queries the Bank entity with $top=10
  • "Update bank with ID 1 to have street number 5" → Executes PATCH operation on Bank entity
  • "Create a new customer with name John Doe" → Performs POST to Customer entity
  • "List all purchase orders from this week" → Applies $filter for date range on PurchaseOrder entity

🏗️ Architecture Overview

graph TB
    A[AI Agent/LLM] --> B[MCP Client]
    B --> C[SAP MCP Server]
    C --> D[SAP BTP Destination]
    D --> E[SAP SAP System]
    
    C --> F[Dynamic Service Discovery]
    F --> G[OData Catalog API]
    C --> H[CRUD Tool Generation]
    H --> I[Entity Metadata Parser]
    
    style A fill:#e1f5fe
    style C fill:#f3e5f5
    style E fill:#e8f5e8

Core Components:

  1. 🔍 Service Discovery Engine: Automatically discovers all available OData services from SAP
  2. ⚙️ Dynamic Tool Generator: Creates MCP tools for CRUD operations on each discovered entity
  3. 🔌 MCP Protocol Layer: Full compliance with MCP 2025-06-18 specification
  4. 🌐 HTTP Transport: Session-based Streamable HTTP for web applications
  5. 🔐 BTP Integration: Seamless authentication via SAP BTP Destination service

Key Features

🎨 Natural Language to OData

  • Smart Query Translation: Converts natural language to proper OData queries
  • Context-Aware Operations: Understands entity relationships and constraints
  • Parameter Inference: Automatically maps user intent to tool parameters

🔄 Dynamic CRUD Operations

  • Read Operations: Entity sets with filtering, sorting, pagination
  • Create Operations: New entity creation with validation
  • Update Operations: Partial and full entity updates
  • Delete Operations: Safe entity deletion with confirmation

🚀 Production-Ready

  • Session Management: Automatic session creation and cleanup
  • Error Handling: Comprehensive error handling with user-friendly messages
  • Logging: Detailed logging for debugging and monitoring
  • Security: DNS rebinding protection, CORS, Helmet security

📊 Real-Time Metadata

  • Service Catalog: Live discovery of available services
  • Entity Schemas: Dynamic schema generation from OData metadata
  • Capability Detection: Automatic detection of CRUD capabilities per entity

🏛️ System Architecture

┌─────────────────────┐    ┌───────────────────────────┐    ┌─────────────────────┐
│                     │    │                           │    │                     │
│   🤖 AI Agent       │    │   🖥️  SAP MCP Server     │    │   🏢 SAP            │
│   - Claude          │◄──►│   - Service Discovery     │◄──►│   - OData Services  │
│   - GPT-4           │    │   - CRUD Tool Registry    │    │   - Business Logic  │
│   - Local LLMs      │    │   - Session Management    │    │   - Master Data     │
│                     │    │   - BTP Authentication    │    │                     │
└─────────────────────┘    └───────────────────────────┘    └─────────────────────┘
                                           │                                       
                                           ▼                                       
                           ┌───────────────────────────┐                          
                           │                           │                          
                           │   ☁️  SAP BTP Platform    │                          
                           │   - Destination Service   │                          
                           │   - Connectivity Service  │                          
                           │   - XSUAA Security        │                          
                           │                           │                          
                           └───────────────────────────┘                          

🎯 Use Cases

📈 Business Intelligence Queries

User: "Show me top 10 customers by revenue this quarter"
→ Tool: r-CustomerService-Customer
→ Parameters: $filter, $orderby, $top

📝 Data Maintenance

User: "Update supplier ABC123 to have status 'Active'"
→ Tool: u-SupplierService-Supplier
→ Parameters: SupplierId="ABC123", Status="Active"

📊 Analytical Insights

User: "How many open purchase orders are there?"
→ Tool: r-PurchaseOrderService-PurchaseOrder
→ Parameters: $filter=Status eq 'Open'&$count=true

🔧 System Administration

User: "List all inactive users in the system"
→ Tool: r-UserService-User
→ Parameters: $filter=Status eq 'Inactive'

🛠️ Installation & Setup

Prerequisites

  • Node.js 18.x or higher
  • SAP S/4HANA or ECC system with OData services enabled
  • SAP BTP account with Destination and Connectivity services
  • TypeScript knowledge for customization

🚀 Usage Examples

Natural Language Queries

The MCP server automatically translates these natural language commands to the appropriate tool calls:

Natural Language Generated Tool Call OData Query
"Show me 10 banks" r-BankService-Bank GET /BankSet?$top=10
"Find banks in Germany" r-BankService-Bank GET /BankSet?$filter=Country eq 'DE'
"Update bank 123 name to ABC Corp" u-BankService-Bank PATCH /BankSet('123')
"Create a new customer John Doe" c-CustomerService-Customer POST /CustomerSet
"Delete order 456" d-OrderService-Order DELETE /OrderSet('456')

📋 Available Tools

Tool Naming Convention

{operationAbbreviation}-{serviceId}-{entityName}

Where operationAbbreviation is:

  • r: read (query entities or get single entity)
  • c: create (create new entity)
  • u: update (update existing entity)
  • d: delete (delete entity)

Examples:

  • r-API_BUSINESS_PARTNER-BusinessPartner
  • c-API_CUSTOMER_MATERIAL_SRV-CustomerMaterial
  • u-API_SALES_ORDER_SRV-SalesOrder
  • d-API_SALES_ORDER_SRV-SalesOrder

CRUD Operations

Protocol Version: 2025-06-18

Supported Capabilities:

  • Tools with listChanged notifications
  • Resources with listChanged notifications
  • Logging with level control
  • Session Management for HTTP transport
  • Error Handling with proper error codes

Protocol Version

2025-06-18

Supported Capabilities

  • Tools with listChanged notifications
  • Resources with listChanged notifications
  • Logging with level control
  • Session Management for HTTP transport
  • Error Handling with proper error codes

Transport Support

  • Streamable HTTP (recommended)
  • Stdio for command line usage
  • Session-based with automatic cleanup
  • DNS Rebinding Protection

🔒 Security & Authentication

SAP BTP Integration

  • Uses BTP Destination service for S/4HANA or ECC authentication
  • Supports Principal Propagation and OAuth2
  • Automatic token refresh and session management
  • Secure credential storage in BTP

HTTP Security

  • Helmet.js security headers
  • CORS protection with configurable origins
  • DNS rebinding attack prevention
  • Request rate limiting (configurable)

Session Security

  • Automatic session expiration (24h default)
  • Secure session ID generation
  • Session cleanup on server restart
  • Memory leak prevention

📚 API Reference

Health Check

GET /health
{
  "status": "healthy",
  "activeSessions": 3,
  "discoveredServices": 25,
  "version": "2.0.0"
}

Server Info

GET /mcp
{
  "name": "btp-sap-odata-to-mcp-server",
  "protocol": { "version": "2025-06-18" },
  "capabilities": { "tools": {}, "resources": {} },
  "features": ["Dynamic service discovery", "CRUD operations"],
  "activeSessions": 3
}

Documentation

GET /docs
{
  "title": "SAP MCP Server API",
  "endpoints": {...},
  "mcpCapabilities": {...},
  "usage": {...}
}

🎬 Demo

See the MCP server in action:

MCP Demo

⚡ Quick Start

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选