Skip to main content
Glama

delete_resource

Remove specific Kubernetes resources by specifying type, name, and namespace. Simplify resource management tasks for streamlined cluster operations.

Instructions

Delete a Kubernetes resource

Args: resource_type: Type of the resource (e.g., pod, service, deployment,configmap,secret,ingress,statefulset,replicaset,damonset,newtorkpolicy,rolebinding,role,serviceaccount,job,cronjob) resource_name: Name of the resource to delete namespace: Namespace of the resource

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
namespaceNodefault
resource_nameYes
resource_typeYes

Implementation Reference

  • The handler function for the 'delete_resource' MCP tool. It uses kubectl to delete the specified resource type and name in the given namespace. The @mcp.tool() decorator registers it with the FastMCP server.
    @mcp.tool() async def delete_resource(resource_type: str, resource_name: str, namespace: str = "default") -> dict: """Delete a Kubernetes resource Args: resource_type: Type of the resource (e.g., pod, service, deployment,configmap,secret,ingress,statefulset,replicaset,damonset,newtorkpolicy,rolebinding,role,serviceaccount,job,cronjob) resource_name: Name of the resource to delete namespace: Namespace of the resource """ try: cmd = ["kubectl", "delete", resource_type, resource_name, "-n", namespace] result = subprocess.run(cmd, capture_output=True, text=True, check=True) return {"message": f"Resource {resource_type}/{resource_name} deleted successfully in namespace {namespace}", "details": result.stdout} except subprocess.CalledProcessError as e: return {"error": f"Failed to delete resource: {str(e)}"}

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/abhijeetka/mcp-k8s-server'

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