serviceaccount_create
Create a ServiceAccount in Kubernetes to manage cluster access permissions and authentication for applications or users.
Instructions
Create a ServiceAccount in the specified namespace.
Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The ServiceAccount name labels: Optional labels to apply to the ServiceAccount
Returns: Status of the creation operation
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| context_name | Yes | ||
| namespace | Yes | ||
| name | Yes | ||
| labels | No |
Implementation Reference
- tools/serviceaccount.py:27-48 (handler)The handler function for the 'serviceaccount_create' tool. It is decorated with @mcp.tool() for registration, @use_current_context to set the current context, and @check_readonly_permission for access control. The function creates a Kubernetes ServiceAccount in the given namespace using the CoreV1Api client.@mcp.tool() @use_current_context @check_readonly_permission def serviceaccount_create(context_name: str, namespace: str, name: str, labels: dict = None): """ Create a ServiceAccount in the specified namespace. Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The ServiceAccount name labels: Optional labels to apply to the ServiceAccount Returns: Status of the creation operation """ core_v1: CoreV1Api = get_api_clients(context_name)["core"] serviceaccount = V1ServiceAccount( metadata=V1ObjectMeta(name=name, labels=labels) ) created_serviceaccount = core_v1.create_namespaced_service_account(namespace=namespace, body=serviceaccount) return {"name": created_serviceaccount.metadata.name, "status": "Created"}
- tools/serviceaccount.py:27-27 (registration)The @mcp.tool() decorator registers the serviceaccount_create function as an MCP tool.@mcp.tool()