serviceaccount_create
Create a Kubernetes ServiceAccount in a specified namespace using context details and optional labels, managed via the k8s-pilot MCP server.
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 | ||
| labels | No | ||
| name | Yes | ||
| namespace | Yes |
Implementation Reference
- tools/serviceaccount.py:30-48 (handler)The core handler function that executes the logic to create a new Kubernetes ServiceAccount in the given namespace, using type hints for input schema.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)Registers the serviceaccount_create function as an MCP tool using the @mcp.tool() decorator.@mcp.tool()
- tools/serviceaccount.py:31-42 (schema)Docstring providing input arguments description and return value for the tool schema.""" 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 """