Skip to main content
Glama

add_node_taint

Add a taint to a Kubernetes node to control pod scheduling by specifying key, value, and effect (NoSchedule, PreferNoSchedule, or NoExecute).

Instructions

Add a taint to a node.

Args: context_name: The Kubernetes context name node_name: The name of the node to modify taint_key: The taint key to add taint_value: The taint value to set taint_effect: The taint effect (NoSchedule, PreferNoSchedule, or NoExecute)

Returns: JSON string containing the updated node taints

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
context_nameYes
node_nameYes
taint_keyYes
taint_valueYes
taint_effectYes

Implementation Reference

  • The add_node_taint tool handler function. It adds or updates a taint on a Kubernetes node using the Kubernetes API. Decorated with @mcp.tool() for registration and @use_current_context for context management. Includes input validation for taint effect, handles existing taints, patches the node spec, and returns JSON with updated taints.
    @mcp.tool()
    @use_current_context
    def add_node_taint(context_name: str, node_name: str, taint_key: str,
                       taint_value: str, taint_effect: str):
        """
        Add a taint to a node.
    
        Args:
            context_name: The Kubernetes context name
            node_name: The name of the node to modify
            taint_key: The taint key to add
            taint_value: The taint value to set
            taint_effect: The taint effect (NoSchedule, PreferNoSchedule, or NoExecute)
    
        Returns:
            JSON string containing the updated node taints
        """
        core_v1: CoreV1Api = get_api_clients(context_name)["core"]
    
        # Validate the taint effect
        valid_effects = ["NoSchedule", "PreferNoSchedule", "NoExecute"]
        if taint_effect not in valid_effects:
            result = {
                "error": f"Invalid taint effect. Must be one of {', '.join(valid_effects)}"
            }
            return json.dumps(result)
    
        # Get the current node
        node = core_v1.read_node(node_name)
    
        # Prepare the taints
        current_taints = []
        if node.spec.taints:
            current_taints = node.spec.taints
    
        # Check if taint with this key already exists
        exists = False
        for i, taint in enumerate(current_taints):
            if taint.key == taint_key:
                # Update existing taint
                current_taints[i] = V1Taint(
                    key=taint_key,
                    value=taint_value,
                    effect=taint_effect
                )
                exists = True
                break
    
        # Add new taint if it doesn't exist
        if not exists:
            current_taints.append(V1Taint(
                key=taint_key,
                value=taint_value,
                effect=taint_effect
            ))
    
        # Apply the patch
        body = {
            "spec": {
                "taints": [
                    {
                        "key": taint.key,
                        "value": taint.value,
                        "effect": taint.effect
                    } for taint in current_taints
                ]
            }
        }
    
        patched_node = core_v1.patch_node(node_name, body)
    
        # Format the taints for response
        response_taints = []
        if patched_node.spec.taints:
            response_taints = [
                {
                    "key": taint.key,
                    "value": taint.value,
                    "effect": taint.effect
                } for taint in patched_node.spec.taints
            ]
    
        result = {
            "name": patched_node.metadata.name,
            "taints": response_taints
        }
    
        return json.dumps(result)
  • tools/node.py:190-190 (registration)
    The @mcp.tool() decorator registers the add_node_taint 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 states this is a modification operation ('Add a taint to a node') which implies mutation, but doesn't mention required permissions, whether this is destructive to existing workloads, rate limits, or what happens if the taint already exists. The return format is mentioned but without details about error conditions or side effects.

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 efficiently structured with a clear purpose statement followed by well-organized parameter documentation and return information. Every sentence serves a purpose, though the 'Args:' and 'Returns:' formatting could be more integrated with the main description rather than appearing as separate documentation blocks.

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 5-parameter mutation tool with no annotations and no output schema, the description provides adequate but incomplete coverage. The parameters are well-documented, but critical behavioral aspects are missing: no information about permissions required, error conditions, whether this affects running pods, or what the JSON return structure contains beyond 'updated node taints.'

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?

With 0% schema description coverage, the description provides excellent parameter documentation. Each of the 5 parameters is clearly explained with meaningful context: 'context_name' identifies the Kubernetes context, 'node_name' specifies which node, and the taint components (key, value, effect) are defined with the effect's valid values explicitly listed. This fully compensates for the schema's lack of descriptions.

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 verb ('Add') and resource ('taint to a node'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'remove_node_taint' beyond the obvious directionality, nor does it explain what a taint is in Kubernetes context for someone unfamiliar with the concept.

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 about when to use this tool versus alternatives. While 'remove_node_taint' is clearly the opposite operation, there's no mention of when tainting is appropriate versus other node management approaches like cordoning, nor prerequisites like required permissions or cluster state.

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