Skip to main content
Glama

remove_label

Remove a label from a Kubernetes resource to manage metadata and organize cluster objects. Specify resource type, name, label key, and namespace.

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
resource_typeYes
resource_nameYes
label_keyYes
namespaceNodefault

Implementation Reference

  • The main handler function for the 'remove_label' MCP tool. It uses kubectl to remove a label from a Kubernetes resource by running 'kubectl label <resource_type> <resource_name> <label_key>- --overwrite'. The @mcp.tool() decorator registers it as a tool in FastMCP, with the function signature providing the input schema via type hints and defaults.
    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