Skip to main content
Glama

delete_resource

Remove a Kubernetes resource from a cluster by specifying its type, name, and namespace to manage cluster resources effectively.

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
resource_typeYes
resource_nameYes
namespaceNodefault

Implementation Reference

  • The handler function for the 'delete_resource' tool. It executes 'kubectl delete' command to remove the specified Kubernetes resource. Registered via the @mcp.tool() decorator immediately above the function definition.
    @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)}"}
  • kubernetes.py:353-353 (registration)
    The @mcp.tool() decorator registers the delete_resource function as an MCP tool.
    @mcp.tool()

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