# How to build an MCP server for SAP ECC 6.0

> Source: https://netray.co/integrations/sap-ecc-mcp-server
> Publisher: Netray (netray.co), AI and integration engineering for ERP and manufacturing systems.
> Section: Integrations

## Short answer

An MCP server for ECC is a small service that registers a handful of named tools, each wrapping a released BAPI, a Z function module or an OData call, and runs under a restricted technical user. Start with read-only tools for materials, stock, POs and orders, expose them over stdio for testing and HTTP for teams, and log every call.

## System

SAP ECC 6.0

## Capability

mcp-server

## Intro

The Model Context Protocol is an open standard that lets AI clients such as Claude, ChatGPT and various agent frameworks call tools and read resources in a consistent way. For SAP ECC 6.0, an MCP server is the cleanest place to put your integration rules, because the AI client stays generic while the ECC-specific knowledge lives in one reviewed service.

The design question is not how to expose all of SAP. It is which dozen questions your plant asks every day, and how to answer each one through a function that SAP security can reason about. A good first server is small, strict and boring.

This page is about the server itself: tool design, connectivity to ECC, authentication, scoping and operations.

## Use Cases

### Item and BOM lookup

**Description:** Tools such as get_material and get_bom (reading MARA, MARC and STKO/STPO data via a BAPI or Z module) let any MCP client answer "what is this part and what goes into it".

### Inventory by plant and storage location

**Description:** A get_stock tool backed by material availability and storage data (MARD view) answers stock questions without MB52 navigation.

### Open order status

**Description:** get_purchase_order and get_sales_order tools return header, line, delivery and confirmation status, trimmed to the fields users care about.

### Production order progress

**Description:** get_production_order returns operations, confirmations and component shortages for the shop floor supervisor.

### Approval-gated actions

**Description:** Later, a request_po_change tool that does not post anything, but creates a proposal record that a buyer approves in a separate step.

### Document and resource access

**Description:** Expose work instructions or certificates stored in DMS or a file share as MCP resources next to the live ERP tools.

## System Surface

- SAP NetWeaver RFC SDK with a binding for your language (PyRFC for Python, node-rfc for Node.js), connecting to the application server or a message server with a logon group, ideally over SNC.
- BAPIs for reads, for example BAPI_MATERIAL_GET_DETAIL, BAPI_PO_GETDETAIL, BAPI_PRODORD_GET_DETAIL and sales order getters; verify names and parameters in SE37 and BAPI Explorer (BAPI transaction) for your release.
- Custom Z function modules marked remote-enabled, written when no BAPI returns the shape you need, with their own AUTHORITY-CHECK statements.
- SAP Gateway OData services (SEGW) as an alternative back end, and SICF for HTTP handler activation; useful if you prefer HTTP between server and ECC.
- Connection management: SM59 destinations, gateway security files (secinfo, reginfo) and the technical user maintained in SU01 with role in PFCG.
- Runtime load and trace visibility via SM50/SM66, ST05 and STAD, which Basis uses to check what your server does.

## How It Works

### Write the tool catalog first

**Detail:** For each tool define name, plain description, input schema, output fields and the ECC function it calls. Review the list with the SAP functional lead before coding.

### Choose the MCP SDK and runtime

**Detail:** Use an official MCP SDK for Python or TypeScript. Pair with PyRFC or node-rfc. Keep the RFC library installation (a SAP download requiring an S-user) documented for your deployment image.

### Create the connection and service user

**Detail:** Ask Basis for a Service type user, a PFCG role limited to the needed function groups via S_RFC, plus plant and company code restrictions in business authorization objects.

### Implement read tools with strict output shaping

**Detail:** Validate input, set row caps, convert SAP internal formats (leading zeros in material numbers, date formats, units via conversion exits) and return human-readable values.

### Pick transports

**Detail:** Use stdio for local development and desktop clients. Use streamable HTTP in a container for shared use, behind a reverse proxy with OAuth or SSO and TLS.

### Add audit and rate limits

**Detail:** Log caller identity, tool, parameters, duration and row counts. Limit concurrent RFC connections so you do not exhaust dialog work processes.

### Test with several MCP clients

**Detail:** Try the server with Claude, a ChatGPT connector if your plan supports it, and an open-source agent framework to confirm the schema works across clients.

## Example Flows

### Stock check from any MCP client

**Trigger:** A user asks, "How many of part 100-2045 do we have at plant 1000?"

**Steps:**

- The client picks get_stock and passes material and plant.
- The server normalizes the material number to its internal format.
- It calls the availability BAPI and reads unrestricted, quality inspection and blocked quantities.
- It returns those quantities with unit and last movement date.

**Result:** A precise answer with the breakdown, logged under the user's identity.

### Proposal instead of posting

**Trigger:** An agent decides a PO line should move out two weeks.

**Steps:**

- It calls request_po_change with PO, item, new date and reason.
- The server writes a proposal row to an approvals table, not to ECC.
- The buyer sees it in a queue and approves or rejects.
- A separate approved-only job posts the change through a narrow function.

**Result:** Agents can suggest changes but only a person causes a posting.

## On Prem

An MCP server is just a process, so it fits on-prem naturally. Run it in a container or a service on a host inside the same network zone as the ECC application server, expose it only to your internal clients, and connect clients that use local or on-prem models. This is the building block that lets a private open-weight model (served with vLLM or Ollama) use SAP tools without any cloud involvement. If you also want cloud-hosted clients such as Claude or ChatGPT to use it, put the HTTP endpoint behind a reverse proxy in a DMZ with strong auth and restrict what tools are visible there, keeping the more sensitive tools internal-only. Netray builds and hardens servers like this for plants with controlled data.

## Security

- Never expose raw RFC_READ_TABLE or a generic SQL tool to a model.
- Use a non-dialog technical user and a dedicated PFCG role reviewed by your SAP security team.
- Authenticate callers at the MCP layer and forward the identity to logs; consider per-user ECC mapping for sensitive tools.
- Treat tool output as untrusted by clients: vendor names and free text fields can contain prompt injection, so keep write tools gated.
- Run the server with least privilege on the host, rotate secrets, and keep the SAP RFC SDK patched.

## Options

### Fork or adopt an open-source SAP MCP project

**Fit:** Good starting point if it supports RFC and ECC; review the code and the license.

**Effort:** A few days to adapt, plus a security review.

### Build a bespoke server

**Fit:** Full control over tool shape, Z objects and audit; best for long-term use.

**Effort:** Two to four weeks for a solid read-only set with logging and tests.

### Have Netray build and operate it

**Fit:** When you want tools designed with planners, plus on-prem model support and a hardening review.

**Effort:** A scoped pilot, then add tools by function.

## Pitfalls

- Exposing too many tools. Models choose worse when there are dozens; keep the list focused per use case.
- Not handling SAP conversion exits, so material 000000000000100234 and 100234 behave differently.
- Returning unfiltered tables which flood the context window and leak sensitive columns.
- Opening RFC connections per request and exhausting the application server; pool them carefully.
- Skipping unit tests with recorded RFC responses, leading to regressions after a support package.

## Faq

### What is an MCP server for SAP?

**Answer:** It is a service that presents SAP functions as tools any MCP-compatible AI client can call. For ECC 6.0 it usually wraps BAPIs and Z function modules over RFC, applies authorization and logging, and returns compact structured results.

### Do I need SAP Gateway to build one?

**Answer:** No. Direct RFC with the NetWeaver RFC SDK is the most common route on ECC. Gateway OData is a good alternative when your landscape already has it and you prefer HTTP.

### Which tools should I build first?

**Answer:** Material lookup, stock by plant, PO status, sales order status and production order status. All are read-only, map to released BAPIs or small Z modules, and answer the questions people ask most often.

### Can the same server serve Claude and ChatGPT?

**Answer:** Yes, MCP is client-neutral, though each client has its own rules for remote connectors, so test your transport and authentication method against the clients you plan to use.

### How do I stop it slowing down SAP?

**Answer:** Cap rows, set timeouts, limit concurrent connections and avoid wide table reads. Ask Basis to watch the technical user's workload in the first weeks and tune the limits.

## Search terms

sap ecc mcp server, sap mcp server rfc, model context protocol sap ecc, build mcp server for sap, sap bapi mcp, mcp sap on-prem, sap ecc 6.0 mcp tools, pyrfc mcp server, node-rfc mcp sap, mcp server erp manufacturing

---
Talk to an engineer: https://netray.co/contact?intent=erp_ai | Machine catalog: https://netray.co/agent/catalog.json
