Skip to main content
Glama

annotate_resource

Add custom annotations to Kubernetes resources such as pods, services, or deployments, specifying a key-value pair and resource namespace for improved metadata management.

Instructions

Annotate a Kubernetes resource with the specified annotation

Args: resource_type: Type of the resource (e.g., pod, service, deployment) resource_name: Name of the resource to annotate annotation: Annotation to add (e.g., key=value) namespace: Namespace of the resource

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
annotationYes
namespaceNodefault
resource_nameYes
resource_typeYes

Implementation Reference

  • The main handler function for the 'annotate_resource' MCP tool. It uses kubectl annotate command to add an annotation to a specified Kubernetes resource. Registered via @mcp.tool() decorator, which also serves as the registration point.
    @mcp.tool() async def annotate_resource(resource_type: str, resource_name: str, annotation: str, namespace: str = "default") -> dict: """Annotate a Kubernetes resource with the specified annotation Args: resource_type: Type of the resource (e.g., pod, service, deployment) resource_name: Name of the resource to annotate annotation: Annotation to add (e.g., key=value) namespace: Namespace of the resource """ try: cmd = ["kubectl", "annotate", resource_type, resource_name, annotation, "-n", namespace, "--overwrite"] result = subprocess.run(cmd, capture_output=True, text=True, check=True) return {"message": f"Resource {resource_type}/{resource_name} annotated successfully in namespace {namespace}", "details": result.stdout} except subprocess.CalledProcessError as e: return {"error": f"Failed to annotate 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