analyze-resource-usage
Analyze Kubernetes cluster resource usage to identify consumption patterns and optimize allocation across namespaces.
Instructions
Analyze resource usage across the cluster
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| namespace | No | The namespace to analyze (optional, analyzes all namespaces if not specified) |
Implementation Reference
- server.js:2226-2234 (handler)Handler implementation for the 'analyze-resource-usage' tool. Executes 'kubectl top pods --containers' in the specified namespace (or all) to show resource usage of pods and containers.const { namespace } = args || {}; const nsArg = namespace ? `-n ${namespace}` : ""; const cmd = `kubectl top pods ${nsArg} --containers`; const { stdout } = await execAsync(cmd); return { content: [{ type: "text", text: stdout || "Unable to analyze resource usage" }] }; }
- server.js:1358-1369 (schema)Tool definition including name, description, and input schema for 'analyze-resource-usage'. This is part of the tools list returned by listTools handler.name: "analyze-resource-usage", description: "Analyze resource usage across the cluster", inputSchema: { type: "object", properties: { namespace: { type: "string", description: "The namespace to analyze (optional, analyzes all namespaces if not specified)" } } } },
- server.js:1392-1394 (registration)Registration of the listTools handler which returns the array of all tools including 'analyze-resource-usage'.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });