SAP RCA MCP Server
SAP RCA MCP サーバー
Azure Log Analytics のデータを照会することで、AI エージェントが SAP システムの根本原因分析(Root Cause Analysis)を実行できるようにする Python MCP サーバー。
アーキテクチャ
AI Agent (Azure AI Foundry / Claude / Copilot Studio)
│ MCP Tool Calls
▼
FastMCP Server (server.py)
├── get_schema → schema_registry.py (table/column metadata)
├── execute_query → la_client.py (validated KQL execution)
├── analyze_results → domain_knowledge.py (SAP error classification)
└── run_full_rca → rca_orchestrator.py (8-step automated workflow)
│
▼
Azure Log Analytics (read-only KQL queries via Managed Identity)Related MCP server: exception-mcp-server
4 つのツール
ツール | 目的 |
| 登録済みテーブルの正確な列名、型、時刻列、SID 列、KQL ヒントを返します。最初にこれを呼び出してください。 |
| エージェントが生成した KQL クエリを検証(読み取り専用ガード)してから実行します。 |
| SAP ドメイン知識を適用して生の行を分類します:エラーカテゴリ、重大度、推奨事項。 |
| 8 つの RCA ステップをすべて自動実行し、統合された JSON レポートを返します。 |
前提条件
Python 3.11+
Azure CLI(
az)がインストールされていることAzure Log Analytics ワークスペースへのアクセス(ワークスペース ID が必要)
アカウントに
Log Analytics Readerロールが割り当てられていること(またはマネージド ID)
セットアップ
# 1. Clone / navigate to this folder
cd C:\Users\padmajat\Documents\AMS-Agentic-RCA\MCP
# 2. Create virtual environment
python -m venv .venv
.venv\Scripts\activate # Windows
# source .venv/bin/activate # Linux/macOS
# 3. Install dependencies
pip install -r requirements.txt
# 4. Configure
copy .env.example .env
# Edit .env and fill in AZURE_LOG_ANALYTICS_WORKSPACE_ID and AZURE_TENANT_ID
# 5. Authenticate (local development)
az login設定(.env)
AZURE_LOG_ANALYTICS_WORKSPACE_ID=<your-workspace-guid>
AZURE_TENANT_ID=<your-tenant-id>Azure でマネージド ID を使用する場合、必要なのはワークスペース ID のみです。AZURE_CLIENT_* フィールドはすべて空白のままにしてください。
実行
stdio モード(Claude Desktop、MCP Inspector、Azure AI Foundry ローカル)
python server.py
# or:
mcp dev server.pySSE/HTTP モード(Azure App Service デプロイ)
pip install uvicorn
uvicorn server:mcp --host 0.0.0.0 --port 8000SSE エンドポイントは次のようになります:http://localhost:8000/sse
Claude Desktop に接続
claude_desktop_config.json に追加:
{
"mcpServers": {
"sap-rca": {
"command": "python",
"args": ["C:/Users/padmajat/Documents/AMS-Agentic-RCA/MCP/server.py"],
"env": {
"AZURE_LOG_ANALYTICS_WORKSPACE_ID": "<your-workspace-id>",
"AZURE_TENANT_ID": "<your-tenant-id>"
}
}
}
}Azure AI Foundry に接続
Azure AI Foundry で、次の場所を指す MCP 接続を追加します:
https://<your-app-service>.azurewebsites.net/sse
エージェントとの会話例
フォーカスしたクエリワークフロー:
Agent → get_schema(["SapNetweaver_ShortDumps_CL"])
Agent → execute_query("SapNetweaver_ShortDumps_CL | where serverTimestamp_t > ago(4h) | where SID_s == 'CHA' | take 100")
Agent → analyze_results(results, "short_dumps", context="SID=CHA, last 4h")完全自動 RCA:
Agent → run_full_rca(sid="CHA", time_range_hours=4, issue_description="Multiple batch job failures")
← Returns complete 8-step RCA report登録済みテーブル
現在登録済み(7 件中 1 件):
テーブル | SAP ソース | ステータス |
| ST22 ABAP ショートダンプ | ✅ 登録済み |
| SM21 システムログ | ⏳ スキーマ CSV 待ち |
| SM37 バッチジョブ | ⏳ スキーマ CSV 待ち |
| インスタンス可用性 | ⏳ スキーマ CSV 待ち |
| プロセス可用性 | ⏳ スキーマ CSV 待ち |
| OS メトリクス | ⏳ スキーマ CSV 待ち |
| HA クラスター | ⏳ スキーマ CSV 待ち |
新しいテーブルスキーマの追加
スキーマ CSV(列 + 説明)を提供します —
SchemaforMCP-Details.csvと同じ形式です。既存の
SapNetweaver_ShortDumps_CLエントリをテンプレートとして、schema_registry.pyに新しいエントリを追加します。テーブルにドメイン固有の分析ロジックが必要な場合は、
tools/analyze_results.pyに_analyze_<type>()関数を追加します。tools/rca_orchestrator.pyの_KQL_TEMPLATESに KQL テンプレートを追加します。サーバーを再起動します — 他の変更は不要です。
セキュリティに関する注意事項
execute_queryはすべての KQL 管理コマンド(.ingest、.drop、.setなど)をブロックします。run_full_rcaはパラメータ化された KQL テンプレートを使用します — SID 値は置換前に検証されます。すべての資格情報は環境変数から読み込まれます — コード内にシークレットはありません。
Azure ではマネージド ID を使用してください。App Service 設定に
AZURE_CLIENT_SECRETを保存しないでください。
⚠ 未解決の質問(対応が必要)
サーバーがワークスペースに接続できるようになる前に、以下を提供する必要があります:
# | 内容 | 確認場所 | 更新するファイル |
1 | Log Analytics ワークスペース ID | Azure Portal → Log Analytics ワークスペース → 概要 → ワークスペース ID |
|
2 | Azure テナント ID | Azure Portal → Microsoft Entra ID → 概要 → テナント ID |
|
3 |
| 提供された CSV には |
|
4 | SID_s 列の存在 | ShortDumps テーブルに |
|
5 | 残り 6 つのテーブルスキーマ | 残りのテーブルについてスキーマ CSV( |
|
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
Related MCP Connectors
Query your AI agent traces, root-cause verdicts and issues, and run investigations, from your agent.
Lets AI agents analyze API metrics, request logs, and traces, and manage apps and alerts.
Finds what's broken in your product, explains why, and fixes it from your agent.
AI agent run monitoring with incident replay and SLA receipts.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to investigate backend incidents by executing runbooks that gather evidence from observability and storage systems.9MIT
- FlicenseNot gradedqualityDmaintenanceEnables AI-powered analysis of exceptions using vector similarity search and Azure OpenAI for operations teams.-
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to query and analyze data in Azure Data Explorer, Log Analytics, and Microsoft Sentinel using Kusto Query Language (KQL) through tools, resources, and prompts.6MIT
- AlicenseAqualityBmaintenanceEnables AI agents to discover, inspect, and call SAP RFC-enabled function modules (BAPIs/RFCs) with configurable read/write policies, transaction support, audit logging, and ABAP source retrieval.61MIT