Skip to main content
Glama

list_namespaces

Retrieve and display all namespaces in a Kubernetes cluster using the specified context, returning detailed information in JSON format for streamlined management and monitoring.

Instructions

List all namespaces in the Kubernetes cluster.

Args: context_name: The Kubernetes context name

Returns: JSON string containing basic information about all namespaces

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
context_nameYes

Implementation Reference

  • The handler function decorated with @mcp.tool() that lists all Kubernetes namespaces in the specified context and returns a JSON array of namespace names.
    @mcp.tool() @use_current_context def list_namespaces(context_name: str): """ List all namespaces in the Kubernetes cluster. Args: context_name: The Kubernetes context name Returns: JSON string containing basic information about all namespaces """ core_v1: CoreV1Api = get_api_clients(context_name)["core"] namespaces = core_v1.list_namespace() result = [{"name": ns.metadata.name} for ns in namespaces.items] return json.dumps(result)
  • The @mcp.tool() decorator registers the list_namespaces function as an MCP tool.
    @mcp.tool()

Other Tools

Related Tools

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/bourbonkk/k8s-pilot'

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