Skip to main content
Glama

k8s_get_pods

Retrieve and monitor Kubernetes pods by listing their status, restart counts, and age. Filter results using namespace, label selectors, or field selectors to manage container workloads.

Instructions

List pods in a Kubernetes namespace with their status, restarts, and age

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
namespaceNoKubernetes namespace (default: 'default')
label_selectorNoLabel selector to filter pods (e.g., 'app=nginx')
field_selectorNoField selector (e.g., 'status.phase=Running')

Implementation Reference

  • The actual logic that calls the Kubernetes API to get pods.
    export async function getPods(args: Record<string, unknown>): Promise<string> {
      const api = getCoreV1Api();
      const namespace = (args.namespace as string) || "default";
      const labelSelector = args.label_selector as string | undefined;
      const fieldSelector = args.field_selector as string | undefined;
    
      const response = await api.listNamespacedPod(
        namespace,
        undefined,
        undefined,
        undefined,
        fieldSelector,
        labelSelector
      );
    
      const pods = response.body.items;
      if (pods.length === 0) {
        return `No pods found in namespace '${namespace}'${labelSelector ? ` with selector '${labelSelector}'` : ""}.`;
      }
    
      const headers = ["NAME", "READY", "STATUS", "RESTARTS", "AGE"];
      const rows = pods.map((pod) => {
        const containers = pod.status?.containerStatuses || [];
        const ready = containers.filter((c) => c.ready).length;
        const total = containers.length || pod.spec?.containers.length || 0;
        const restarts = containers.reduce((sum, c) => sum + (c.restartCount || 0), 0);
        const status = pod.status?.phase || "Unknown";
        const age = pod.metadata?.creationTimestamp
          ? formatAge(pod.metadata.creationTimestamp)
          : "?";
    
        return [
          pod.metadata?.name || "unknown",
          `${ready}/${total}`,
          status,
          String(restarts),
          age,
        ];
      });
    
      return `Pods in namespace '${namespace}':\n\n${formatTable(headers, rows)}`;
    }
  • The tool definition (schema) for k8s_get_pods.
    {
      name: "k8s_get_pods",
      description: "List pods in a Kubernetes namespace with their status, restarts, and age",
      inputSchema: {
        type: "object" as const,
        properties: {
          namespace: { type: "string", description: "Kubernetes namespace (default: 'default')" },
          label_selector: { type: "string", description: "Label selector to filter pods (e.g., 'app=nginx')" },
          field_selector: { type: "string", description: "Field selector (e.g., 'status.phase=Running')" },
        },
      },
    },
  • The dispatcher logic inside handleKubernetesTool that routes the request to the getPods function.
    case "k8s_get_pods": return getPods(a);
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. It mentions the returned fields (status, restarts, age) but lacks critical behavioral details: it doesn't specify if this is a read-only operation, whether it requires specific permissions, if there are rate limits, the output format (e.g., table, JSON), or pagination handling. For a tool with no annotations, this leaves significant gaps in understanding its behavior.

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, efficient sentence that front-loads the core action ('List pods') and includes key details (location, returned fields). There is no wasted text, repetition, or unnecessary elaboration, making it highly concise and well-structured for quick understanding.

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 the tool's moderate complexity (listing with optional filters), 100% schema coverage, and no output schema, the description is minimally adequate. It covers the basic purpose but lacks behavioral context (e.g., safety, permissions, output format) and usage guidelines, which are important for a tool interacting with a Kubernetes cluster. Without annotations or output schema, more detail would improve completeness.

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%, so the schema fully documents the three parameters (namespace, label_selector, field_selector). The description adds no parameter-specific information beyond implying a listing action, which the schema already covers through parameter descriptions. This meets the baseline of 3 for high schema coverage without additional value.

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 action ('List pods') and resource ('in a Kubernetes namespace'), specifying what information is returned ('status, restarts, and age'). It distinguishes from other k8s tools like 'k8s_describe_pod' or 'k8s_get_pod_logs' by focusing on listing with specific fields, though it doesn't explicitly differentiate from 'k8s_get_deployments' or 'k8s_get_services' beyond the resource type.

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?

No guidance is provided on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing cluster access), compare to sibling tools like 'k8s_describe_pod' for detailed info or 'k8s_get_pod_logs' for logs, or specify scenarios where it's preferred. The description only states what it does, not when to use it.

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