secret_update
Modify Kubernetes Secrets by updating key-value pairs in a specified namespace. This tool changes sensitive configuration data stored as base64-encoded values for applications.
Instructions
Update an existing Secret in the specified namespace.
Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The Secret name data: A dictionary of key-value pairs (values will be base64 encoded)
Returns: Status of the update operation
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| context_name | Yes | ||
| namespace | Yes | ||
| name | Yes | ||
| data | Yes |
Implementation Reference
- tools/secret.py:80-101 (handler)The core handler implementation for the 'secret_update' MCP tool. It reads the existing Kubernetes Secret, encodes the provided data, updates the Secret's data field, and replaces the Secret in the cluster using the Kubernetes API. Decorators handle tool registration (@mcp.tool()), context management (@use_current_context), and permissions (@check_readonly_permission).@mcp.tool() @use_current_context @check_readonly_permission def secret_update(context_name: str, namespace: str, name: str, data: dict): """ Update an existing Secret in the specified namespace. Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The Secret name data: A dictionary of key-value pairs (values will be base64 encoded) Returns: Status of the update operation """ core_v1: CoreV1Api = get_api_clients(context_name)["core"] secret = core_v1.read_namespaced_secret(name=name, namespace=namespace) encoded_data = {key: base64.b64encode(value.encode()).decode() for key, value in data.items()} secret.data.update(encoded_data) updated_secret = core_v1.replace_namespaced_secret(name=name, namespace=namespace, body=secret) return {"name": updated_secret.metadata.name, "status": "Updated"}