trackmcp
Back to directory
lemaiwo

btp-sap-odata-to-mcp-server

View on GitHub

BTP CloudFoundry Node.js MCP server for SAP OData services integration

73 stars TypeScriptServers & Infrastructure Updated Oct 16, 2025

Documentation

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 - 3-Level Progressive Discovery

mermaid
graph TB
    A[AI Agent/LLM] --> B[MCP Client]
    B --> C[SAP MCP Server]
    C --> D[SAP BTP Destination]
    D --> E[SAP System]

    C --> F[Level 1: Lightweight Discovery]
    F --> G[Minimal Service/Entity List]
    C --> H[Level 2: Full Metadata]
    H --> I[Complete Entity Schemas]
    C --> J[Level 3: CRUD Execution]
    J --> K[Authenticated Operations]

    style A fill:#e1f5fe
    style C fill:#f3e5f5
    style E fill:#e8f5e8
    style F fill:#fff3e0
    style H fill:#e8eaf6
    style J fill:#e0f2f1

Core Components:

1. ๐Ÿ” Level 1 - Discovery: Lightweight search returning minimal service/entity lists (token-optimized)

2. ๐Ÿ“‹ Level 2 - Metadata: Full schema details on-demand for selected entities

3. โšก Level 3 - Execution: Authenticated CRUD operations using metadata from Level 2

4. ๐Ÿ”Œ MCP Protocol Layer: Full compliance with MCP 2025-06-18 specification

5. ๐ŸŒ HTTP Transport: Session-based Streamable HTTP for web applications

6. ๐Ÿ” BTP Integration: Seamless authentication via SAP BTP Destination service

3-Level Approach Benefits:

  • Token Efficient: Level 1 returns 90% less data than full schemas
  • Progressive Detail: Fetch full schemas only when needed
  • Better LLM Experience: Smaller responses, clearer workflow
  • Reduced Context: From 200+ tools down to just 3

โœจ 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

code
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                     โ”‚    โ”‚                           โ”‚    โ”‚                     โ”‚
โ”‚   ๐Ÿค– 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

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

๐Ÿ“ Data Maintenance

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

๐Ÿ“Š Analytical Insights

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

๐Ÿ”ง System Administration

code
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 LanguageGenerated Tool CallOData 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 - 3-Level Architecture

The server exposes 3 progressive discovery tools instead of hundreds of individual CRUD tools:

Level 1: discover-sap-data

Purpose: Lightweight search for services and entities

Returns: Minimal data (serviceId, serviceName, entityName, entityCount)

Usage:

javascript
// Search for customer entities
discover-sap-data({ query: "customer" })

// Get all available services
discover-sap-data({ query: "" })

// Search in specific category
discover-sap-data({ query: "sales", category: "sales" })

Fallback: If no matches found, returns ALL services with entity lists


Level 2: get-entity-metadata

Purpose: Get complete schema for a specific entity

Returns: Full schema with properties, types, keys, capabilities

Usage:

javascript
// Get full schema for Customer entity
get-entity-metadata({
  serviceId: "API_BUSINESS_PARTNER",
  entityName: "Customer"
})

Output: All properties, types, nullable flags, maxLength, keys, capabilities


Level 3: execute-sap-operation

Purpose: Perform authenticated CRUD operations

Operations: read, read-single, create, update, delete

Usage:

javascript
// Read customers
execute-sap-operation({
  serviceId: "API_BUSINESS_PARTNER",
  entityName: "Customer",
  operation: "read",
  filterString: "CustomerName eq 'ACME'"
})

// Update customer
execute-sap-operation({
  serviceId: "API_BUSINESS_PARTNER",
  entityName: "Customer",
  operation: "update",
  parameters: { CustomerID: "123", CustomerName: "New Name" }
})

Workflow Example

code
1. discover-sap-data โ†’ "customer"
   โ†“ Returns: List of customer-related entities

2. get-entity-metadata โ†’ "API_BUSINESS_PARTNER", "Customer"
   โ†“ Returns: Full schema with all properties

3. execute-sap-operation โ†’ read/create/update/delete
   โœ“ Executes operation with proper parameters

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

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

Server Info

http
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

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

๐ŸŽฌ Demo

See the MCP server in action:

MCP Demo

โš™๏ธ Environment Variable: Disable ReadEntity Tool Registration

To disable registration of the ReadEntity tool for all entities in all services, set the following in your `.env` file:

env
DISABLE_READ_ENTITY_TOOL=true

This will prevent registration of the ReadEntity tool for all entities and services.

โšก Quick Start

Frequently asked questions

What is btp-sap-odata-to-mcp-server?

btp-sap-odata-to-mcp-server is BTP CloudFoundry Node.js MCP server for SAP OData services integration

How do I install btp-sap-odata-to-mcp-server?

Open the GitHub repository and follow its README. Most MCP servers are added to your client's MCP config, then called by your agent.

Is btp-sap-odata-to-mcp-server open source?

Yes โ€” it is hosted on GitHub at https://github.com/lemaiwo/btp-sap-odata-to-mcp-server and has 73 stars.

Related MCP tools

Run your own MCP server? See who uses it and what to fix.

Measure it with TrackMCP