Skip to main content
Glama

add_node_label

Add or update labels on Kubernetes nodes to organize and manage cluster resources effectively. This tool modifies node metadata for improved resource allocation and operational control.

Instructions

Add or update a label to a node.

Args: context_name: The Kubernetes context name node_name: The name of the node to modify label_key: The label key to add label_value: The label value to set

Returns: JSON string containing the updated node labels

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
context_nameYes
node_nameYes
label_keyYes
label_valueYes

Implementation Reference

  • The handler function for the 'add_node_label' tool. Decorated with @mcp.tool() for automatic registration in the MCP server. It reads the current node, updates or adds the specified label, patches the node via Kubernetes CoreV1Api, and returns the updated labels as JSON.
    @mcp.tool()
    @use_current_context
    def add_node_label(context_name: str, node_name: str, label_key: str, label_value: str):
        """
        Add or update a label to a node.
    
        Args:
            context_name: The Kubernetes context name
            node_name: The name of the node to modify
            label_key: The label key to add
            label_value: The label value to set
    
        Returns:
            JSON string containing the updated node labels
        """
        core_v1: CoreV1Api = get_api_clients(context_name)["core"]
    
        # Get the current node
        node = core_v1.read_node(node_name)
    
        # Prepare the patch
        if not node.metadata.labels:
            node.metadata.labels = {}
    
        # Update the labels
        labels = dict(node.metadata.labels)
        labels[label_key] = label_value
    
        # Apply the patch
        body = {
            "metadata": {
                "labels": labels
            }
        }
    
        patched_node = core_v1.patch_node(node_name, body)
    
        result = {
            "name": patched_node.metadata.name,
            "labels": patched_node.metadata.labels
        }
    
        return json.dumps(result)
  • tools/node.py:96-96 (registration)
    The @mcp.tool() decorator registers the add_node_label function as an MCP tool.
    @mcp.tool()
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the tool modifies a node and returns JSON, but doesn't address critical aspects like whether this requires admin permissions, if it's idempotent, potential side effects, or error conditions. This is inadequate for a mutation tool.

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

Conciseness5/5

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

The description is efficiently structured with a clear purpose statement followed by parameter documentation. Every sentence serves a purpose with zero waste, and information is appropriately front-loaded.

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

Completeness3/5

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

For a Kubernetes node mutation tool with no annotations and no output schema, the description provides basic parameter documentation but lacks important context about permissions, side effects, and error handling. It's minimally viable but has clear gaps for a tool that modifies infrastructure.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, but the description compensates well by documenting all 4 parameters with clear explanations of what each represents. The Args section adds meaningful context beyond the bare schema, though it doesn't provide format examples or constraints.

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 ('Add or update a label') and target resource ('to a node'), providing specific verb+resource. However, it doesn't explicitly differentiate from sibling tools like 'remove_node_label' or 'add_node_taint', which prevents a perfect score.

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 is provided on when to use this tool versus alternatives like 'remove_node_label' or 'add_node_taint'. The description lacks context about prerequisites, permissions needed, or typical use cases for labeling nodes in Kubernetes.

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