Skip to main content
Glama
NNNNzs

Server Status MCP Server

get_server_status

Retrieve CPU, memory, and uptime status of local or remote servers via SSH for real-time server monitoring and performance analysis.

Instructions

获取服务器的CPU、内存和运行状态

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hostNo远程服务器地址或SSH配置中的主机名

Implementation Reference

  • index.ts:109-130 (registration)
    Registers the get_server_status tool with MCP server, including description, input schema (optional host), and inline handler for local server status.
    server.tool(
      "get_server_status",
      "获取服务器的CPU、内存和运行状态",
      {
        host: z.string().optional().describe("远程服务器地址或SSH配置中的主机名")
      },
      async () => {
        return {
          content: [{
            type: 'text',
            text: JSON.stringify({
              cpuCount: os.cpus().length,
              cpuRel: getLocalCpuUsage(),
              memory: os.freemem(),
              memoryUsage: ((1 - os.freemem() / os.totalmem()) * 100).toFixed(2) + '',
              uptime: os.uptime(),
              type: 'local'
            }, null, 2)
          }]
        };
      }
    );
  • Handler function that computes local server status: CPU count and relative usage (using getLocalCpuUsage helper), free memory, memory usage percentage, uptime, and type 'local', formatted as JSON in text content.
    async () => {
      return {
        content: [{
          type: 'text',
          text: JSON.stringify({
            cpuCount: os.cpus().length,
            cpuRel: getLocalCpuUsage(),
            memory: os.freemem(),
            memoryUsage: ((1 - os.freemem() / os.totalmem()) * 100).toFixed(2) + '',
            uptime: os.uptime(),
            type: 'local'
          }, null, 2)
        }]
      };
    }
  • Input schema for the tool: optional 'host' string parameter described as remote server address or SSH config hostname.
    {
      host: z.string().optional().describe("远程服务器地址或SSH配置中的主机名")
    },
  • Helper function to calculate local CPU usage percentage (idle time averaged across all CPUs). Called by the handler.
    export function getLocalCpuUsage() {
      const cpus = os.cpus();
      let totalIdle = 0, totalTick = 0;
      cpus.forEach((cpu) => {
        for (let type in cpu.times) {
          totalTick += cpu.times[type as keyof typeof cpu.times];
        }
        totalIdle += cpu.times.idle;
      });
      const idle = totalIdle / cpus.length;
      const total = totalTick / cpus.length;
      return 1 - idle / total;
    }

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/NNNNzs/server-status-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server