Skip to main content
Glama
NNNNzs

Server Status MCP Server

get_remote_server_status

Monitor CPU, memory, and uptime of remote servers via SSH. Retrieve real-time server status data using host information for efficient system health tracking.

Instructions

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

Input Schema

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

Implementation Reference

  • The asynchronous handler function for the get_remote_server_status tool. It establishes an SSH connection to the specified host using configuration from SSH config file if available, executes commands to retrieve CPU info (/proc/cpuinfo), memory (free -m), and uptime, then returns the stdout as JSON. Handles errors and ensures SSH disposal.
    async (args) => {
      const ssh = new NodeSSH();
    
      try {
        const sshConfigPath = options.sshConfigPath.replace(/^~/, os.homedir());
        let sshConfig;
    
        try {
          const configContent = await fs.readFile(sshConfigPath, 'utf-8');
          sshConfig = await parseSSHConfig(configContent, args.host);
        } catch (error: any) {
          console.warn(`无法读取 SSH 配置文件 ${sshConfigPath}:`, error.message);
          sshConfig = null;
        }
    
        const connectionConfig = sshConfig ? {
          host: sshConfig.hostname || args.host,
          username: sshConfig.user,
          port: sshConfig.port ? parseInt(sshConfig.port) : 22,
          privateKey: sshConfig.identityfile ?
            await fs.readFile(sshConfig.identityfile.replace(/^~/, os.homedir()), 'utf-8') :
            undefined
        } : {
          host: args.host,
          username: os.userInfo().username,
          privateKey: path.join(os.homedir(), '.ssh', 'id_rsa')
        };
    
        await ssh.connect(connectionConfig);
    
        const [cpuInfo, memInfo, uptimeInfo] = await Promise.all([
          ssh.execCommand('cat /proc/cpuinfo'),
          ssh.execCommand('free -m'),
          ssh.execCommand('uptime'),
        ]);
    
        return {
          content: [{
            type: 'text',
            text: JSON.stringify({
              cpu: cpuInfo.stdout,
              memory: memInfo.stdout,
              uptime: uptimeInfo.stdout,
              type: 'remote'
            }, null, 2)
          }]
        };
      } catch (error: any) {
        return {
          content: [{
            type: 'text',
            text: JSON.stringify({
              error: error.message
            }, null, 2)
          }]
        };
      } finally {
        ssh.dispose();
      }
    }
  • Input schema for the tool using Zod: requires a 'host' string parameter describing the remote server address or SSH config host name.
    {
      host: z.string().describe("远程服务器地址或SSH配置中的主机名")
    },
  • index.ts:135-201 (registration)
    Registration of the get_remote_server_status tool on the McpServer instance within addServerTools function, including name, description, input schema, and inline handler.
    server.tool(
      "get_remote_server_status",
      "获取远程服务器的CPU、内存和运行状态",
      {
        host: z.string().describe("远程服务器地址或SSH配置中的主机名")
      },
      async (args) => {
        const ssh = new NodeSSH();
    
        try {
          const sshConfigPath = options.sshConfigPath.replace(/^~/, os.homedir());
          let sshConfig;
    
          try {
            const configContent = await fs.readFile(sshConfigPath, 'utf-8');
            sshConfig = await parseSSHConfig(configContent, args.host);
          } catch (error: any) {
            console.warn(`无法读取 SSH 配置文件 ${sshConfigPath}:`, error.message);
            sshConfig = null;
          }
    
          const connectionConfig = sshConfig ? {
            host: sshConfig.hostname || args.host,
            username: sshConfig.user,
            port: sshConfig.port ? parseInt(sshConfig.port) : 22,
            privateKey: sshConfig.identityfile ?
              await fs.readFile(sshConfig.identityfile.replace(/^~/, os.homedir()), 'utf-8') :
              undefined
          } : {
            host: args.host,
            username: os.userInfo().username,
            privateKey: path.join(os.homedir(), '.ssh', 'id_rsa')
          };
    
          await ssh.connect(connectionConfig);
    
          const [cpuInfo, memInfo, uptimeInfo] = await Promise.all([
            ssh.execCommand('cat /proc/cpuinfo'),
            ssh.execCommand('free -m'),
            ssh.execCommand('uptime'),
          ]);
    
          return {
            content: [{
              type: 'text',
              text: JSON.stringify({
                cpu: cpuInfo.stdout,
                memory: memInfo.stdout,
                uptime: uptimeInfo.stdout,
                type: 'remote'
              }, null, 2)
            }]
          };
        } catch (error: any) {
          return {
            content: [{
              type: 'text',
              text: JSON.stringify({
                error: error.message
              }, null, 2)
            }]
          };
        } finally {
          ssh.dispose();
        }
      }
    );
  • Helper function to parse the SSH configuration file content and extract settings for a specific target host, used in the tool handler to configure SSH connection.
    export async function parseSSHConfig(configContent: string, targetHost: string) {
      const lines = configContent.split('\n');
      let currentHost: string | null = null;
      let config: Record<string, Record<string, string>> = {};
    
      for (const line of lines) {
        const trimmedLine = line.trim();
        if (!trimmedLine || trimmedLine.startsWith('#')) continue;
    
        const [key, ...values] = trimmedLine.split(/\s+/);
        const value = values.join(' ');
    
        if (key.toLowerCase() === 'host') {
          currentHost = value;
          if (currentHost && !config[currentHost]) {
            config[currentHost] = {};
          }
        } else if (currentHost) {
          config[currentHost][key.toLowerCase()] = value;
        }
      }
    
      return targetHost ? config[targetHost] : null;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. While it states what information is retrieved (CPU, memory, operational status), it doesn't mention how this information is obtained (SSH connection? API call?), what authentication is required, potential rate limits, error conditions, or the format of returned data. For a tool that presumably connects to remote servers, this is a significant gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise - a single sentence that directly states what the tool does. There's no wasted language or unnecessary elaboration. It's front-loaded with the core functionality. Every word earns its place in communicating the tool's purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given that this is a tool that presumably connects to remote systems (with no annotations and no output schema), the description is incomplete. It doesn't explain how the connection is established, what authentication is needed, what happens if the server is unreachable, or what format the status information will be returned in. For a tool with potential complexity around remote access, more context would be helpful.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% (the 'host' parameter has a clear description in the schema), so the baseline is 3. The tool description doesn't add any parameter information beyond what's already in the schema. The description mentions '远程服务器' (remote server) which aligns with the 'host' parameter, but provides no additional semantic context about parameter usage or constraints.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: '获取远程服务器的CPU、内存和运行状态' (Get remote server's CPU, memory, and operational status). It specifies the verb (get/获取) and resources (CPU, memory, operational status). However, it doesn't distinguish this from the sibling tool 'get_server_status' - we don't know if that tool is for local servers or has different functionality.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. There's a sibling tool 'get_server_status' with a similar name, but the description doesn't explain the difference between them or when one should be preferred over the other. No context about prerequisites or limitations is mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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