Skip to main content
Glama
mcp-vps-monitor

mcp-vps-monitor

by sykin7

mcp-vps-monitor

一个专为 AI 智能体(如 OpenClaw / 小龙虾、Cursor、Claude Desktop 等)设计的通用 VPS 系统监测与运维 MCP(Model Context Protocol)工具包。

本工具包采用纯只读架构,支持数据缓存防高并发打爆 CPU、正则表达式防命令注入,并提供精准的内存/Swap 统计与 Docker 容器运行状态排查。


🛠️ 项目结构

mcp-vps-monitor/
├── src/
│   └── index.ts        # MCP 服务核心源码(已优化缓存与安全校验)
├── dist/               # 自动编译生成的 JavaScript 运行目录
├── package.json        # 项目依赖配置
├── tsconfig.json       # TypeScript 编译选项
├── setup.sh            # Linux / VPS 环境一键部署脚本
├── init.bat            # Windows 本地环境一键部署脚本
└── README.md           # 部署使用说明文档

Related MCP server: Enterprise Infrastructure & Metrics MCP Server

🛠️ 核心功能列表 (Tools)

工具名称

功能描述

特性与安全防护

示例输入参数

get_system_metrics

获取 CPU 占用、精准可用内存(Available)、Swap 交换分区以及磁盘容量信息

具备 3 秒 In-Memory 缓存,防止智能体高频调用打爆 CPU

无

check_network_ping

测试 VPS 到指定目标 IP 或域名的网络延迟与连通性

内置严格正则匹配校验,防范命令行注入攻击

{"host": "1.1.1.1"}

get_top_processes

获取当前系统 CPU 或内存占用最高的前 N 个进程

经过字段精简脱敏,减少 Token 消耗

{"limit": 5}

get_docker_status

获取 VPS 上运行的 Docker 容器列表及其运行状态

快速提取容器 ID、名称、镜像与 Up/Exited 状态

无


🚀 部署与初始化步骤

环境要求

  • Node.js:v18.0.0 或更高版本

  • npm:随 Node.js 一起安装


途径一:在 Linux / VPS 环境部署(推荐)

  1. 上传项目文件: 将 mcp-vps-monitor 文件夹上传至 VPS 的任意目录(例如 /opt/mcp-vps-monitor)。

  2. 运行一键部署脚本: 进入项目目录并执行 setup.sh 脚本,自动安装依赖并完成编译:

cd /opt/mcp-vps-monitor
bash setup.sh
  1. 运行结果校验: 脚本执行完成后,会在项目根目录下生成 dist/index.js 文件。


途径二:在 Windows 本地电脑部署

  1. 打开项目目录: 进入 mcp-vps-monitor 根目录。

  2. 双击运行脚本: 直接双击运行 init.bat 脚本。

  3. 运行结果校验: 脚本会自动唤起命令行界面进行 npm install 与 npx tsc 编译,完成后按下任意键退出即可。


🤖 智能体(Agent)接入配置

接入 OpenClaw(小龙虾)

OpenClaw 与 MCP 服务部署在同一台 VPS 环境下时,建议采用 STDIO 管道传输 模式接入。

  1. 打开 OpenClaw 的配置文件(例如 openclaw.json 或 Agent 配置文件)。

  2. 在 mcpServers 字段中添加以下配置节点:

{
  "mcpServers": {
    "vps-monitor": {
      "command": "node",
      "args": [
        "/opt/mcp-vps-monitor/dist/index.js"
      ]
    }
  }
}

注意:请确保 /opt/mcp-vps-monitor/dist/index.js 为您 VPS 上的实际绝对路径。

  1. 保存配置文件并重启 OpenClaw 服务。


❓ 常见问题与注意事项

  1. Docker 容器列表获取失败:

  • 原因:运行 MCP 服务或 OpenClaw 的系统用户缺乏读取 Docker Daemon 的权限。

  • 解决方案:请使用 root 用户运行,或将当前非 root 用户加入 docker 用户组:

sudo usermod -aG docker $USER
  1. 网络 Ping 测试提示格式非法:

  • 原因:check_network_ping 增加了正则安全过滤,仅支持标准的 IP 地址(如 1.1.1.1)或域名(如 google.com),不支持带空格或管道符的复杂字符串。

Available Tools

4 tools
check_network_pingA

测试 VPS 到指定目标 IP 或域名的网络延迟与连通性(带防注入与超时保护)

Inputs: host (required).

get_docker_statusA

获取 VPS 上运行的 Docker 容器列表及其运行状态

Inputs: no named parameters.

get_system_metricsA

获取 VPS 的 CPU 占用、精准可用内存、Swap 交换分区以及磁盘容量信息

Inputs: no named parameters.

get_top_processesB

获取当前系统 CPU 或内存占用最高的前 N 个进程

Inputs: limit.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

    TDQS

    A3.9/5.0

    Scored across 4 tools

    Disambiguation5/5

    Each tool targets a distinct monitoring function: system metrics, network ping, top processes, and Docker status. There is no overlap.

    Naming Consistency5/5

    All tools use consistent snake_case verb_noun naming (get_system_metrics, check_network_ping, get_top_processes, get_docker_status).

    Tool Count5/5

    Four tools are well-scoped for a VPS monitor, covering essential aspects without being too few or too many.

    Completeness4/5

    The set covers CPU, memory, disk, network, processes, and Docker status. Minor gaps like uptime or per-partition disk usage exist but are not critical.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Provides read-only access to host system metrics (CPU, memory, disk), Docker container health/logs, and sandboxed log file analysis via MCP tools, enabling AI agents to monitor enterprise infrastructure safely.
      3
      MIT
    • F
      license
      B
      quality
      B
      maintenance
      Enables safe VPS diagnostics and Docker/Docker Compose management over SSH, providing predefined read-only and mutating tools for system monitoring, container inspection, and Compose orchestration without exposing arbitrary shell execution.
      26
      -
    • F
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to audit server health and operations through read-only tools, including container status, logs, alerts, and WhatsApp session status, without requiring SSH access.
      -