Skip to main content
Glama

list-hpa

Retrieve horizontal pod autoscalers from a Kubernetes namespace to monitor and manage application scaling configurations.

Instructions

List Kubernetes horizontal pod autoscalers in a namespace

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
namespaceNoThe namespace to list HPAs from (optional, defaults to current context namespace)

Implementation Reference

  • The handler for the 'list-hpa' tool executes 'kubectl get hpa -o wide' optionally in a specified namespace to list Horizontal Pod Autoscalers (HPAs).
    case "list-hpa": {
      const { namespace } = args || {};
      const nsArg = namespace ? `-n ${namespace}` : "";
      const cmd = `kubectl get hpa ${nsArg} -o wide`;
      const { stdout } = await execAsync(cmd);
      return {
        content: [{ type: "text", text: stdout || "No horizontal pod autoscalers found" }]
      };
    }
  • The input schema definition for the 'list-hpa' tool, specifying an optional 'namespace' parameter.
    {
      name: "list-hpa",
      description: "List Kubernetes horizontal pod autoscalers in a namespace",
      inputSchema: {
        type: "object",
        properties: {
          namespace: { 
            type: "string",
            description: "The namespace to list HPAs from (optional, defaults to current context namespace)"
          }
        }
      }
    },
  • server.js:1392-1394 (registration)
    Registration handler for listing all tools, including 'list-hpa' via the 'tools' array.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return { tools };
    });
  • server.js:1397-2255 (registration)
    Main CallToolRequestSchema handler that dispatches to the specific 'list-hpa' case in the switch.
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      const { name, arguments: args } = request.params;
    
      try {
        switch (name) {
          // Basic Resource Listing
          case "list-pods": {
            const { namespace } = args || {};
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl get pods ${nsArg} -o wide`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No pods found" }]
            };
          }
    
          case "list-services": {
            const { namespace } = args || {};
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl get svc ${nsArg} -o wide`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No services found" }]
            };
          }
    
          case "list-deployments": {
            const { namespace } = args || {};
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl get deployments ${nsArg} -o wide`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No deployments found" }]
            };
          }
    
          case "list-namespaces": {
            const cmd = `kubectl get namespaces -o wide`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No namespaces found" }]
            };
          }
    
          case "list-nodes": {
            const cmd = `kubectl get nodes -o wide`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No nodes found" }]
            };
          }
    
          case "list-configmaps": {
            const { namespace } = args || {};
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl get configmaps ${nsArg} -o wide`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No configmaps found" }]
            };
          }
    
          case "list-secrets": {
            const { namespace } = args || {};
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl get secrets ${nsArg} -o wide`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No secrets found" }]
            };
          }
    
          case "list-jobs": {
            const { namespace } = args || {};
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl get jobs ${nsArg} -o wide`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No jobs found" }]
            };
          }
    
          case "list-cronjobs": {
            const { namespace } = args || {};
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl get cronjobs ${nsArg} -o wide`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No cronjobs found" }]
            };
          }
    
          case "list-ingresses": {
            const { namespace } = args || {};
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl get ingresses ${nsArg} -o wide`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No ingresses found" }]
            };
          }
    
          case "list-pv": {
            const cmd = `kubectl get pv -o wide`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No persistent volumes found" }]
            };
          }
    
          case "list-pvc": {
            const { namespace } = args || {};
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl get pvc ${nsArg} -o wide`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No persistent volume claims found" }]
            };
          }
    
          case "list-all": {
            const { namespace } = args || {};
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl get all ${nsArg} -o wide`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No resources found" }]
            };
          }
    
          // Describe Resources
          case "describe-pod": {
            const { pod, namespace } = args;
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl describe pod ${pod} ${nsArg}`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No pod details found" }]
            };
          }
    
          case "describe-deployment": {
            const { deployment, namespace } = args;
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl describe deployment ${deployment} ${nsArg}`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No deployment details found" }]
            };
          }
    
          case "describe-service": {
            const { service, namespace } = args;
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl describe service ${service} ${nsArg}`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No service details found" }]
            };
          }
    
          case "describe-node": {
            const { node } = args;
            const cmd = `kubectl describe node ${node}`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No node details found" }]
            };
          }
    
          case "describe-configmap": {
            const { configmap, namespace } = args;
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl describe configmap ${configmap} ${nsArg}`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No configmap details found" }]
            };
          }
    
          case "describe-secret": {
            const { secret, namespace } = args;
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl describe secret ${secret} ${nsArg}`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No secret details found" }]
            };
          }
    
          // Logs and Debugging
          case "get-logs": {
            const { pod, namespace, lines = 100, follow = false, container } = args;
            const nsArg = namespace ? `-n ${namespace}` : "";
            const followArg = follow ? "-f" : "";
            const containerArg = container ? `-c ${container}` : "";
            const cmd = `kubectl logs ${pod} ${nsArg} --tail=${lines} ${followArg} ${containerArg}`.trim();
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No logs found" }]
            };
          }
    
          case "get-events": {
            const { namespace } = args || {};
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl get events ${nsArg} --sort-by='.lastTimestamp'`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No events found" }]
            };
          }
    
          case "top-pods": {
            const { namespace } = args || {};
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl top pods ${nsArg}`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No pod metrics found" }]
            };
          }
    
          case "top-nodes": {
            const cmd = `kubectl top nodes`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No node metrics found" }]
            };
          }
    
          // Networking
          case "port-forward": {
            const { service, namespace, localPort, targetPort } = args;
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl port-forward svc/${service} ${localPort}:${targetPort} ${nsArg}`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ 
                type: "text", 
                text: stdout || `Port-forwarding started for ${service}:${targetPort} -> localhost:${localPort}` 
              }]
            };
          }
    
          case "port-forward-pod": {
            const { pod, namespace, localPort, targetPort } = args;
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl port-forward pod/${pod} ${localPort}:${targetPort} ${nsArg}`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ 
                type: "text", 
                text: stdout || `Port-forwarding started for ${pod}:${targetPort} -> localhost:${localPort}` 
              }]
            };
          }
    
          // Resource Management
          case "scale-deployment": {
            const { deployment, namespace, replicas } = args;
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl scale deployment ${deployment} --replicas=${replicas} ${nsArg}`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ 
                type: "text", 
                text: stdout || `Deployment ${deployment} scaled to ${replicas} replicas` 
              }]
            };
          }
    
          case "rollout-status": {
            const { deployment, namespace } = args;
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl rollout status deployment/${deployment} ${nsArg}`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "Unable to get rollout status" }]
            };
          }
    
          case "rollout-restart": {
            const { deployment, namespace } = args;
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl rollout restart deployment/${deployment} ${nsArg}`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ 
                type: "text", 
                text: stdout || `Deployment ${deployment} rollout restarted` 
              }]
            };
          }
    
          case "rollout-history": {
            const { deployment, namespace } = args;
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl rollout history deployment/${deployment} ${nsArg}`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No rollout history found" }]
            };
          }
    
          case "set-image": {
            const { deployment, container, image, namespace } = args;
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl set image deployment/${deployment} ${container}=${image} ${nsArg}`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ 
                type: "text", 
                text: stdout || `Image updated for deployment ${deployment}` 
              }]
            };
          }
    
          // Exec and File Operations
          case "exec": {
            const { pod, command, namespace, container } = args;
            const nsArg = namespace ? `-n ${namespace}` : "";
            const containerArg = container ? `-c ${container}` : "";
            const cmd = `kubectl exec ${pod} ${nsArg} ${containerArg} -- ${command}`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "Command executed" }]
            };
          }
    
          case "cp": {
            const { pod, source, destination, namespace, container } = args;
            const nsArg = namespace ? `-n ${namespace}` : "";
            const containerArg = container ? `-c ${container}` : "";
            const cmd = `kubectl cp ${source} ${pod}:${destination} ${nsArg} ${containerArg}`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ 
                type: "text", 
                text: stdout || `File copied from ${source} to ${pod}:${destination}` 
              }]
            };
          }
    
          // Configuration and Secrets
          case "get-configmap": {
            const { configmap, namespace } = args;
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl get configmap ${configmap} ${nsArg} -o yaml`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No configmap data found" }]
            };
          }
    
          case "get-secret": {
            const { secret, namespace } = args;
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl get secret ${secret} ${nsArg} -o yaml`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No secret data found" }]
            };
          }
    
          // Cluster Information
          case "cluster-info": {
            const cmd = `kubectl cluster-info`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "Unable to get cluster info" }]
            };
          }
    
          case "version": {
            const cmd = `kubectl version --short`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "Unable to get version info" }]
            };
          }
    
          case "api-resources": {
            const cmd = `kubectl api-resources`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No API resources found" }]
            };
          }
    
          case "api-versions": {
            const cmd = `kubectl api-versions`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No API versions found" }]
            };
          }
    
          // Context and Configuration
          case "current-context": {
            const cmd = `kubectl config current-context`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout.trim() || "No current context" }]
            };
          }
    
          case "get-contexts": {
            const cmd = `kubectl config get-contexts`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No contexts found" }]
            };
          }
    
          case "use-context": {
            const { context } = args;
            const cmd = `kubectl config use-context ${context}`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ 
                type: "text", 
                text: stdout || `Switched to context ${context}` 
              }]
            };
          }
    
          // Resource Creation/Deletion
          case "apply": {
            const { file, namespace } = args;
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl apply -f ${file} ${nsArg}`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ 
                type: "text", 
                text: stdout || `Applied manifest from ${file}` 
              }]
            };
          }
    
          case "delete": {
            const { resource, name, namespace } = args;
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl delete ${resource} ${name} ${nsArg}`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ 
                type: "text", 
                text: stdout || `Deleted ${resource} ${name}` 
              }]
            };
          }
    
          case "create-namespace": {
            const { name } = args;
            const cmd = `kubectl create namespace ${name}`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ 
                type: "text", 
                text: stdout || `Created namespace ${name}` 
              }]
            };
          }
    
          // Debugging Tools
          case "debug-pod": {
            const { pod, namespace, image = "busybox" } = args;
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl debug ${pod} ${nsArg} --image=${image} --share-processes --copy-to=${pod}-debug`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ 
                type: "text", 
                text: stdout || `Debug pod created for ${pod}` 
              }]
            };
          }
    
          case "run": {
            const { name, image, namespace, command } = args;
            const nsArg = namespace ? `-n ${namespace}` : "";
            const commandArg = command ? `-- ${command}` : "";
            const cmd = `kubectl run ${name} --image=${image} ${nsArg} ${commandArg}`.trim();
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ 
                type: "text", 
                text: stdout || `Pod ${name} created with image ${image}` 
              }]
            };
          }
    
          // Helm Operations
          case "helm-list": {
            const { namespace } = args || {};
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `helm list ${nsArg}`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No Helm releases found" }]
            };
          }
    
          case "helm-status": {
            const { release, namespace } = args;
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `helm status ${release} ${nsArg}`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "Unable to get Helm release status" }]
            };
          }
    
          // Security and RBAC
          case "list-serviceaccounts": {
            const { namespace } = args || {};
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl get serviceaccounts ${nsArg} -o wide`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No service accounts found" }]
            };
          }
    
          case "list-roles": {
            const { namespace } = args || {};
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl get roles ${nsArg} -o wide`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No roles found" }]
            };
          }
    
          case "list-rolebindings": {
            const { namespace } = args || {};
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl get rolebindings ${nsArg} -o wide`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No role bindings found" }]
            };
          }
    
          case "list-clusterroles": {
            const cmd = `kubectl get clusterroles -o wide`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No cluster roles found" }]
            };
          }
    
          case "list-clusterrolebindings": {
            const cmd = `kubectl get clusterrolebindings -o wide`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No cluster role bindings found" }]
            };
          }
    
          case "auth-can-i": {
            const { verb, resource, namespace } = args;
            const nsArg = namespace ? `--namespace=${namespace}` : "";
            const cmd = `kubectl auth can-i ${verb} ${resource} ${nsArg}`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "Authorization check result" }]
            };
          }
    
          // Advanced Networking
          case "list-networkpolicies": {
            const { namespace } = args || {};
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl get networkpolicies ${nsArg} -o wide`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No network policies found" }]
            };
          }
    
          case "list-endpoints": {
            const { namespace } = args || {};
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl get endpoints ${nsArg} -o wide`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No endpoints found" }]
            };
          }
    
          // Resource Management
          case "list-resourcequotas": {
            const { namespace } = args || {};
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl get resourcequotas ${nsArg} -o wide`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No resource quotas found" }]
            };
          }
    
          case "list-limitranges": {
            const { namespace } = args || {};
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl get limitranges ${nsArg} -o wide`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No limit ranges found" }]
            };
          }
    
          case "list-hpa": {
            const { namespace } = args || {};
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl get hpa ${nsArg} -o wide`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No horizontal pod autoscalers found" }]
            };
          }
    
          // Custom Resources
          case "list-crds": {
            const cmd = `kubectl get crds -o wide`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No custom resource definitions found" }]
            };
          }
    
          case "get-crd": {
            const { name } = args;
            const cmd = `kubectl get crd ${name} -o yaml`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "CRD not found" }]
            };
          }
    
          // Advanced Operations
          case "wait": {
            const { resource, name, condition, namespace, timeout = "300s" } = args;
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl wait ${resource}/${name} --for=condition=${condition} --timeout=${timeout} ${nsArg}`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || `Wait condition met for ${resource}/${name}` }]
            };
          }
    
          case "patch": {
            const { resource, name, patch, type = "strategic", namespace } = args;
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl patch ${resource} ${name} --type=${type} -p '${patch}' ${nsArg}`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || `${resource} ${name} patched successfully` }]
            };
          }
    
          case "label": {
            const { resource, name, labels, namespace } = args;
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl label ${resource} ${name} ${labels} ${nsArg}`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || `Labels updated on ${resource} ${name}` }]
            };
          }
    
          case "annotate": {
            const { resource, name, annotations, namespace } = args;
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl annotate ${resource} ${name} ${annotations} ${nsArg}`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || `Annotations updated on ${resource} ${name}` }]
            };
          }
    
          // Troubleshooting and Diagnostics
          case "get-pod-metrics": {
            const { pod, namespace } = args;
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl get pod ${pod} ${nsArg} -o jsonpath='{.spec.containers[*].resources}' | jq .`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "Unable to get pod metrics" }]
            };
          }
    
          case "get-node-metrics": {
            const { node } = args;
            const cmd = `kubectl describe node ${node}`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "Unable to get node metrics" }]
            };
          }
    
          case "cordon-node": {
            const { node } = args;
            const cmd = `kubectl cordon ${node}`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || `Node ${node} cordoned` }]
            };
          }
    
          case "uncordon-node": {
            const { node } = args;
            const cmd = `kubectl uncordon ${node}`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || `Node ${node} uncordoned` }]
            };
          }
    
          case "drain-node": {
            const { node, force = false, ignore_daemonsets = true } = args;
            const forceArg = force ? "--force" : "";
            const ignoreArg = ignore_daemonsets ? "--ignore-daemonsets" : "";
            const cmd = `kubectl drain ${node} ${forceArg} ${ignoreArg} --delete-emptydir-data`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || `Node ${node} drained successfully` }]
            };
          }
    
          // Advanced Helm Operations
          case "helm-install": {
            const { name, chart, namespace, values, version } = args;
            const nsArg = namespace ? `-n ${namespace}` : "";
            const versionArg = version ? `--version ${version}` : "";
            const valuesArg = values ? `-f <(echo '${values}')` : "";
            const cmd = `helm install ${name} ${chart} ${nsArg} ${versionArg} ${valuesArg}`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || `Helm chart ${chart} installed as ${name}` }]
            };
          }
    
          case "helm-upgrade": {
            const { name, chart, namespace, values } = args;
            const nsArg = namespace ? `-n ${namespace}` : "";
            const valuesArg = values ? `-f <(echo '${values}')` : "";
            const cmd = `helm upgrade ${name} ${chart} ${nsArg} ${valuesArg}`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || `Helm release ${name} upgraded` }]
            };
          }
    
          case "helm-uninstall": {
            const { name, namespace } = args;
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `helm uninstall ${name} ${nsArg}`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || `Helm release ${name} uninstalled` }]
            };
          }
    
          // ArgoCD Operations
          case "argocd-list-apps": {
            const { namespace = "argocd" } = args || {};
            const cmd = `kubectl get applications -n ${namespace} -o wide`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No ArgoCD applications found" }]
            };
          }
    
          case "argocd-app-status": {
            const { app, namespace = "argocd" } = args;
            const cmd = `kubectl get application ${app} -n ${namespace} -o yaml`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "ArgoCD application not found" }]
            };
          }
    
          // Istio Operations
          case "istio-list-virtualservices": {
            const { namespace } = args || {};
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl get virtualservices ${nsArg} -o wide`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No Istio virtual services found" }]
            };
          }
    
          case "istio-list-gateways": {
            const { namespace } = args || {};
            const nsArg = namespace ? `-n ${namespace}` : "";
            const cmd = `kubectl get gateways ${nsArg} -o wide`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "No Istio gateways found" }]
            };
          }
    
          // Prometheus/Kube State Metrics
          case "get-cluster-metrics": {
            const cmd = `kubectl get --raw /apis/metrics.k8s.io/v1beta1/nodes`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || "Unable to get cluster metrics" }]
            };
          }
    
          // Advanced Debugging
          case "create-ephemeral-container": {
            const { pod, image, name, namespace, command } = args;
            const nsArg = namespace ? `-n ${namespace}` : "";
            const commandArg = command ? `-- ${command}` : "";
            const cmd = `kubectl debug ${pod} ${nsArg} --image=${image} --container=${name} --ephemeral-containers ${commandArg}`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || `Ephemeral container ${name} created in pod ${pod}` }]
            };
          }
    
          // Resource Analysis
          case "analyze-resource-usage": {
            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" }]
            };
          }
    
          // Backup and Recovery
          case "create-backup": {
            const { namespace, output = "backup.yaml" } = args || {};
            const nsArg = namespace ? `-n ${namespace}` : "--all-namespaces";
            const cmd = `kubectl get all ${nsArg} -o yaml > ${output}`;
            const { stdout } = await execAsync(cmd);
            return {
              content: [{ type: "text", text: stdout || `Backup created in ${output}` }]
            };
          }
    
          default:
            throw new Error(`Unknown tool: ${name}`);
        }
      } catch (error) {
        return {
          content: [{ type: "text", text: `Error: ${error.message}` }],
          isError: true
        };
      }
    });
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It only states the action without mentioning permissions required, output format, pagination, error handling, or whether it's a read-only operation. This leaves significant gaps for an agent to understand how to use it effectively.

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 directly states the tool's purpose without unnecessary words. It's appropriately sized for a simple listing tool and front-loads the essential information.

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?

For a simple listing tool with one optional parameter and no output schema, the description is minimally adequate but lacks important context. Without annotations or output schema, it should ideally mention the return format (e.g., list of HPA objects) or behavioral aspects like permissions. The completeness is borderline given the tool's low complexity.

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 input schema already documents the single optional parameter 'namespace' with its default behavior. The description doesn't add any parameter-specific information beyond what's in the schema, meeting the baseline for high coverage.

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 verb ('List') and resource ('Kubernetes horizontal pod autoscalers') with scope ('in a namespace'), making the purpose unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'list-all' or 'list-deployments', which would require mentioning HPA-specific characteristics.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'list-all' (which might list all resources including HPAs) or 'get-pod-metrics' (which might relate to autoscaling data), nor does it specify prerequisites or exclusions for usage.

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/thekaranpargaie/kube-mcp'

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