Skip to main content
Glama
abhijeetka
by abhijeetka

annotate_resource

Add annotations to Kubernetes resources like pods, services, or deployments to add metadata for tracking, configuration, or automation purposes.

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

Implementation Reference

  • The handler function for the 'annotate_resource' tool. It uses kubectl to annotate a specified Kubernetes resource with the given annotation key-value pair in the specified namespace.
    @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)}"}
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It states the tool 'annotates' a resource, implying a mutation, but lacks details on permissions required, whether it's idempotent, error handling (e.g., if resource doesn't exist), or side effects. This is a significant gap for a mutation tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the core purpose in the first sentence, followed by a structured Args section. Each sentence earns its place by clarifying parameters, but it could be more concise by integrating examples directly or omitting redundant formatting like quotes around the description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a Kubernetes mutation tool with 4 parameters, no annotations, and no output schema, the description is incomplete. It lacks behavioral context (e.g., safety, errors), output details, and comprehensive usage guidelines. This is inadequate for a tool that modifies cluster state.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It lists all 4 parameters with brief examples (e.g., 'pod, service, deployment' for resource_type, 'key=value' for annotation), adding meaning beyond the schema's bare titles. However, it doesn't explain parameter interactions or constraints (e.g., namespace defaulting to 'default'), leaving some gaps.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('annotate') and target ('Kubernetes resource'), making the purpose evident. It specifies adding an annotation with key=value format, which distinguishes it from sibling tools like 'label_resource' or 'remove_annotation'. However, it doesn't explicitly differentiate from all siblings, such as 'update_deployment', which might also modify resources.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing proper Kubernetes context or permissions), contrast with 'label_resource' for labeling instead of annotating, or specify scenarios like debugging or metadata addition. Usage is implied but not articulated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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