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.
README
sap-sales-order-mcp
Production-ready MCP server for SAP S/4HANA Sales Order Management. Sandbox-first, offline-testable, built on FastMCP.
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 +
--selftestrun against aMockSAPClientwith realistic OData v2 fixtures. No API key, no network. Live tests are opt-in viaLIVE_TESTS=1. - Structured errors. Every failure returns a
ToolErrorwitherrorCategory(transient|validation|business|permission) +isRetryable— never a bare"failed"string. Claude can act on them. - Boundary descriptions. Each tool's docstring explicitly states
USE WHENandDO 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-dotenvare imported lazily in live functions. Unit tests run without them. - Path-scoped rules.
.claude/rules/python.mdand.claude/rules/mcp-tool-design.mdload only when editing matching files — rootCLAUDE.mdstays 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
docs/SETUP.md— Full setup guide (SAP API Hub, Claude Desktop, troubleshooting)docs/ARCHITECTURE.md— Design decisions + CCA-F pattern rationaledocs/EXAMPLES.md— 10 prompt/response examplesdocs/NEXT-STEPS.md— v2 ideas (create-order with approval gate, OAuth, more domains)CONTRIBUTING.md— How to contribute
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
- SAP — API Business Hub for the sandbox
- Anthropic — MCP 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).
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。