S/4HANA MCP Server
S/4HANA MCP サーバー
SAP S/4HANA(Cloud Public Edition およびオンプレミス Private Edition)向けに、OData V2、OData V4、SOAP を介して 38 のツールを公開する MCP サーバーです。ビジネスパートナー、製品、販売価格、倉庫、購買発注、購買情報レコード、仕入先請求書(転記と取消を含む)、サービス入力シート、仕訳エントリ、原価センタ、財務組織構造を扱います。
書き込みツール(create_*、cancel_supplier_invoice、check_invoice_posting_readiness)と get_finance_structure は、結果を JSON としてインラインで返します。その他の(読み取り)ツールは、結果(コレクションの場合は CSV、単一レコードの場合は Markdown)を E2B サンドボックスに書き込み、ファイルパスを返します。大量の SAP 結果セット(数百のビジネスパートナー、仕訳エントリの明細詳細など)を呼び出し元エージェントのコンテキストに直接埋め込むことはありません。このサーバーは、MCP クライアントがすでに所有している E2B サンドボックスにのみ接続します。新しく作成することはありません。 クライアント側でファイルを読み取るには、独自の E2B 統合(E2B SDK、または同等のコード実行アクセスを持つ Claude 環境)が必要です。E2B サンドボックスのセットアップ を参照してください。
クイックスタート
git clone https://github.com/ilia-inovaflow/s4hana-mcp-server.git
cd s4hana-mcp-server
npm install
npm run build
cp .env.example .env # fill in your E2B sandbox + SAP connection details
npm start # stdio transport (Claude Desktop, MCP Inspector, etc.)ビルドせずにローカル開発する場合: npm run dev。
Related MCP server: SAP OData MCP Server
E2B サンドボックスのセットアップ
e2b.dev で無料の API キーを登録し、MCP クライアントがファイルを読み取れるサンドボックスを起動(または再利用)して、以下を設定します:
E2B_API_KEY=<your E2B API key>
SANDBOX_ID=<an already-running sandbox ID> # stdio only — HTTP takes this per-sessionHTTP トランスポートでは、SANDBOX_ID はセッションごとに sandbox-id リクエストヘッダーで提供されます。これは、1 つのサーバーインスタンスが複数の呼び出し元(それぞれ独自のサンドボックスを持つ)を処理する場合に便利です。
これは、以下の SAP 独自の sandbox.api.sap.com トライアルホストとは関係ありません。この README では「サンドボックス」は 2 つの異なる意味を持ちます。
自前の SAP テナントなしで試す
SAP は、sandbox.api.sap.com で無料の公開読み取り専用 API サンドボックスを公開しており、このサーバーはそのまま接続できます。api.sap.com で無料の API キーを登録し、以下を設定します:
SAP_HOST=https://sandbox.api.sap.com
SAP_CLIENT_ID=<your sandbox API key>ユーザー名、パスワード、OAuth 設定は不要です。サンドボックスは単一の APIKey ヘッダーで認証します。ビジネスパートナー、製品、価格設定ツールは、サンドボックスのデモデータに対してすぐに動作します(読み取りツールの結果を受け取るには、上記の E2B サンドボックスが引き続き必要です)。
実際の SAP テナントへの接続
SAP_HOST にテナント URL を設定し、SAP_AUTH_MODE で 3 つの認証モードのいずれかを選択します:
モード | ユースケース | 必要な変数 |
| クイックテスト、OAuth が設定されていないオンプレミスシステム |
|
| S/4HANA Cloud Public Edition、サービス間(OAuth 2.0 クライアントクレデンシャル) |
|
| ユーザー委任 OAuth 認可コード — HTTP トランスポートのみ。呼び出し元が | なし(トークンは MCP クライアントから提供) |
SAP_CLIENT(SAP クライアント/マンダント番号、例: 100)は、未設定の場合は 100 にデフォルト設定されます。
2 つの API ファミリは、SAP の設計上、basic または X.509 認証が必要で、OAuth を拒否します: 仕訳エントリ転記(create_journal_entry、SOAP SAP_COM_0002)と会計伝票明細ビュー(get_journal_entry、document_level=true の search_journal_entries)。その他はすべて、3 つのモードのいずれでも動作します。
完全な変数リスト(一部のオンプレミス SOAMANAGER 設定で必要なオプションの SAP_JE_SOAP_PATH 上書きを含む)は .env.example を参照してください。
トランスポート
stdio(デフォルト、npm start / npm run dev)— プロセスごとに 1 つの SAP 接続と 1 つの E2B サンドボックスを使用し、すべて .env から設定します。これは Claude Desktop とほとんどのローカル MCP クライアントが期待するものです:
{
"mcpServers": {
"s4hana": {
"command": "node",
"args": ["/absolute/path/to/s4hana-mcp-server/dist/index.js"],
"env": {
"E2B_API_KEY": "...", "SANDBOX_ID": "...",
"SAP_HOST": "...", "SAP_AUTH_MODE": "basic", "SAP_USERNAME": "...", "SAP_PASSWORD": "..."
}
}
}
}Streamable HTTP(npm run start:http / npm run dev:http)— リモートまたはマルチテナント展開用。各セッションの SAP 接続は、.env のデフォルトまたはリクエストごとのヘッダー(sap-host、sap-auth-mode、sap-username、sap-password、sap-token-url、sap-client-id、sap-client-secret、sap-client、sap-je-soap-path)から設定され、E2B サンドボックスは sandbox-id ヘッダー(またはフォールバックとして SANDBOX_ID 環境変数)から設定されます。これにより、1 つの実行中サーバーが異なるテナントとサンドボックスに対するリクエストを処理できます。E2B_API_KEY は常にサーバー自身の環境から読み取られます。PORT(デフォルト 3000)と HOST(デフォルト localhost)がリスナーを設定します。MCP エンドポイントは POST /mcp、ヘルスチェック用に GET /health があります。
HTTP トランスポートをネットワーク経由で到達可能な場所にデプロイする場合は、独自の認証/ネットワーク境界の背後に配置してください。このサーバー自体は /mcp エンドポイントへのアクセスをゲートせず、下流の SAP 接続のみをゲートします。
ツール
search_business_partners— 顧客、仕入先、個人、組織を検索get_business_partner— 1 つのビジネスパートナーの完全な詳細query_business_partner_odata— 任意のAPI_BUSINESS_PARTNERエンティティセットに対する汎用クエリ
search_products— 材料、完成品、サービス、原材料を検索get_product— 1 つの製品の完全な詳細query_product_odata— 任意のAPI_PRODUCT_SRVエンティティセットに対する汎用クエリ
get_product_pricing— 材料の複合価格検索(「X の価格はいくらか」はここから)search_pricing_conditions— タイプ/レートで条件レコードを参照get_pricing_condition— 1 つの条件レコードの完全な詳細query_pricing_odata— 任意の価格設定エンティティセットに対する汎用クエリ
list_warehousesget_warehouse
search_purchase_ordersget_purchase_orderquery_purchase_order_odata— 明細/納入日程行レベルを含む汎用クエリget_purchase_order_confirmations— 仕入先注文/出荷/GR 確認、一括検索
search_purchasing_info_recordsget_purchasing_info_recordquery_purchasing_info_record_odata
search_supplier_invoicesget_supplier_invoicequery_supplier_invoice_odatacreate_supplier_invoice_po⚠️ 書き込み — PO 参照の 3 ウェイマッチ請求書create_supplier_invoice_gl⚠️ 書き込み — PO なしの経費請求書、直接 G/L 行create_supplier_credit_memo⚠️ 書き込み — PO 参照のクレジットメモcancel_supplier_invoice⚠️ 書き込み — 転記済み請求書またはクレジットメモを取り消しcheck_invoice_posting_readiness— 読み取り専用の事前チェックガード
search_service_entry_sheetsget_service_entry_sheetquery_service_entry_sheet_odata
create_journal_entry⚠️ 書き込み — G/L 伝票を転記(SOAP、basic/X.509 認証のみ)search_journal_entries— 分析(集計)または会計伝票(明細レベル)ビューget_journal_entry— 番号による 1 つの会計伝票search_gl_accountssearch_open_po_items— 仕入先のまだ請求可能な PO 明細を 1 回の呼び出しで取得search_cost_centersget_cost_center_hierarchy— 標準の原価センタ階層ツリーget_finance_structure— 会社コード、元帳、勘定科目表、セグメント、事業領域
すべての書き込みツールは、転記前にサーバー側のガードチェック(存在確認、ブロッキングフラグ、重複検出、残高検証)を実行し、ガードが失敗した場合は構造化された理由リストを報告します(SAP には何も送信されません)。決定的な SAP 拒否(転記期間のクローズ、税管轄の欠落など)は、生のエラーコードではなく、実用的なメッセージに変換されます。
アーキテクチャ
src/
├── server.ts # McpServer factory — tool registration, schemas, annotations
├── client.ts # SapClient — OData V2/V4 requests, CSRF-protected writes, SOAP posts
├── auth.ts # Auth strategies: Basic, OAuth Client Credentials, OAuth Authorization Code
├── config.ts # Connection config + SAP public sandbox detection
├── index.ts # stdio entry point
├── http.ts # Streamable HTTP entry point (Express, per-session auth)
└── tools/
├── shared.ts # OData/CSV/error-parsing + E2B sandbox file I/O, shared by every tool
└── *.ts # one file per tool (schema + handler)OData V2 エンドポイントへの書き込みは、SAP の CSRF トークンプロトコルに従います。GET で X-CSRF-Token: Fetch を使用してトークンを取得し、POST でセッション Cookie とともに再送信し、403 の場合は 1 回再試行します。仕訳エントリ転記は、その API に OData 相当がないため、代わりに生の SOAP エンベロープを構築して送信します。
開発
npm run dev # stdio, hot reload via tsx
npm run dev:http # HTTP, hot reload via tsx
npm run typecheck # tsc --noEmit
npm run build # compile to dist/ライセンス
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables interaction with SAP ABAP systems through ABAP Development Tools (ADT), providing access to repository objects, source code, where-used analysis, and SQL queries with support for both on-premise and BTP systems.2
- FlicenseAqualityDmaintenanceEnables 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.1112
- FlicenseAqualityCmaintenanceEnables interaction with SAP S/4HANA systems via OData, allowing service discovery, metadata exploration, field value retrieval, and CRUD operations through natural language.45
- FlicenseNot gradedqualityDmaintenanceEnables querying ABAP programs, classes, function modules, and other objects from SAP systems with OAuth 2.0 authentication.
Related MCP Connectors
Search, document and execute authenticated API calls across 700+ apps via one MCP server
34 production API tools over one hosted MCP endpoint.
Run SOQL queries to explore and retrieve Salesforce data. Access accounts, contacts, opportunities…
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/ilia-inovaflow/s4hana-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server