以色列红色警报MCP服务器
A. 模型上下文协议(MCP) 微服务,按结构化方式公开以色列后方司令部(Pikud HaOref)的实时和历史火箭警报数据 MCP工具.\ 它将半官方JSON端点封装在Home-Front Command公共网站后面,处理cookies/rate-limits/geo-forces,并提供一个干净的TypeScript API和一个独立的服务器。
⚠️ 这个项目是 非官方的 和 无关联 与以色列国防军或内政部司令部合作。使用数据的风险由您自行承担。
______________________________________________________________________
✨ 特性
- 类型安全
RedAlertAPI它检索:
- 当前实时警报(alerts.json) - 历史警报(AlertsHistory.json) - 位置元数据(面积、避难时间、地区)
- 自动大IP cookie握手+自定义标头,绕过公共站点的WAF和地理围栏。
- 内建 瓶颈 速率限制器(1req/sec),以保持对上游服务器的友好。
- 生产准备就绪 MCP服务器 (
RedAlertMCPServer)使用以下工具:
- get_current_alerts - get_alert_history - get_location_info - count_active_alerts - get_alert_status - get_area_alerts - get_alert_category_info
- 全面的Jest单元测试+可选的实时集成测试(
LIVE_TEST=true). - 严格ESLint/Pretier/
tsconfig以获得一致的代码库。
______________________________________________________________________
📦 安装
# 1. Clone the repo
$ git clone https://github.com/elad12390/red_alert_mcp_server.git
$ cd red_alert_mcp_server
# 2. Install dependencies
$ npm install
# 3. Build the TypeScript sources
$ npm run build目标Node.js版本: >= 18 (在18号和20号测试)。
______________________________________________________________________
🚀 运行服务器
# Development (ts-node, auto-reload)
$ npm run dev
# Production (compiled JavaScript)
$ npm run start默认端口为 8080.\ 用覆盖 PORT 环境变量:
PORT=3000 npm run startCLI入口点是 src/index.ts,它创建了一个实例 RedAlertMCPServer 并开始用优雅的关机钩子进行监听。
______________________________________________________________________
🛠️ 可用的MCP工具
| 工具名称 | 参数(JSON模式) | 描述 |
|---|---|---|
get_current_alerts | – | 返回一个数组 *当前活动* Pikud HaOref返回的警报。 |
get_alert_history | { "from": string (ISO), "to": string (ISO) } | 返回在以下时间之间触发的所有警报 from 和 to. |
get_location_info | { "locationId": string } | 给定位置的静态元数据(区号、避难时间、名称……)。 |
count_active_alerts | – | 返回单个整数(活动警报的数量)的便利包装器。 |
get_alert_status | – | 简单布尔值,表示是否 任何 警报当前处于活动状态。 |
get_area_alerts | { "areaId": string } | Home Front区域内的所有当前警报。 |
get_alert_category_info | { "categoryId": string } | 关于Pikud HaOref警报类别的人类可读信息。 |
典型的MCP工具调用/响应对如下:
// Request (MCP)
{
"tool": "get_current_alerts",
"arguments": {}
}
// Response (assistant)
{
"text": "[{\"id\":123,\"location\":\"אשקלון\",...}]"
}______________________________________________________________________
🧪 测试
# Run the full Jest suite (unit + mocks)
$ npm test
# Run live integration tests against the real API (⚠️ may 403 outside IL)
$ LIVE_TEST=true npm test -- tests/integration/live-api.int.test.ts- axios层完全模拟
tests/__mocks__/axios.ts–正常CI运行期间没有网络请求。 - 集成测试在以下情况下自动取消模拟轴
LIVE_TEST已设置。
______________________________________________________________________
📂 项目结构
├── src
│ ├── red-alert-api.ts # Axios wrapper
│ ├── server.ts # MCP server implementation
│ ├── index.ts # CLI bootstrap
│ └── types.ts # Shared TypeScript types
├── tests # Jest unit + integration suites
├── package.json
├── tsconfig.json
└── …______________________________________________________________________
⚖️ 许可证
麻省理工学院©2025年至今Elad Ben Haim
______________________________________________________________________
🙏 致谢
- 后方司令部(פִקו"ֲד)公开暴露警报源。
- 模型上下文协议 SDK和规范团队。
- 所有贡献者和问题记者——您的帮助使这个项目变得更好!
