Skip to main content
Glama

delete_namespace

Remove a Kubernetes namespace and all its resources using the k8s-pilot server. Specify context and namespace to clean up cluster resources.

Instructions

Delete a namespace and all resources within it.

Args: context_name: The Kubernetes context name namespace: The name of the namespace to delete

Returns: JSON string containing the result of the operation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
context_nameYes
namespaceYes

Implementation Reference

  • Handler function implementing the delete_namespace MCP tool. Deletes the specified Kubernetes namespace using CoreV1Api after existence check. Includes decorators for tool registration (@mcp.tool()), context usage, and permission checks.
    @mcp.tool()
    @use_current_context
    @check_readonly_permission
    def delete_namespace(context_name: str, namespace: str):
        """
        Delete a namespace and all resources within it.
    
        Args:
            context_name: The Kubernetes context name
            namespace: The name of the namespace to delete
    
        Returns:
            JSON string containing the result of the operation
        """
        core_v1: CoreV1Api = get_api_clients(context_name)["core"]
    
        try:
            # Check if namespace exists
            try:
                core_v1.read_namespace(namespace)
            except ApiException as e:
                if e.status == 404:
                    return json.dumps({"error": f"Namespace '{namespace}' not found"})
                else:
                    return json.dumps({"error": f"API error: {str(e)}"})
    
            # Delete the namespace
            core_v1.delete_namespace(namespace)
    
            result = {
                "name": namespace,
                "status": "Deleting",
                "message": f"Namespace '{namespace}' is being deleted"
            }
    
            return json.dumps(result)
        except ApiException as e:
            return json.dumps({"error": f"Failed to delete namespace: {str(e)}"})
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 discloses the destructive nature ('Delete a namespace and all resources within it'), which is critical, but lacks details on permissions required, irreversibility, potential side effects, or error conditions. For a high-risk mutation tool, this is insufficient.

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

Conciseness4/5

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

The description is well-structured with a clear purpose statement followed by Args and Returns sections. It's front-loaded with the core action. The only minor inefficiency is the vague 'JSON string' return statement, which could be more specific.

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

Completeness2/5

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

Given the tool's high complexity (destructive operation), lack of annotations, and no output schema, the description is incomplete. It misses critical context like safety warnings, authentication needs, error handling, and what the JSON result contains. This leaves significant gaps for safe agent usage.

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?

Schema description coverage is 0%, so the description must compensate. It explicitly lists and describes both parameters ('context_name' and 'namespace') in the Args section, adding meaning beyond the bare schema. However, it doesn't specify format details (e.g., namespace naming conventions).

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

Purpose5/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 ('Delete') and resource ('namespace and all resources within it'), distinguishing it from sibling tools like 'create_namespace' or 'list_namespaces'. It precisely communicates the destructive scope of the operation.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives. While the description implies it's for deletion, it doesn't mention prerequisites (e.g., ensuring the namespace exists), exclusions (e.g., system namespaces), or related tools like 'get_namespace_details' for verification.

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