Skip to main content
Glama

delete_namespace

Remove a Kubernetes namespace and all its resources using the specified context. Simplifies cleanup and cluster management.

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

  • The handler function implementing the 'delete_namespace' tool logic. It uses the Kubernetes API to delete the specified namespace after verifying its existence. Registered via @mcp.tool() decorator.
    @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)}"})

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