Skip to main content
Glama

label

Add or update labels on Kubernetes resources to organize, select, and manage cluster objects using key-value pairs.

Instructions

Add or update labels on a resource

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
resourceYesThe resource type
nameYesThe name of the resource
labelsYesLabels to add/update (key=value,key2=value2)
namespaceNoThe namespace of the resource (optional, defaults to current context namespace)

Implementation Reference

  • Handler function for the 'label' tool that destructures arguments, constructs a 'kubectl label' command, executes it via execAsync, and returns the stdout or a success message.
    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}` }]
      };
    }
  • Tool schema definition for 'label', including name, description, and inputSchema with properties for resource, name, labels (required), and optional namespace.
      name: "label",
      description: "Add or update labels on a resource",
      inputSchema: {
        type: "object",
        properties: {
          resource: { 
            type: "string",
            description: "The resource type"
          },
          name: { 
            type: "string",
            description: "The name of the resource"
          },
          labels: { 
            type: "string",
            description: "Labels to add/update (key=value,key2=value2)"
          },
          namespace: { 
            type: "string",
            description: "The namespace of the resource (optional, defaults to current context namespace)"
          }
        },
        required: ["resource", "name", "labels"]
      }
    },
  • server.js:1391-1394 (registration)
    Registration of the tool list handler that returns the array of all tools (including 'label') in response to ListToolsRequestSchema.
    // Handle tool listing
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return { 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