Skip to main content
Glama
yufeizhou666

log-analyzer-mcp

by yufeizhou666

get_system_metrics

Retrieve system metrics including CPU, memory, and disk usage to monitor system health and performance.

Instructions

Get CPU, memory, and disk metrics from the system

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
metricsNoWhich metrics to retrieve: cpu, memory, disk

Implementation Reference

  • The handler function `getMetrics` that executes the tool logic. It receives input specifying which metrics to retrieve (cpu, memory, disk), calls `getSystemMetrics()` from utils, and formats the result as text content.
    export async function getMetrics(input: ToolInput): Promise<{ content: Array<{ type: string; text: string }> }> {
      const { metrics = ['cpu', 'memory', 'disk'] } = input as GetSystemMetricsInput;
    
      const data = await getSystemMetrics();
    
      const lines: string[] = ['System Metrics:\n'];
    
      if (metrics.includes('cpu')) {
        lines.push(`  CPU: ${data.cpu.usage}% (${data.cpu.cores} cores)`);
      }
    
      if (metrics.includes('memory')) {
        const usedStr = formatBytes(data.memory.used);
        const totalStr = formatBytes(data.memory.total);
        lines.push(`  Memory: ${usedStr} / ${totalStr} (${data.memory.percent}%)`);
      }
    
      if (metrics.includes('disk')) {
        const usedStr = formatBytes(data.disk.used);
        const totalStr = formatBytes(data.disk.total);
        lines.push(`  Disk: ${usedStr} / ${totalStr} (${data.disk.percent}%)`);
      }
    
      return { content: [{ type: 'text', text: lines.join('\n') }] };
    }
  • Helper function `formatBytes` used to convert byte values into human-readable strings (e.g., '1.5 GB').
    function formatBytes(bytes: number): string {
      if (bytes === 0) return '0 B';
      const k = 1024;
      const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
      const i = Math.floor(Math.log(bytes) / Math.log(k));
      return `${(bytes / Math.pow(k, i)).toFixed(1)} ${sizes[i]}`;
    }
  • Input type definition `GetSystemMetricsInput` extending ToolInput with an optional `metrics` array of strings.
    interface GetSystemMetricsInput extends ToolInput {
      metrics?: string[];
    }
  • Type definition `SystemMetrics` (and its nested `CpuMetrics`, `MemoryMetrics`, `DiskMetrics`) defining the return shape of getSystemMetrics.
    export interface SystemMetrics {
      cpu: CpuMetrics;
      memory: MemoryMetrics;
      disk: DiskMetrics;
    }
  • src/index.ts:98-112 (registration)
    Tool registration block defining the name 'get_system_metrics', description, and input schema (the `metrics` array). Dispatches to handler at line 154-155.
    {
      name: 'get_system_metrics',
      description: 'Get CPU, memory, and disk metrics from the system',
      inputSchema: {
        type: 'object',
        properties: {
          metrics: {
            type: 'array',
            items: { type: 'string' },
            default: ['cpu', 'memory', 'disk'],
            description: 'Which metrics to retrieve: cpu, memory, disk'
          }
        }
      }
    },
Behavior2/5

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

No annotations are provided, so the description bears full responsibility. It only states the action without disclosing side effects, permissions, or potential limitations (e.g., read-only, resource cost).

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 a single, clear sentence that conveys the tool's purpose efficiently with no unnecessary words.

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 the lack of output schema and annotations, the description fails to explain return format, data granularity, or operational context (e.g., whether metrics are real-time or cached). It leaves significant gaps for agent decision-making.

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?

The input schema has 100% description coverage for the single parameter 'metrics', which already defines its meaning. The tool description adds no extra semantic value beyond identifying the metrics types.

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

Purpose5/5

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

The description clearly states the verb 'Get' and the resource 'CPU, memory, and disk metrics from the system'. It directly distinguishes from sibling tools like 'search_logs' or 'count_by_level', which handle different data.

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

Usage Guidelines3/5

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

The description implies usage for retrieving system metrics, but no explicit guidance on when to use it versus alternatives or exclusions. Siblings are distinct, so the context is clear but not exhaustive.

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

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/yufeizhou666/my_mcp'

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