Skip to main content
Glama

get_namespace_resource_quota

Retrieve current resource quotas and usage for a Kubernetes namespace to monitor and manage cluster resource allocation.

Instructions

Get current resource quotas for a namespace.

Args: context_name: The Kubernetes context name namespace: The name of the namespace

Returns: JSON string containing the current resource quotas and their usage

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
context_nameYes
namespaceYes

Implementation Reference

  • The handler function that implements the get_namespace_resource_quota tool. It lists resource quotas in the specified namespace using Kubernetes CoreV1Api, handles errors, and returns formatted JSON.
    @mcp.tool()
    @use_current_context
    def get_namespace_resource_quota(context_name: str, namespace: str):
        """
        Get current resource quotas for a namespace.
    
        Args:
            context_name: The Kubernetes context name
            namespace: The name of the namespace
    
        Returns:
            JSON string containing the current resource quotas and their usage
        """
        core_v1: CoreV1Api = get_api_clients(context_name)["core"]
    
        try:
            # Check if namespace exists
            try:
                core_v1.read_namespace(namespace)
            except ApiException as e:
                if e.status == 404:
                    return json.dumps({"error": f"Namespace '{namespace}' not found"})
                else:
                    return json.dumps({"error": f"API error: {str(e)}"})
    
            # Get all resource quotas in the namespace
            quotas = core_v1.list_namespaced_resource_quota(namespace)
    
            if not quotas.items:
                return json.dumps({
                    "namespace": namespace,
                    "message": "No resource quotas defined for this namespace"
                })
    
            quota_info = []
            for quota in quotas.items:
                quota_data = {
                    "name": quota.metadata.name,
                    "hard": quota.spec.hard,
                    "used": quota.status.used if hasattr(quota.status, 'used') else {}
                }
                quota_info.append(quota_data)
    
            result = {
                "namespace": namespace,
                "quotas": quota_info
            }
    
            return json.dumps(result)
        except ApiException as e:
            return json.dumps({"error": f"Failed to get resource quotas: {str(e)}"})
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool 'Get[s] current resource quotas' and returns 'JSON string containing the current resource quotas and their usage', which implies a read-only operation. However, it doesn't address critical behavioral aspects like authentication requirements, error conditions, rate limits, or whether it's safe to call repeatedly. For a tool with zero annotation coverage, this is insufficient.

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 well-structured and front-loaded: the first sentence states the purpose clearly, followed by organized sections for arguments and returns. Every sentence earns its place with no wasted words, making it easy to scan and understand quickly.

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?

Given the tool's moderate complexity (2 required parameters, no output schema, no annotations), the description is minimally adequate. It covers the purpose, parameters, and return format, but lacks deeper context like error handling, authentication needs, or differentiation from siblings. Without annotations or output schema, more behavioral detail would improve completeness.

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?

The description includes an 'Args' section that lists the two parameters ('context_name' and 'namespace') and a 'Returns' section explaining the output. With schema description coverage at 0%, this adds meaningful context beyond the bare schema. However, it doesn't provide details like parameter formats, examples, or constraints (e.g., what a valid namespace name looks like), keeping it at a baseline level.

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 tool's purpose: 'Get current resource quotas for a namespace.' It specifies the verb ('Get') and resource ('resource quotas for a namespace'), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from sibling tools like 'get_namespace_details' or 'set_namespace_resource_quota', which would require a 5.

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 sibling tools like 'get_namespace_details' (which might provide broader namespace info) or 'set_namespace_resource_quota' (for setting quotas), nor does it specify prerequisites or exclusions. This leaves the agent without contextual usage direction.

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/bourbonkk/k8s-pilot'

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