serviceaccount_list
List all ServiceAccounts in a specified Kubernetes namespace. Retrieve essential details for each ServiceAccount to manage and monitor cluster resources efficiently. Works within the k8s-pilot MCP server, supporting multi-cluster operations.
Instructions
List all ServiceAccounts in a given namespace.
Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace
Returns: List of ServiceAccount basic information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| context_name | Yes | ||
| namespace | Yes |
Implementation Reference
- tools/serviceaccount.py:8-24 (handler)The handler function that implements the logic for listing ServiceAccounts in a specified namespace using Kubernetes API.@mcp.tool() @use_current_context def serviceaccount_list(context_name: str, namespace: str): """ List all ServiceAccounts in a given namespace. Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace Returns: List of ServiceAccount basic information """ core_v1: CoreV1Api = get_api_clients(context_name)["core"] serviceaccounts = core_v1.list_namespaced_service_account(namespace) result = [{"name": sa.metadata.name} for sa in serviceaccounts.items] return result
- server/server.py:23-23 (registration)The import statement that loads the serviceaccount.py module, triggering the registration of the serviceaccount_list tool via its @mcp.tool() decorator.import tools.serviceaccount # noqa: F401