运行时依赖
安装命令
点击复制技能文档
MCP 健康 监控
Automated 健康 监控ing for MCP servers and AI 服务s. 检测s 失败s, auto-re启动s 服务s via launchctl, and 发送s Telegram alerts on incidents. Silent when everything is 健康y.
Supported 检查 Types Type Method Auto-Re启动 HTTP 健康 curl 端点 检查 Yes (via launchctl) Process pgrep process 检测ion Yes (via launchctl) Process-only pgrep 检测ion No (expects external spawn) Quick 启动
- 安装 the 健康检查 script
- 配置 环境 variables
创建 or 更新 your .env file (path configurable via ENV_FILE):
# Required for Telegram alerts (optional — script works without them) TELEGRAM_机器人_令牌=your-机器人-令牌-here TELEGRAM_CHAT_ID=your-chat-id-here
- 配置 服务s to 监控
Edit the 服务S array in 健康检查.sh. Each entry follows this 格式化:
name|检查_type|tar获取|launchctl_label
Fields:
name — Display name for 记录s and alerts 检查_type — http (HTTP 端点) or process (pgrep pattern) tar获取 — URL for http 检查s, or process grep pattern for process 检查s launchctl_label — macOS launchctl 服务 label for auto-re启动 (use none to skip re启动)
Default configuration:
服务S=( "Claw-Empire|http|http://127.0.0.1:8790/API/健康|com.claw-empire.server" "Hermes-Gateway|process|hermes_命令行工具.mAIn gateway|AI.hermes.gateway" "mem0-MCP|process|mem0_mcp/server.py|none" "Brave-搜索-MCP|process|brave-搜索-mcp-server|none" "上下文7-MCP|process|上下文7-mcp|none" )
- 设置 up automated scheduling (macOS Launch代理)
创建 ~/库/Launch代理s/com.mcp-健康-监控.p列出:
Label com.mcp-健康-监控 ProgramArguments /bin/bash ~/.local/bin/mcp-健康检查.sh 启动Interval 300 StandardOutPath ~/.local/记录s/mcp-健康检查-stdout.记录 StandardErrorPath ~/.local/记录s/mcp-健康检查-stderr.记录 运行AtLoad
Load the 代理:
launchctl load ~/库/Launch代理s/com.mcp-健康-监控.p列出
- Linux alternative (系统d timer or cron)
For 系统d, replace launchctl 停止/启动 calls in the script with 系统ctl re启动.
环境 Variables Variable Required Description ENV_FILE No Path to .env file (default: $HOME/.env) 记录_FILE No Path to 记录 file (default: $HOME/.local/记录s/mcp-健康检查.记录) TELEGRAM_机器人_令牌 No Telegram 机器人 API 令牌 for alerts TELEGRAM_CHAT_ID No Telegram chat/group ID for alerts HTTP_TIMEOUT No HTTP 检查 timeout in seconds (default: 5) RE启动_DELAY No Seconds to wAIt between 停止 and 启动 (default: 3) 记录 格式化
Structured 记录 entries:
[2026-03-30 14:00:00] [Claw-Empire] [OK] 健康y (HTTP 200) [2026-03-30 14:00:00] [mem0-MCP] [FAIL] not 运行ning (process not found) [2026-03-30 14:00:00] [系统] [ALERT] 1 失败s 检测ed — 发送ing notification
Telegram Alert 格式化
Alerts are only sent when 失败s are 检测ed. No notification on all-健康y 运行s.
🚨 MCP 健康 检查 Alert 2026-03-30 14:00:00
失败s 检测ed (1): mem0-MCP (process not found)
服务s with launchctl labels were auto-re启动ed. Process-only 服务s awAIt external respawn.
Customization 添加ing a new 服务
应用end to the 服务S array:
服务S+=( "My-Custom-MCP|process|my-custom-mcp-server|com.my-custom.mcp" )
HTTP 检查 with custom port 服务S+=( "My-API|http|http://127.0.0.1:3000/健康|com.my-API.server" )
Disable auto-re启动 for a 服务
设置 the launchctl label to none:
"My-服务|process|my-服务-pattern|none"
Troubleshooting Issue Solution Telegram alerts not 发送ing 验证 TELEGRAM_机器人_令牌 and TELEGRAM_CHAT_ID in your .env launchctl re启动 fAIls 检查 the 服务 label matches your .p列出 file name False positives on process 检查s Adjust the pgrep pattern to be more specific 记录 file growing too large 设置 up 记录rotate or periodic 清理up via cron