The Server Status MCP Server is a monitoring tool that allows you to:
Retrieve CPU, memory, and uptime information from your local machine
Fetch the same metrics from remote servers via SSH
Connect to remote servers using IP addresses, hostnames, or aliases defined in your SSH config
Leverage automatic SSH configuration file reading or use custom connection parameters
Use it as a standalone server or integrate it into other applications as an npm package
Interact with it programmatically through a JSONRPC 2.0 API
You can invoke monitoring methods like get_server_status (for both local and remote servers) or get_remote_server_status (specifically for remote servers).
Allows installation directly from GitHub repository, providing source code access for customization and development.
Monitors local server status, providing real-time metrics on CPU usage, memory consumption, and system uptime for local machine monitoring.
Enables installation and distribution through npm, supporting both global installation and integration as a project dependency.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Server Status MCP Servercheck the CPU and memory usage on production-server-01"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
服务器状态监控工具
这是一个基于 FastMCP 的服务器状态监控工具,可以获取本地或远程服务器的 CPU、内存和运行时间信息。
功能特点
支持获取本地服务器状态
支持通过 SSH 获取远程服务器状态
自动读取 SSH 配置文件(~/.ssh/config)
支持自定义 SSH 连接参数
可作为独立服务器运行
可作为npm包集成到其他应用中
Related MCP server: Python MySQL MCP
安装
通过npm安装
# 全局安装
npm install -g server-status-mcp-server
# 或作为项目依赖安装
npm install server-status-mcp-server从源码安装
# 克隆仓库
git clone https://github.com/nnnnzs/server-status-mcp-server.git
cd server-status-mcp-server
# 安装依赖
npm install
# 构建项目
npm run build使用方法
作为独立服务运行
1. 启动服务器
# 如果全局安装了包
server-status-mcp-server
# 或者从源码启动
npm start2. 运行测试客户端
node client.js3. 命令行直接调用
使用 stdio 方式与服务器通信:
echo '{"jsonrpc":"2.0","method":"get_server_status","params":{},"id":1}' | node dist/index.js获取远程服务器状态:
echo '{"jsonrpc":"2.0","method":"getRemoteServerStatus","params":{"host":"172.18.1.103"},"id":1}' | node dist/index.js作为npm包集成
1. 创建和配置MCP服务
import { createServerStatusMCP } from 'server-status-mcp-server';
// 创建MCP服务实例
const server = createServerStatusMCP({
// 可选:自定义SSH配置文件路径
sshConfigPath: '/path/to/ssh/config'
});
// 启动服务
server.start({
transportType: "stdio" // 或其他传输类型
});2. 使用MCP客户端调用
import { MCPClient } from 'fastmcp';
import { createServerStatusMCP } from 'server-status-mcp-server';
import { spawn } from 'child_process';
async function main() {
// 方法1:创建子进程运行服务
const serverProcess = spawn('node', ['path/to/your/server.js']);
// 创建MCP客户端
const client = new MCPClient();
// 连接到服务进程
await client.connect({
process: serverProcess,
transportType: "stdio"
});
// 方法2:在同一进程中使用(不推荐用于生产环境)
const server = createServerStatusMCP();
server.start({ transportType: "memory" });
const memoryClient = new MCPClient();
await memoryClient.connect({ transportType: "memory", server });
// 调用工具
const localStatus = await client.invoke('getLocalServerStatus', {});
console.log('本地服务器状态:', JSON.stringify(localStatus, null, 2));
const remoteStatus = await client.invoke('getRemoteServerStatus', {
host: 'your-ssh-host'
});
console.log('远程服务器状态:', JSON.stringify(remoteStatus, null, 2));
// 断开连接
await client.disconnect();
serverProcess.kill();
}
main().catch(console.error);SSH 配置示例
在 ~/.ssh/config 文件中添加以下配置:
Host my-server
HostName 192.168.1.100
User username
Port 22
IdentityFile ~/.ssh/id_rsa然后可以使用配置的主机名来获取状态:
echo '{"jsonrpc":"2.0","method":"getRemoteServerStatus","params":{"host":"my-server"},"id":1}' | node dist/index.js返回数据格式
本地服务器状态
{
"cpuCount": 8,
"cpuRel": 0.12,
"memory": 8589934592,
"memoryUsage": "45.32",
"uptime": 123456,
"type": "local"
}远程服务器状态
{
"cpu": "处理器信息...",
"memory": "内存使用情况...",
"uptime": "系统运行时间...",
"type": "remote"
}API文档
主要导出
// 创建MCP服务实例
createServerStatusMCP(config?: { sshConfigPath?: string }): FastMCP
// 获取本地CPU使用率
getLocalCpuUsage(): number
// 解析SSH配置文件
parseSSHConfig(configContent: string, targetHost: string): Promise<Record<string, string> | null>
// 服务器状态接口
interface RemoteServerStatus {
cpuRel: string;
memoryRel: string;
alarmInfo: string;
itemStatus: string;
cpu: string;
memory: string;
memoryUsage: string;
uptime: string;
type: 'remote' | 'local';
}错误处理
如果连接失败或执行命令出错,将返回:
{
"error": "错误信息"
}发布到NPM
如果你想自己发布这个包到NPM,可以按照以下步骤操作:
更新
package.json中的版本号运行
npm run build确保构建成功运行
npm login登录NPM账号运行
npm publish发布包可选:使用
npm publish --access public发布公共包
许可证
ISC