SAP早期监控警报MCP系统
一个容器化系统,它接收SAP EWA PDF,使用GPT-5.2 Vision提取警报,通过markdown标头对内容进行块化,使用Azure OpenAI进行矢量化,存储在Azure AI Search(多租户共享索引)中,并通过Streamable HTTP公开MCP服务器,用于Copilot/Claude Desktop集成。
建筑
EWA PDF Upload → Blob Storage → Azure Function → GPT-5.2 Vision (alerts) + pymupdf4llm (text)
↓
Markdown Header Chunking → OpenAI Embedding → Azure AI Search
↓
MCP Server (ACA) ← Event Grid (status events)
↓
Copilot / Claude Desktop组件
| 组件 | 技术 | 目的 |
|---|---|---|
| 文档处理器 | Azure函数(Python) | PDF提取、警报提取、分块、嵌入 |
| MCP服务器 | FastAPI+MCP SDK | 流式HTTP MCP端点 |
| 矢量存储 | Azure AI搜索 | 文档、块和警报存储 |
| 嵌入 | Azure OpenAI文本嵌入-3小 | 1536维向量 |
| 警报提取 | Azure OpenAI GPT-5.2视觉 | 第1-4页图像分析 |
| 事件 | Azure事件网格 | 处理状态跟踪 |
快速开始
1.部署基础设施
cd infrastructure/bicep
az deployment group create \
--resource-group ewa-mcp-rg \
--template-file main.bicep \
--parameters personResponsible="Your Name"或者使用现有的OpenAI:
az deployment group create \
--resource-group ewa-mcp-rg \
--template-file main.bicep \
--parameters personResponsible="Your Name" \
--parameters deployOpenAI=false \
--parameters existingOpenAIEndpoint="https://
.openai.azure.com/" \
--parameters existingOpenAIKey=""2.设置搜索索引
python infrastructure/scripts/setup-indexes.py \
--endpoint $AZURE_SEARCH_ENDPOINT \
--api-key $AZURE_SEARCH_API_KEY3.部署文档处理器
cd processor
func azure functionapp publish ewa-processor-prod4.部署MCP服务器
cd mcp-server
az acr build --registry ewaacr --image ewa-mcp:latest .
az containerapp update --name ewa-mcp --image ewaacr.azurecr.io/ewa-mcp:latest5.配置MCP客户端
添加到Claude桌面配置:
{
"mcpServers": {
"ewa": {
"url": "https://ewa-mcp.your-region.azurecontainerapps.io/mcp",
"headers": {
"Authorization": "Bearer your-api-key"
}
}
}
}使用现有的OpenAI部署
如果你已经有了OpenAI部署 gpt-5.2 和 text-embedding-3-small,您可以跳过创建新的:
选项1:使用deploy.py脚本
python deploy.py \
--subscription \
--resource-group ewa-mcp-rg \
--person-responsible "Your Name" \
--use-existing-openai \
--openai-endpoint "https://your-openai.openai.azure.com/" \
--openai-key "your-api-key"选项2:手动二头肌展开
az deployment group create \
--resource-group ewa-mcp-rg \
--template-file infrastructure/bicep/main.bicep \
--parameters personResponsible="Your Name" \
--parameters deployOpenAI=false \
--parameters existingOpenAIEndpoint="https://your-openai.openai.azure.com/" \
--parameters existingOpenAIKey="your-api-key"这将使用您现有的部署进行GPT-5.2视觉警报提取和文本嵌入-3小矢量化。
MCP工具
| 工具 | 说明 |
|---|---|
list_reports | 列出客户可用的EWA报告 |
get_alert_overview | 从报告中获取所有警报 |
get_alert_detail | 获取包含证据块的详细警报 |
get_section | 检索特定文档部分 |
ask_ewa_scoped | 跨报告的RAG查询 |
compare_reports | 比较两个报告之间的警报 |
generate_action_pack | 生成可交付的行动包 |
目录结构
/ewa-mcp
├── /processor # Azure Function for PDF processing
│ ├── extractors/ # PDF extraction, GPT-5.2 Vision
│ ├── chunkers/ # Markdown chunking
│ ├── embedders/ # OpenAI embeddings
│ ├── indexers/ # Azure AI Search indexing
│ └── eventgrid/ # Event Grid publisher
├── /mcp-server # FastAPI MCP server
│ ├── tools/ # MCP tool implementations
│ ├── search/ # Search client wrapper
│ └── auth/ # API key middleware
├── /infrastructure # Bicep templates
│ ├── bicep/ # ARM/Bicep templates
│ └── scripts/ # Setup scripts
├── /shared # Shared Pydantic models
│ └── models/ # Alert, Chunk, Document, Citation
└── /tests # Test suites配置
处理器(Azure功能)
{
"AZURE_OPENAI_ENDPOINT": "https://...openai.azure.com/",
"AZURE_OPENAI_API_KEY": "...",
"AZURE_OPENAI_VISION_DEPLOYMENT": "gpt-5.2",
"AZURE_OPENAI_EMBEDDING_DEPLOYMENT": "text-embedding-3-small",
"AZURE_SEARCH_ENDPOINT": "https://...search.windows.net",
"AZURE_SEARCH_API_KEY": "...",
"EVENTGRID_ENDPOINT": "https://...eventgrid.azure.net",
"EVENTGRID_KEY": "..."
}MCP服务器
AZURE_SEARCH_ENDPOINT=https://...search.windows.net
AZURE_SEARCH_API_KEY=...
AZURE_OPENAI_ENDPOINT=https://...openai.azure.com/
AZURE_OPENAI_API_KEY=...
API_KEY=your-secure-api-key
PORT=8000多租户
所有索引均由多租户共享 customer_id 作为必需的过滤字段。每个查询都必须包含customer_id过滤以实现数据隔离。
处理流程
- 上传PDF至
ewa-uploads/{customer_id}/{filename} - Blob触发器触发Azure函数
- 发射
EwaProcessingStarted事件 - 将第1-4页提取为图像→ GPT-5.2愿景→ 结构化警报
- 提取完整的PDF文本→ 通过pymupdf4llm降价
- 按标题分组标记(保留section_path)
- 生成嵌入(1536d)
- 上传到3个索引:
ewa-docs,ewa-chunks,ewa-alerts - 发射
EwaProcessingCompleted事件
许可证
麻省理工学院
