Skip to main content
Glama

k8s_top_pods

Monitor CPU and memory usage for Kubernetes pods to identify resource-intensive containers and optimize cluster performance.

Instructions

Show CPU and memory usage for pods (requires metrics-server)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
namespaceNoKubernetes namespace (default: 'default')

Implementation Reference

  • The `topPods` function implements the `k8s_top_pods` tool logic, fetching CPU and memory usage from the Kubernetes Metrics API.
    export async function topPods(args: Record<string, unknown>): Promise<string> {
      const api = getMetricsApi();
      const namespace = (args.namespace as string) || "default";
    
      const response = await api.listNamespacedCustomObject(
        "metrics.k8s.io",
        "v1beta1",
        namespace,
        "pods"
      );
    
      const body = response.body as { items: MetricsItem[] };
      const items = body.items || [];
    
      if (items.length === 0) {
        return `No metrics available for pods in namespace '${namespace}'. Is metrics-server installed?`;
      }
    
      const headers = ["POD", "CONTAINER", "CPU", "MEMORY"];
      const rows: string[][] = [];
    
      for (const item of items) {
        for (const container of item.containers || []) {
          rows.push([
            item.metadata.name,
            container.name,
            container.usage.cpu,
            container.usage.memory,
          ]);
        }
      }
    
      return `Resource usage for pods in namespace '${namespace}':\n\n${formatTable(headers, rows)}`;
    }
  • Definition of the `k8s_top_pods` tool schema in the Kubernetes tools registry.
    {
      name: "k8s_top_pods",
      description: "Show CPU and memory usage for pods (requires metrics-server)",
      inputSchema: {
        type: "object" as const,
        properties: {
          namespace: { type: "string", description: "Kubernetes namespace (default: 'default')" },
        },
      },
    },
  • Registration of the `k8s_top_pods` tool within the tool dispatcher in `src/tools/kubernetes/index.ts`.
    case "k8s_top_pods": return topPods(a);
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the prerequisite 'requires metrics-server', which is valuable context about dependencies. However, it doesn't disclose other behavioral traits like whether this is a read-only operation, what format the output takes, potential rate limits, or error conditions.

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 communicates the core purpose and a critical prerequisite. Every word earns its place with zero waste. It's front-loaded with the main functionality.

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

Completeness3/5

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

Given this is a monitoring/read tool with no annotations and no output schema, the description provides basic completeness by stating what it does and a key prerequisite. However, for a tool that presumably returns metrics data, more context about output format or behavior would be helpful. It's adequate but has clear gaps.

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% with one parameter clearly documented in the schema. The description doesn't add any parameter-specific information beyond what's in the schema. With high schema coverage, the baseline score of 3 is appropriate as the description doesn't compensate but also doesn't need to.

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: 'Show CPU and memory usage for pods' - a specific verb (show) and resource (pods) with what metrics (CPU and memory). It distinguishes from siblings like k8s_get_pods (which lists pods) and k8s_describe_pod (which provides detailed configuration), though it doesn't explicitly mention these distinctions.

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 provides some usage context with 'requires metrics-server', indicating a prerequisite. However, it doesn't explicitly state when to use this tool versus alternatives like k8s_top_nodes (for node metrics) or when not to use it. The guidance is implied rather than explicit.

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

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