sap-sales-order-mcp

sap-sales-order-mcp

MCP server for SAP S/4HANA Sales Order Management that enables natural language queries for sales orders, order details, and line items using SAP's public sandbox API. Built with offline testing, structured errors, and retry policies.

Category
Visit Server

README

sap-sales-order-mcp

Production-ready MCP server for SAP S/4HANA Sales Order Management. Sandbox-first, offline-testable, built on FastMCP.

Python License: MIT Tests MCP Compatible SAP API Business Hub

A reference implementation showing how to build a maintainable, testable MCP server that connects Claude (or any MCP client) to an enterprise system. Uses the public SAP API Business Hub sandbox — no on-prem SAP install needed.

Why this repo exists: most MCP + SAP examples show a toy server with one tool and no error handling. This one applies the patterns from Anthropic's Claude Certified Architect (Foundations) curriculum — boundary descriptions, structured errors, offline mocks, and a tool-selection reliability harness — to a real (public) SAP API.


5-Minute Quickstart

# 1. Clone + install
git clone https://github.com/coding-with-abbi/sap-sales-order-mcp.git
cd sap-sales-order-mcp
pip install -e .

# 2. Smoke-test all 4 tools offline (no API key needed)
python mcp_server.py --selftest

# 3. Add your SAP API key (get it free at api.sap.com)
cp .env.example .env
# Edit .env: SAP_API_KEY=<your key>

# 4. Verify live connection
LIVE_TESTS=1 python -m pytest tests/test_integration_live.py

Add to Claude Desktop (macOS: ~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "sap-sales-orders": {
      "command": "python",
      "args": ["/absolute/path/to/sap-sales-order-mcp/mcp_server.py"],
      "env": {
        "SAP_API_KEY": "your_key_here"
      }
    }
  }
}

Restart Claude Desktop, then ask: "Show me all open sales orders for customer 17100001."


Tools

Four tools, each with boundary descriptions (USE WHEN / DO NOT use) that guide Claude to pick the right one on ambiguous requests. See docs/ARCHITECTURE.md for the design rationale.

Tool What it does Typical prompt
list_sales_orders Paginated list with optional filters (customer, type, status, created-since) "Show me all open orders"
get_sales_order Single order header by ID (customer, amounts, status, dates) "Details for order 1000001"
get_sales_order_items Line items of an order (material, quantity, price) "What products are on order 1000001?"
search_orders_by_customer Convenience wrapper: all orders for a specific customer "Show orders for customer 17100001"

Full contracts (docstrings): src/sap_sales_mcp/tools.py. More prompts + responses: docs/EXAMPLES.md.


Architecture Highlights

  • Offline-first. Unit tests + --selftest run against a MockSAPClient with realistic OData v2 fixtures. No API key, no network. Live tests are opt-in via LIVE_TESTS=1.
  • Structured errors. Every failure returns a ToolError with errorCategory (transient|validation|business|permission) + isRetryable — never a bare "failed" string. Claude can act on them.
  • Boundary descriptions. Each tool's docstring explicitly states USE WHEN and DO NOT use for, with cross-references. A tool-selection-reliability harness empirically verifies that these descriptions guide the model correctly on ambiguous requests.
  • Retry policy. Bounded exponential backoff (1s/2s/4s) on transient HTTP errors only. Never on validation, business, or permission errors.
  • Lazy imports. The offline codepath is stdlib-only — httpx, mcp, python-dotenv are imported lazily in live functions. Unit tests run without them.
  • Path-scoped rules. .claude/rules/python.md and .claude/rules/mcp-tool-design.md load only when editing matching files — root CLAUDE.md stays lean.

Testing

# Unit tests (offline, always safe)
python -m pytest

# Tool-selection harness (deterministic proxy for LLM tool-picking)
python tool_selection_harness.py

# Integration tests against real SAP sandbox
LIVE_TESTS=1 python -m pytest tests/test_integration_live.py

Current status: 53 passed + 5 skipped (5 skipped = live tests, opt-in).


Documentation


Positioning

Built by Jacob Abb — AI Consultant & Engineer specialising in Enterprise-AI (RAG, Voicebots, SAP+GenAI). This project is part of a public reference portfolio; adapt it for your own SAP system or use it as a template for other SAP domains (Business Partner, Purchase Order, Materials).

Related: the patterns here (boundary descriptions, structured errors, tool-selection harness) come directly from Anthropic's Claude Certified Architect – Foundations curriculum.


Credits

  • SAPAPI Business Hub for the sandbox
  • AnthropicMCP protocol + Claude Certified Architect curriculum
  • FastMCP — the Python MCP framework this server is built on

License

MIT — use freely, adapt for your production SAP systems, fork it for other domains. PRs welcome (see CONTRIBUTING.md).

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured