Skip to main content
Glama

remove_namespace_label

Remove a label from a Kubernetes namespace to manage cluster metadata and organization. This tool helps maintain clean namespace configurations by deleting specific labels.

Instructions

Remove a label from a namespace.

Args: context_name: The Kubernetes context name namespace: The name of the namespace label_key: The label key to remove

Returns: JSON string containing the updated namespace labels

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
context_nameYes
namespaceYes
label_keyYes

Implementation Reference

  • The main handler function for the 'remove_namespace_label' MCP tool. It removes a specified label from a Kubernetes namespace using the CoreV1Api. Includes decorators for MCP tool registration (@mcp.tool()), context usage (@use_current_context), and permission checks (@check_readonly_permission). Returns JSON with updated labels or error messages.
    @mcp.tool()
    @use_current_context
    @check_readonly_permission
    def remove_namespace_label(context_name: str, namespace: str, label_key: str):
        """
        Remove a label from a namespace.
    
        Args:
            context_name: The Kubernetes context name
            namespace: The name of the namespace
            label_key: The label key to remove
    
        Returns:
            JSON string containing the updated namespace labels
        """
        core_v1: CoreV1Api = get_api_clients(context_name)["core"]
    
        try:
            # Get the current namespace
            ns = core_v1.read_namespace(namespace)
    
            # Check if the namespace has labels
            if not ns.metadata.labels or label_key not in ns.metadata.labels:
                result = {
                    "name": namespace,
                    "labels": ns.metadata.labels,
                    "message": f"Label '{label_key}' not found on namespace"
                }
                return json.dumps(result)
    
            # Update the labels
            labels = dict(ns.metadata.labels)
            del labels[label_key]
    
            # Apply the patch
            body = {
                "metadata": {
                    "labels": labels
                }
            }
    
            patched_ns = core_v1.patch_namespace(namespace, body)
    
            result = {
                "name": patched_ns.metadata.name,
                "labels": patched_ns.metadata.labels
            }
    
            return json.dumps(result)
        except ApiException as e:
            if e.status == 404:
                return json.dumps({"error": f"Namespace '{namespace}' not found"})
            else:
                return json.dumps({"error": f"Failed to remove label: {str(e)}"})
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states the action but doesn't disclose behavioral traits like required permissions, whether this is a destructive operation, error conditions, or rate limits. The description adds minimal context beyond the basic operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and well-structured with clear sections (purpose, Args, Returns). It's front-loaded with the core purpose, though the Args and Returns sections could be slightly more concise.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 3 parameters with 0% schema coverage, no annotations, and no output schema, the description is incomplete. It explains parameters but lacks behavioral context, error handling, permissions, or detailed return format. For a mutation tool in a complex domain like Kubernetes, this leaves significant gaps.

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 0%, but the description provides a brief explanation of each parameter's purpose in the Args section. This adds meaningful semantics beyond the bare schema, though it doesn't fully compensate for the lack of schema descriptions (e.g., no format details for context_name or label_key).

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 action ('Remove a label from a namespace') with a specific verb and resource. It distinguishes from sibling tools like 'add_namespace_label' by specifying removal, but doesn't explicitly differentiate from other label/taint removal tools like 'remove_node_label' or 'remove_node_taint' in terms of scope.

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?

No guidance on when to use this tool versus alternatives is provided. The description doesn't mention prerequisites, when-not-to-use scenarios, or compare it to similar tools like 'remove_node_label' or 'remove_node_taint'. Usage is implied from the name and purpose alone.

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/bourbonkk/k8s-pilot'

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