Skip to main content
Glama
abhijeetka
by abhijeetka

label_resource

Add labels to Kubernetes resources like pods, services, or deployments to organize and identify them within your cluster.

Instructions

Label a Kubernetes resource with the specified label

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
resource_typeYes
resource_nameYes
labelYes
namespaceNodefault

Implementation Reference

  • The main handler function for the 'label_resource' tool, decorated with @mcp.tool() for registration. It uses kubectl label to add a label to a Kubernetes resource.
    async def label_resource(resource_type: str, resource_name: str, label: str, namespace: str = "default") -> dict:
        """Label a Kubernetes resource with the specified label
    
        Args:
            resource_type: Type of the resource (e.g., pod, service, deployment)
            resource_name: Name of the resource to label
            label: Label to add (e.g., key=value)
            namespace: Namespace of the resource
        """
        try:
            cmd = ["kubectl", "label", resource_type, resource_name, label, "-n", namespace, "--overwrite"]
            result = subprocess.run(cmd, capture_output=True, text=True, check=True)
            return {"message": f"Resource {resource_type}/{resource_name} labeled successfully in namespace {namespace}",
                    "details": result.stdout}
        except subprocess.CalledProcessError as e:
            return {"error": f"Failed to label 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 the full burden of behavioral disclosure. While 'label' implies a mutation, the description doesn't specify whether this overwrites existing labels, requires specific permissions, or has side effects like triggering redeployments. It lacks details on error conditions or response format.

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

Conciseness5/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. Every sentence adds value without redundancy, making it efficient and easy to parse.

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

Completeness3/5

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

For a mutation tool with no annotations and no output schema, the description is moderately complete. It covers the basic operation and parameters but lacks details on behavioral traits like idempotency, error handling, or return values. Given the complexity of Kubernetes operations, more context would be beneficial.

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

Parameters4/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 provides clear semantics for all parameters with examples (e.g., 'key=value' for label, 'pod, service, deployment' for resource_type), adding meaningful context beyond the bare schema. However, it doesn't explain the default namespace behavior mentioned in the schema.

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

Purpose5/5

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

The description clearly states the verb 'label' and the resource 'Kubernetes resource', making the purpose specific and actionable. It distinguishes from sibling tools like 'remove_label' (which removes labels) and 'annotate_resource' (which adds annotations rather than labels).

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

Usage Guidelines3/5

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

The description implies usage by specifying it's for labeling Kubernetes resources, but it doesn't explicitly state when to use this tool versus alternatives like 'annotate_resource' or 'remove_label'. No guidance is provided on prerequisites, such as requiring the resource to exist or having appropriate permissions.

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