pod_update
Update Kubernetes pod labels to modify metadata for existing pods, enabling resource organization and management within clusters.
Instructions
Update an existing pod's metadata (only labels can be updated for an existing pod).
Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The pod name labels: New labels to apply to the pod
Returns: Information about the updated pod
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| context_name | Yes | ||
| namespace | Yes | ||
| name | Yes | ||
| labels | No |
Implementation Reference
- tools/pod.py:246-282 (handler)The handler function implementing the pod_update tool logic. It reads the existing pod, updates its labels if provided, patches the pod via Kubernetes API, and returns the updated pod information.def pod_update(context_name: str, namespace: str, name: str, labels: Optional[Dict[str, str]] = None): """ Update an existing pod's metadata (only labels can be updated for an existing pod). Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The pod name labels: New labels to apply to the pod Returns: Information about the updated pod """ core_v1: CoreV1Api = get_api_clients(context_name)["core"] # Get the current pod pod = core_v1.read_namespaced_pod(name=name, namespace=namespace) # Update pod labels if provided if labels: pod.metadata.labels = labels # Update the pod in Kubernetes updated_pod = core_v1.patch_namespaced_pod( name=name, namespace=namespace, body={"metadata": {"labels": labels}} ) result = { "name": updated_pod.metadata.name, "namespace": updated_pod.metadata.namespace, "status": updated_pod.status.phase, "labels": updated_pod.metadata.labels, } return result
- tools/pod.py:243-243 (registration)The @mcp.tool() decorator registers the pod_update function as an MCP tool.@mcp.tool()
- tools/pod.py:244-245 (registration)Decorators providing context and permission checks for the pod_update tool.@use_current_context @check_readonly_permission