service_update
Modify Service metadata, such as labels, in Kubernetes clusters. Use context_name, namespace, and name to identify the Service, then apply updated labels to streamline resource management and organization.
Instructions
Update an existing Service's metadata (e.g., labels).
Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The Service name labels: New labels to apply to the Service
Returns: Status of the update operation
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| context_name | Yes | ||
| labels | Yes | ||
| name | Yes | ||
| namespace | Yes |
Implementation Reference
- tools/service.py:83-103 (handler)The service_update tool handler, decorated with @mcp.tool() for registration. Updates the labels on an existing Kubernetes Service using the patch API.@mcp.tool() @use_current_context @check_readonly_permission def service_update(context_name: str, namespace: str, name: str, labels: dict): """ Update an existing Service's metadata (e.g., labels). Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The Service name labels: New labels to apply to the Service Returns: Status of the update operation """ core_v1: CoreV1Api = get_api_clients(context_name)["core"] service = core_v1.read_namespaced_service(name=name, namespace=namespace) service.metadata.labels = labels updated_service = core_v1.patch_namespaced_service(name=name, namespace=namespace, body={"metadata": {"labels": labels}}) return {"name": updated_service.metadata.name, "status": "Updated", "labels": updated_service.metadata.labels}
- tools/service.py:86-98 (schema)Input schema defined by function parameters and docstring Args/Returns.def service_update(context_name: str, namespace: str, name: str, labels: dict): """ Update an existing Service's metadata (e.g., labels). Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The Service name labels: New labels to apply to the Service Returns: Status of the update operation """