SAP RCA MCP Server
SAP RCA MCP Server
Python MCP 服务器,使 AI 代理能够通过查询 Azure Log Analytics 数据对 SAP 系统执行根因分析。
架构
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角色(或使用托管标识)
设置
# 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——将所有 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 系统日志 | ⏳ 等待 schema CSV |
| SM37 批处理作业 | ⏳ 等待 schema CSV |
| 实例可用性 | ⏳ 等待 schema CSV |
| 进程可用性 | ⏳ 等待 schema CSV |
| 操作系统指标 | ⏳ 等待 schema CSV |
| HA 集群 | ⏳ 等待 schema CSV |
添加新表 Schema
提供 schema 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 上,请使用托管标识;不要在 App Service 配置中存储
AZURE_CLIENT_SECRET
⚠ 待解决问题(需要操作)
在服务器能够连接到您的工作区之前,您需要提供以下信息:
# | 内容 | 查找位置 | 需更新的文件 |
1 | Log Analytics 工作区 ID | Azure 门户 → Log Analytics 工作区 → 概览 → 工作区 ID |
|
2 | Azure 租户 ID | Azure 门户 → Microsoft Entra ID → 概览 → 租户 ID |
|
3 |
| 您提供的 CSV 显示为 |
|
4 | SID_s 列是否存在 | 您的 ShortDumps 表中是否存在 |
|
5 | 其余 6 个表的 schema | 为其余表提供 schema CSV(格式与 |
|
This server cannot be deployed
Maintenance
Related MCP Connectors
AI agent run monitoring with incident replay and SLA receipts.
Read-only finance and operations controls for AI agents with evidence and safe next actions.
AI agent observability for production traces, natural-language insights, and improvement loops.
- causelyOAuthapp.causely
Causal reasoning for reliability: root cause, blast radius, and service health for agents.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to investigate backend incidents by executing runbooks that gather evidence from observability and storage systems.7 npm9MIT
- 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
- AlicenseAqualityAmaintenanceEnables 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