Skip to main content
Glama
BenedatLLC
by BenedatLLC

get_namespaces

Retrieve a summary of Kubernetes cluster namespaces, including name, status, and age, similar to kubectl get namespace. Simplifies namespace monitoring without manual API calls.

Instructions

Return a summary of the namespaces for this Kubernetes cluster, similar to that returned by kubectl get namespace.

Parameters ---------- None This function does not take any parameters. Returns ------- list of NamespaceSummary List of namespace summary objects. Each NamespaceSummary has the following fields: name : str Name of the namespace. status : str Status phase of the namespace. age : datetime.timedelta Age of the namespace (current time minus creation timestamp). Raises ------ K8sConfigError If unable to initialize the K8S API. K8sApiError If the API call to list namespaces fails.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function for the 'get_namespaces' tool. It initializes the Kubernetes API client if needed, lists all namespaces, computes their age, and returns a list of NamespaceSummary objects.
    def get_namespaces() -> list[NamespaceSummary]: """Return a summary of the namespaces for this Kubernetes cluster, similar to that returned by `kubectl get namespace`. Parameters ---------- None This function does not take any parameters. Returns ------- list of NamespaceSummary List of namespace summary objects. Each NamespaceSummary has the following fields: name : str Name of the namespace. status : str Status phase of the namespace. age : datetime.timedelta Age of the namespace (current time minus creation timestamp). Raises ------ K8sConfigError If unable to initialize the K8S API. K8sApiError If the API call to list namespaces fails. """ global K8S if K8S is None: K8S = _get_api_client() logging.info(f"get_namespaces()") namespaces = K8S.list_namespace().items now = datetime.datetime.now(datetime.timezone.utc) return [ NamespaceSummary(name=namespace.metadata.name, status=namespace.status.phase, age=now-namespace.metadata.creation_timestamp) for namespace in namespaces ]
  • Pydantic BaseModel defining the output schema for the get_namespaces tool, with fields for name, status, and age of each namespace.
    class NamespaceSummary(BaseModel): """Summary information about a namespace, like returned by `kubectl get namespace`""" name: str status: str age: datetime.timedelta
  • Registration of the get_namespaces tool (and others) in the TOOLS list, which is likely used by the MCP server to expose these functions as tools.
    TOOLS = [ get_namespaces, get_node_summaries, get_pod_summaries, get_pod_container_statuses, get_pod_events, get_pod_spec, get_logs_for_pod_and_container, get_deployment_summaries, get_service_summaries ]

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/BenedatLLC/k8stools'

If you have feedback or need assistance with the MCP directory API, please join our Discord server