Skip to main content
Glama

remove_annotation

Remove annotations from Kubernetes resources like pods, services, or deployments to clean up metadata or modify configurations.

Instructions

Remove an annotation from a Kubernetes resource

Args: resource_type: Type of the resource (e.g., pod, service, deployment) resource_name: Name of the resource to remove the annotation from annotation_key: Key of the annotation to remove namespace: Namespace of the resource

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
resource_typeYes
resource_nameYes
annotation_keyYes
namespaceNodefault

Implementation Reference

  • The core handler function for the 'remove_annotation' tool. It is decorated with @mcp.tool(), which registers it with the MCP server. The function executes kubectl annotate command with the annotation key suffixed by '-' to remove the annotation from the specified Kubernetes resource.
    @mcp.tool() async def remove_annotation(resource_type: str, resource_name: str, annotation_key: str, namespace: str = "default") -> dict: """Remove an annotation from a Kubernetes resource Args: resource_type: Type of the resource (e.g., pod, service, deployment) resource_name: Name of the resource to remove the annotation from annotation_key: Key of the annotation to remove namespace: Namespace of the resource """ try: cmd = ["kubectl", "annotate", resource_type, resource_name, f"{annotation_key}-", "-n", namespace, "--overwrite"] result = subprocess.run(cmd, capture_output=True, text=True, check=True) return {"message": f"Annotation {annotation_key} removed from resource {resource_type}/{resource_name} in namespace {namespace}", "details": result.stdout} except subprocess.CalledProcessError as e: return {"error": f"Failed to remove annotation: {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