Skip to main content
Glama

remove_label

Remove a specific label from Kubernetes resources such as pods, services, or deployments by specifying the resource type, name, label key, and namespace using the MCP Kubernetes Server.

Instructions

Remove a label from a Kubernetes resource

Args: resource_type: Type of the resource (e.g., pod, service, deployment) resource_name: Name of the resource to remove the label from label_key: Key of the label to remove namespace: Namespace of the resource

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
label_keyYes
namespaceNodefault
resource_nameYes
resource_typeYes

Implementation Reference

  • The handler function for the 'remove_label' MCP tool. It is registered via the @mcp.tool() decorator and implements the logic to remove a label from a Kubernetes resource using the 'kubectl label' command with the label key suffixed by '-'.
    @mcp.tool() async def remove_label(resource_type: str, resource_name: str, label_key: str, namespace: str = "default") -> dict: """Remove a label from a Kubernetes resource Args: resource_type: Type of the resource (e.g., pod, service, deployment) resource_name: Name of the resource to remove the label from label_key: Key of the label to remove namespace: Namespace of the resource """ try: cmd = ["kubectl", "label", resource_type, resource_name, f"{label_key}-", "-n", namespace, "--overwrite"] result = subprocess.run(cmd, capture_output=True, text=True, check=True) return {"message": f"Label {label_key} removed from resource {resource_type}/{resource_name} in namespace {namespace}", "details": result.stdout} except subprocess.CalledProcessError as e: return {"error": f"Failed to remove label: {str(e)}"}

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/abhijeetka/mcp-k8s-server'

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