lohith2/Incident-Response-MCP
GitHub: lohith2/Incident-Response-MCP
基于 MCP 协议和 LangGraph 的智能事故响应平台,支持自然语言查询、多数据源自动关联分析和自进化 RAG 知识库
Stars: 0 | Forks: 0
# Incident Response MCP
[](https://typescriptlang.org)
[](https://python.org)
[](https://langchain.com)
[](https://aws.amazon.com/bedrock)
## 功能
当凌晨 2 点发生 SEV1 事故时,该系统允许待命工程师用自然语言描述事故,并在单次响应中获取来自整个可观测性堆栈(logs、traces、alerts、deploys 和历史事故)的关联洞察。
```
Engineer → Any MCP Client → MCP Server → [Datadog · CloudWatch · PagerDuty · Pinecone · PostgreSQL]
↓
LangGraph Investigation Pipeline
↓
Root cause · Remediation · Postmortem · Slack Alert
```
## 两种模式
### 模式 1 — 交互式(演示/开发)
```
Engineer types incident in Claude Desktop (or any MCP client)
↓
Claude autonomously calls MCP tools
↓
Agentic RAG: Claude decides which tools to call and in what order
↓
Postmortem generated → Dashboard updates → Slack notified
```
### 模式 2 — 自动化(生产环境)
```
PagerDuty webhook fires → POST /trigger-workflow
↓
LangGraph pipeline runs automatically:
fetch alerts → query logs → check deploys →
search history → generate postmortem → notify
↓
Slack notification fired → Dashboard updated
Zero human input required
```
启用生产模式:
```
USE_MOCK=false
PAGERDUTY_TOKEN=your_real_token
DATADOG_API_KEY=your_real_key
GITHUB_TOKEN=your_real_token
```
## 架构
**三层协作:**
**1. TypeScript MCP Server** — 通过 Model Context Protocol(SSE + Streamable HTTP 传输)暴露 19 个工具。任何兼容 MCP 的客户端均可连接。演示使用 Claude Desktop。
**2. Python LangGraph Workflow** — 由 AWS Bedrock 驱动的多步骤自主调查 pipeline。通过 MCP 客户端交互式触发,或通过 PagerDuty webhook 自动触发。
**3. React Dashboard** — 实时事故订阅源、MTTR 分析、RAG 智能面板和实时 Slack 路由 —— 全部通过 REST 轮询实时数据。
## MCP 工具(共 19 个)
| 类别 | 工具 |
|----------|-------|
| Alerts | `alert_get_active`, `alert_get_timeline`, `alert_acknowledge`, `alert_get_service_health` |
| Logs | `log_query`, `log_get_error_spike`, `log_get_metrics`, `log_find_pattern` |
| Git | `git_get_recent_deploys`, `git_get_commit_diff`, `git_find_similar_incidents`, `git_create_incident_issue`, `git_get_deploy_before_incident` |
| Postmortem | `postmortem_generate`, `postmortem_get_similar`, `postmortem_find_similar`, `pattern_get_count` |
| Traces | `traces_query`, `traces_query_metrics` |
## 技术栈
| 层级 | 技术 |
|-------|-----------|
| MCP Server | TypeScript, Model Context Protocol |
| MCP Transport | SSE + Streamable HTTP(兼容任何 MCP 客户端) |
| Agent Orchestration | LangGraph, Python FastAPI |
| LLM Inference | AWS Bedrock — Claude Sonnet 4(postmortems)+ Claude Haiku(pattern extraction) |
| Vector Store | Pinecone(双命名空间:incidents + log-patterns) |
| Embeddings | AWS Titan Embed V2(1024 维) |
| Cache | Redis |
| Database | PostgreSQL(audit trail, metrics, postmortems) |
| Integrations | Datadog, PagerDuty, GitHub(提供 mock 模式) |
| Notifications | Slack(基于严重程度的路由:SEV1/SEV2/SEV3 频道) |
| Dashboard | React 18, Vite, TypeScript, Tailwind |
## 快速开始
```
# 1. 配置环境
cp .env.example .env
# 填写: AWS credentials, PINECONE_API_KEY, REDIS_URL, DATABASE_URL
# 2. 启动所有服务
docker compose up -d
# 3. 填充知识库
npx tsx scripts/seed-incidents.ts
# 4a. 交互模式 — 连接任意 MCP 客户端
# Claude Desktop: 添加到 claude_desktop_config.json
# Cursor: 添加到 MCP 设置
# URL: https://your-ngrok-url/mcp
# 4b. 自动模式 — 通过 webhook 触发
curl -X POST http://localhost:8000/trigger-workflow \
-H "Content-Type: application/json" \
-d '{"incident_id":"INC-001","service":"payment-service","severity":"SEV1"}'
# 5. 模拟事件
npm run simulate
```
## MCP 客户端兼容性
该服务器实现标准 MCP 传输,适用于任何兼容客户端:
| 客户端 | 状态 |
|--------|--------|
| Claude Desktop | ✅ 已测试 |
| Cursor | ✅ 已测试 |
| Zed | ✅ 兼容 |
| Continue | ✅ 兼容 |
| 自定义客户端 | ✅ SSE + Streamable HTTP |
## 自我改进的 RAG
每个已解决的事故都会自动:
1. 通过 AWS Titan V2 进行 embedding 并存储在 Pinecone 中
2. 触发 Claude Haiku 提取 3-5 个错误模式
3. 对比现有知识库对模式进行去重
4. 使未来的调查更快、更准确
```
Day 1: 10 seed incidents, 20 patterns
Week 1: 40+ incidents, 64+ patterns
Month 1: 200+ incidents, 300+ patterns → highly accurate RAG
```
## Slack 严重程度路由
```
SEV1 → #incidents-sev1 (critical, pages everyone)
SEV2 → #incidents-sev2 (high priority, pages on-call)
SEV3 → #incidents-sev3 (low priority, no pages)
All → #all-incidentresponsemcp (full audit trail)
```
## 环境变量
```
# AWS
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_REGION=us-east-1
AWS_BEDROCK_MODEL_ID=us.anthropic.claude-sonnet-4-20250514-v1:0
AWS_BEDROCK_HAIKU_MODEL_ID=us.anthropic.claude-3-5-haiku-20241022-v1:0
AWS_BEDROCK_EMBEDDING_MODEL_ID=amazon.titan-embed-text-v2:0
# Pinecone
PINECONE_API_KEY=
PINECONE_INDEX_NAME=incident-postmortems
# 数据库
DATABASE_URL=postgresql://user:password@postgres:5432/incident_response
REDIS_URL=redis://redis:6379
# Integrations (生产环境设置 USE_MOCK=false)
USE_MOCK=true
PAGERDUTY_TOKEN=
DATADOG_API_KEY=
GITHUB_TOKEN=
GITHUB_REPO=
# Slack
SLACK_WEBHOOK_SEV1=
SLACK_WEBHOOK_SEV2=
SLACK_WEBHOOK_SEV3=
SLACK_WEBHOOK_ALL=
```
## 许可证
MIT © 2026 Lohith Reddy Kondreddy
基于 TypeScript · LangGraph · AWS Bedrock · Pinecone · React · Model Context Protocol 构建
标签:Agentic AI, API集成, AWS Bedrock, Claude, CloudWatch, CVE检测, Datadog, DLL 劫持, IT运维, LangGraph, LLM, MCP, Model Context Protocol, On-Call, PagerDuty, Pinecone, PostgreSQL, Python, RAG, RCA, SEV1, Slack集成, Socks5代理, SRE, TypeScript, Unmanaged PE, 事后复盘, 偏差过滤, 可观测性, 告警关联, 大语言模型, 安全插件, 库, 应急响应, 搜索引擎查询, 故障排查, 无后门, 根因分析, 测试用例, 知识检索, 站点可靠性工程, 网络调试, 自动化, 自动化攻击, 请求拦截, 运维, 逆向工具