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
| Name | Required | Description | Default |
|---|---|---|---|
| resource | Yes | The resource type | |
| name | Yes | The name of the resource | |
| labels | Yes | Labels to add/update (key=value,key2=value2) | |
| namespace | No | The namespace of the resource (optional, defaults to current context namespace) |
Implementation Reference
- server.js:2060-2068 (handler)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}` }] }; }
- server.js:1041-1065 (schema)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 }; });