Skip to main content
Glama

list_namespaces

Retrieve all Kubernetes namespaces in a cluster to manage resources and organize workloads by context.

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 for the 'list_namespaces' tool. It uses Kubernetes CoreV1Api to list all namespaces in the specified context and returns a JSON array of namespace names. Registered via @mcp.tool() decorator.
    @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()
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It states the tool lists namespaces and returns JSON, but doesn't disclose critical behavioral traits such as whether it requires specific permissions, how it handles errors, if it's read-only or has side effects, or any rate limits. For a Kubernetes tool with zero annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured and front-loaded with the core purpose in the first sentence, followed by clear sections for arguments and returns. Every sentence earns its place by providing essential information without redundancy. It's appropriately sized for a simple tool with one parameter.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (one parameter, no output schema, no annotations), the description is minimally complete: it states the purpose, explains the parameter, and hints at the return format. However, it lacks details on behavioral aspects like permissions or error handling, which are important for Kubernetes operations. Without annotations or output schema, more context would improve completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description includes an 'Args' section that explains the single parameter 'context_name' as 'The Kubernetes context name', adding meaning beyond the schema which has 0% description coverage and only provides a title. This fully compensates for the schema gap, making the parameter clear. However, it doesn't elaborate on format or examples, keeping it from a perfect score.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('List') and resource ('all namespaces in the Kubernetes cluster'), making it immediately understandable. It distinguishes from siblings like 'get_namespace_details' by indicating it lists all namespaces rather than retrieving details for a specific one. However, it doesn't explicitly contrast with 'list_namespace_resources' or 'create_namespace', which would push it to a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage by specifying it lists all namespaces, suggesting it's for general overview rather than detailed inspection. However, it lacks explicit guidance on when to use this tool versus alternatives like 'get_namespace_details' for specific namespace info or 'list_namespace_resources' for resources within namespaces. No exclusions or prerequisites are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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