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()

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