Skip to main content
Glama

k8s_top_nodes

Monitor CPU and memory utilization across all Kubernetes cluster nodes to identify resource bottlenecks and optimize infrastructure performance.

Instructions

Show CPU and memory usage for all cluster nodes (requires metrics-server)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The implementation of the `k8s_top_nodes` handler function, which fetches node resource metrics using the metrics API.
    export async function topNodes(): Promise<string> {
      const api = getMetricsApi();
    
      const response = await api.listClusterCustomObject(
        "metrics.k8s.io",
        "v1beta1",
        "nodes"
      );
    
      const body = response.body as { items: MetricsItem[] };
      const items = body.items || [];
    
      if (items.length === 0) {
        return "No metrics available for nodes. Is metrics-server installed?";
      }
    
      const headers = ["NODE", "CPU", "MEMORY"];
      const rows = items.map((item) => [
        item.metadata.name,
        item.usage?.cpu || "N/A",
        item.usage?.memory || "N/A",
      ]);
    
      return `Node resource usage:\n\n${formatTable(headers, rows)}`;
    }
  • Tool registration for `k8s_top_nodes` in the Kubernetes toolset.
    {
      name: "k8s_top_nodes",
      description: "Show CPU and memory usage for all cluster nodes (requires metrics-server)",
      inputSchema: { type: "object" as const, properties: {} },
    },
  • Tool handler delegation for `k8s_top_nodes`.
    case "k8s_top_nodes": return topNodes();

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/batu-sonmez/infraclaude'

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