serviceaccount_list
List all ServiceAccounts in a specified Kubernetes namespace to manage access controls and permissions across clusters.
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 main handler function for the 'serviceaccount_list' tool. It lists ServiceAccounts in the specified namespace using the Kubernetes CoreV1Api. Decorated with @mcp.tool() for automatic registration and @use_current_context for context management.@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 in load_modules() that triggers the execution of the module, thereby registering the tool via its @mcp.tool() decorator.import tools.serviceaccount # noqa: F401
- server/server.py:3-3 (registration)Definition of the mcp instance (FastMCP) used for tool registration via decorators.mcp = FastMCP("k8s-pilot")