Skip to main content
Glama
Nidhideep

SAP S/4HANA MCP Server

by Nidhideep

SAP S4 MCP Server

MCP server for SAP S/4HANA OData access. Discover services, query entities, fetch metadata, and manage data — built on the @modelcontextprotocol/sdk TypeScript SDK.

Tools

Tool

Description

discover_sap_services

Discovers available services from the SAP Gateway Service Catalog

get_entity_metadata

Fetches and summarizes OData service metadata optimized for LLM consumption

get_field_values

Fetches dropdown/value-list values from SAP OData entities

execute_odata_query

Executes OData CRUD operations (GET returns CSV, writes return JSON)

Related MCP server: SAP OData to MCP Server

Prerequisites

  • Node.js >= 18.0.0

  • SAP S/4HANA system with OData services enabled

  • SAP user with appropriate OData authorizations

Setup

git clone https://github.com/Nidhideep/sap-s4-mcp-server
cd sap-s4-mcp-server
npm install
cp .env.example .env
# Edit .env with your SAP connection details
npm run build

Environment Variables

Copy .env.example to .env and fill in the values.

OData Connection (required)

Variable

Description

Example

S4_ODATA_HOST

Full SAP S/4HANA URL including scheme and port

https://my-s4.sap:44301

S4_ODATA_CLIENT

SAP client number

100

AUTH_METHOD

basic or token

basic

S4_ODATA_USER

SAP user (when AUTH_METHOD=basic)

ODATA_USER

S4_ODATA_PASSWORD

Password (when AUTH_METHOD=basic)

S4_ODATA_TOKEN

Bearer token (when AUTH_METHOD=token)

Operational

Variable

Description

Default

LOG_LEVEL

debug, info, warn, error

info

DRY_RUN

When true, all write operations are blocked

false

MCP Client Configuration

Claude Code

claude mcp add sap-s4-mcp-server -- node /absolute/path/to/sap-s4-mcp-server/dist/src/index.js

Then set env vars via .mcp.json (copy from .mcp.example.json).

Claude Desktop / Cline

Copy .mcp.example.json to .mcp.json, fill in real values, and add to your MCP client config:

{
  "mcpServers": {
    "sap-s4-mcp-server": {
      "command": "node",
      "args": ["/absolute/path/to/sap-s4-mcp-server/dist/src/index.js"],
      "env": {
        "S4_ODATA_HOST": "https://your-s4.example.com:44301",
        "S4_ODATA_CLIENT": "100",
        "AUTH_METHOD": "basic",
        "S4_ODATA_USER": "your_user",
        "S4_ODATA_PASSWORD": "your_password"
      }
    }
  }
}
  1. Discoverdiscover_sap_services to find the service name

  2. Understandget_entity_metadata to see entity sets and field names

  3. Validate inputsget_field_values to look up valid dropdown values

  4. Query or writeexecute_odata_query with the correct service, entity, and fields

Project Structure

src/
  index.ts              # Server entry point (stdio transport)
  server.ts             # Tool registration
tools/
  s4-discover-services.tool.ts   # Gateway catalog discovery
  s4-metadata.tool.ts            # OData $metadata parser
  s4-field-values.tool.ts        # Value-list / dropdown fetcher
  s4-odata-query.tool.ts         # CRUD query executor
config/
  env.ts                # Zod-validated environment config
  auth.ts               # Auth headers + CSRF token fetch
  policy.ts             # DRY_RUN enforcement + audit log
docs/
  authentication.md
  governance.md
  troubleshooting.md
examples/
  example-workflow.md

Development

npm run dev        # Watch mode with tsx
npm run typecheck  # Type-check without building
npm run build      # Compile to dist/

Governance

  • DRY_RUN=true blocks all write operations — safe for read-only environments

  • All write operations are audit-logged to stderr

  • CSRF tokens are fetched automatically before every write

  • No credentials are ever committed — use .env (gitignored) or MCP client env injection

Available Tools

4 tools
discover_sap_servicesA

Discovers available OData services from the SAP Gateway Service Catalog. Returns service names, titles, and descriptions. Use this first when you don't know which service name to pass to execute_odata_query or get_entity_metadata.

ParametersJSON Schema
NameRequiredDescriptionDefault
searchNoFilter services by name or title substring (case-insensitive)
topNoMaximum number of services to return (default 50)

TDQS

A4.1/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must cover behavioral traits. It describes the discovery operation as safe and returns names, titles, and descriptions, but lacks details on limitations (e.g., default top of 50), error handling, or what happens if no results are found.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two concise sentences: first states purpose, second gives usage guidance. No wasted words, highly efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema exists, so the description should compensate by explaining the return structure. It mentions returning names, titles, and descriptions but doesn't specify if it's a list or the format. Also, it could clarify how the output feeds into sibling tools, though it's implied.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with both parameters described. The description adds no additional meaning beyond the schema, so baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool discovers OData services from SAP Gateway, returning names, titles, and descriptions. It also distinguishes itself from sibling tools by specifying to use it first when the service name is unknown.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly states to use this tool first when you don't know the service name to pass to execute_odata_query or get_entity_metadata, providing clear guidance on when to use it vs alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

execute_odata_queryA

Executes OData CRUD operations against SAP S/4HANA. GET requests return data as CSV for easy reading. POST, PATCH, and DELETE return JSON with the operation result. Use discover_sap_services to find service names, get_entity_metadata for field names, and get_field_values for valid input values before writing.

ParametersJSON Schema
NameRequiredDescriptionDefault
serviceYesOData service name, e.g. API_BUSINESS_PARTNER
entityYesEntity set name, e.g. A_BusinessPartner
methodNoHTTP method — GET reads (returns CSV), POST creates, PATCH updates, DELETE removesGET
entityKeyNoKey predicate for a single-record operation, e.g. "'1000001'" or "BusinessPartner='1000001'"
filterNoOData $filter expression, e.g. "BusinessPartnerCategory eq '1'"
selectNoFields to return, e.g. ["BusinessPartner", "BusinessPartnerFullName"]
topNoMaximum rows to return for GET requests (default 100)
skipNoRows to skip for GET pagination
orderByNoOData $orderby expression, e.g. "BusinessPartner asc"
payloadNoRequest body for POST and PATCH operations

TDQS

A3.9/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Discloses that GET returns CSV and POST/PATCH/DELETE return JSON, which is valuable beyond schema. However, with no annotations, description carries full burden; it omits side effects, permissions, error handling, or idempotency. Adds some context but incomplete for a CRUD tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, front-loaded with core purpose, no wasted words. Efficiently conveys return format and usage recommendations.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given tool complexity (10 params, CRUD, no output schema), description is adequate but has gaps: does not mention pagination behavior (top/skip are in schema but not described), single-record vs list retrieval via entityKey, or error handling. Points to siblings for discovery but could be more complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so baseline is 3. Description does not add significant meaning beyond schema; it only hints at using sibling tools for valid input values. No parameter-specific enrichment in description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states it executes OData CRUD operations against SAP S/4HANA, with specific verb and resource. Distinguishes from sibling tools discover_sap_services, get_entity_metadata, and get_field_values, which are used for preparation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly recommends using sibling tools before write operations for discovery of service names, field names, and valid input values. Provides clear context but does not cover all usage scenarios (e.g., when to use GET vs POST is inferred from method parameter).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_entity_metadataA

Fetches and summarizes OData service metadata from SAP S/4HANA. Returns all entity sets with their key fields, properties, and navigation properties. Use this before calling execute_odata_query to understand the available fields and correct entity names.

ParametersJSON Schema
NameRequiredDescriptionDefault
serviceYesOData service name, e.g. API_BUSINESS_PARTNER

TDQS

A4.4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, description explains the tool returns metadata (entity sets, fields, navigation properties) and implies no side effects. Could be more explicit about being read-only or requiring authentication, but sufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two concise sentences: first states purpose, second gives usage guidance. No unnecessary words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Completeness is high given no output schema: describes return content and provides usage context. Could mention authentication or scope, but not critical for a metadata retrieval tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema has 100% coverage for the single 'service' parameter, and description provides an example (API_BUSINESS_PARTNER) adding some value beyond the schema description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states it fetches and summarizes OData service metadata from SAP S/4HANA, returning entity sets with key fields, properties, and navigation properties. This distinguishes it from sibling tools like execute_odata_query.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly says 'Use this before calling execute_odata_query to understand the available fields and correct entity names,' providing clear context and alternative.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_field_valuesA

Fetches dropdown and value-list options from a SAP S/4HANA OData entity. Use this to discover valid input values before writing data with execute_odata_query. Provide the entity set that acts as the value-help source and the target field name.

ParametersJSON Schema
NameRequiredDescriptionDefault
serviceYesOData service name, e.g. API_BUSINESS_PARTNER
entityYesEntity set that serves as a value-help list, e.g. A_BPContactToFuncAndDept
valueFieldYesTechnical field name whose distinct values you want, e.g. BusinessPartnerCategory
labelFieldNoField that holds the human-readable description for each value
topNoMaximum number of values to return (default 200)

TDQS

A4.2/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must fully disclose behavior. It states it fetches options but omits details like read-only nature, distinctness, or error handling. While the input schema covers parameters, the description itself adds minimal behavioral context beyond the core function.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences efficiently convey the tool's purpose and usage. Every word earns its place; no redundancy or fluff.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (5 params, no output schema), the description ties the tool to sibling 'execute_odata_query' and explains the value-help concept. However, it omits the return format (array of value-label pairs) and pagination behavior of the 'top' parameter, leaving some ambiguity for an agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

All 5 parameters have descriptions in the input schema (100% coverage), so the description's mention of 'entity set that acts as the value-help source and the target field name' adds no new semantic meaning. It restates schema info without deepening parameter understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Fetches') and resource ('dropdown and value-list options from a SAP S/4HANA OData entity'). It effectively distinguishes itself from siblings like 'execute_odata_query' and 'get_entity_metadata' by focusing on value discovery before writing.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly directs when to use the tool ('before writing data with execute_odata_query') and provides actionable guidance on how to provide the entity set and target field. This fulfills a high standard of usage context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 4 tool updatesv0.1.0
    • First observeddiscover_sap_services
    • First observedexecute_odata_query
    • First observedget_entity_metadata
    • First observedget_field_values

TDQS

A4.4/5.0

Scored across 4 tools

Disambiguation5/5

Each tool has a distinct purpose: service discovery, query execution, metadata retrieval, and field values. No overlap, clear differentiation.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern in snake_case: discover, execute, get, get. Uniform and predictable.

Tool Count5/5

Four tools cover the essential workflow for interacting with SAP OData services efficiently. Not over- or under-scoped.

Completeness5/5

The tool set enables a complete cycle: discover services, understand metadata, fetch valid input values, and perform CRUD operations. No critical gaps.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    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.
    26 npm
    132
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Transforms SAP S/4HANA or ECC systems into conversational AI interfaces by exposing OData services as dynamic MCP tools. Enables natural language interactions with ERP data for querying, creating, updating, and deleting business entities.
    26 npm
    1
    MIT
  • F
    license
    A
    quality
    D
    maintenance
    Enables AI assistants to integrate with SAP systems via OData REST APIs for querying entity sets, performing CRUD operations, and executing function imports. It features automatic service discovery, CSRF token management, and smart connection handling without requiring the SAP RFC SDK.
    11
    12
    -
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables interaction with SAP Business One via Service Layer REST API to retrieve and create business data such as partners, orders, invoices, items, and stock levels through natural language.
    1
    -