Skip to main content
Glama

k8s_get_events

Retrieve Kubernetes cluster events filtered by namespace and type (Normal/Warning) to monitor and troubleshoot infrastructure issues.

Instructions

List cluster events filtered by namespace and type (Normal/Warning)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
namespaceNoKubernetes namespace (default: 'default')
typeNoEvent type: 'Normal' or 'Warning'
field_selectorNoField selector for filtering
limitNoMax number of events (default: 50)

Implementation Reference

  • Implementation of the k8s_get_events tool logic using the Kubernetes client to list events.
    export async function getEvents(args: Record<string, unknown>): Promise<string> {
      const api = getCoreV1Api();
      const namespace = (args.namespace as string) || "default";
      const type = args.type as string | undefined; // Normal, Warning
      const fieldSelector = args.field_selector as string | undefined;
      const limit = (args.limit as number) || 50;
    
      let selector = fieldSelector;
      if (type) {
        selector = selector ? `${selector},type=${type}` : `type=${type}`;
      }
    
      const response = await api.listNamespacedEvent(
        namespace,
        undefined,
        undefined,
        undefined,
        selector
      );
    
      const events = response.body.items
        .sort((a, b) => {
          const aTime = a.lastTimestamp || a.metadata?.creationTimestamp;
          const bTime = b.lastTimestamp || b.metadata?.creationTimestamp;
          return new Date(bTime || 0).getTime() - new Date(aTime || 0).getTime();
        })
        .slice(0, limit);
    
      if (events.length === 0) {
        return `No events found in namespace '${namespace}'${type ? ` of type '${type}'` : ""}.`;
      }
    
      const headers = ["LAST SEEN", "TYPE", "REASON", "OBJECT", "MESSAGE"];
      const rows = events.map((e) => [
        e.lastTimestamp ? formatAge(e.lastTimestamp) : "?",
        e.type || "Normal",
        e.reason || "",
        `${e.involvedObject.kind}/${e.involvedObject.name}`,
        (e.message || "").substring(0, 80),
      ]);
    
      return `Events in namespace '${namespace}':\n\n${formatTable(headers, rows)}`;
    }
  • Definition of the k8s_get_events tool schema.
      name: "k8s_get_events",
      description: "List cluster events filtered by namespace and type (Normal/Warning)",
      inputSchema: {
        type: "object" as const,
        properties: {
          namespace: { type: "string", description: "Kubernetes namespace (default: 'default')" },
          type: { type: "string", description: "Event type: 'Normal' or 'Warning'" },
          field_selector: { type: "string", description: "Field selector for filtering" },
          limit: { type: "number", description: "Max number of events (default: 50)" },
        },
      },
    },
  • Routing k8s_get_events tool call to the handler function in index.ts.
    case "k8s_get_events": return getEvents(a);
Behavior2/5

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

With no annotations, the description carries full burden but provides minimal behavioral insight. It mentions filtering but doesn't cover permissions needed, rate limits, pagination behavior, or what happens if parameters are omitted (defaults are only in schema). For a read operation in a complex system like Kubernetes, this is inadequate.

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 with zero wasted words. It's front-loaded with the core purpose and includes key filtering details without unnecessary elaboration.

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?

For a Kubernetes tool with 4 parameters, no annotations, and no output schema, the description is incomplete. It lacks behavioral context (e.g., safety, permissions), usage guidance, and details on return format or error handling, leaving significant gaps for an AI agent.

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 all parameters. The description adds marginal value by highlighting namespace and type filtering, but doesn't explain semantics beyond what's in the schema (e.g., how field_selector works or limit implications). Baseline 3 is appropriate.

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') and resource ('cluster events') with filtering criteria ('by namespace and type'). It distinguishes from some siblings like k8s_get_pods or k8s_get_services by specifying events, but doesn't explicitly differentiate from all possible event-related tools (though none are listed).

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 on when to use this tool versus alternatives is provided. The description doesn't mention prerequisites, context, or compare it to other tools like k8s_describe_pod for detailed event views or system_logs for broader logging.

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