Skip to main content
Glama

get_clusters

Retrieve all Kubernetes clusters from your kubeconfig file to manage multiple cluster configurations and switch contexts efficiently.

Instructions

Get all clusters from the kubeconfig file. :return:

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The primary handler function for the 'get_clusters' tool. It is decorated with @mcp.tool() which also serves as its registration in the MCP system. Parses kubeconfig to return list of available clusters as ContextInfo objects.
    @mcp.tool()
    def get_clusters():
        """
        Get all clusters from the kubeconfig file.
        :return:
        """
        config_data = get_kubeconfig()
        current_context = config_data.get("current-context")
        contexts = config_data.get("contexts", [])
    
        return [
            ContextInfo(
                name=ctx["name"],
                cluster=ctx["context"].get("cluster"),
                user=ctx["context"].get("user"),
                current=ctx["name"] == current_context,
            )
            for ctx in contexts]
  • Dataclass schema/model defining the structure of cluster context information returned by the get_clusters tool.
    @dataclass
    class ContextInfo:
        """
        Represents a Kubernetes context.
        """
        name: str
        cluster: str
        user: str
        current: bool
  • tools/cluster.py:10-10 (registration)
    The @mcp.tool() decorator registers the get_clusters function as an MCP tool.
    @mcp.tool()
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. While 'Get' implies a read operation, the description doesn't specify whether this requires authentication, what format the clusters are returned in, whether there are rate limits, or what happens if the kubeconfig file is missing or malformed. The ':return:' placeholder adds no value.

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

Conciseness3/5

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

The description is brief but contains a useless ':return:' placeholder that adds no information. The first sentence is clear, but the second fragment wastes space. It's appropriately sized for a simple tool but could be better structured without the placeholder.

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 simple read operation with no parameters and no output schema, the description is minimally adequate but leaves important questions unanswered. Without annotations or output schema, the description should ideally specify what format the clusters are returned in (list of names? full configurations?) and any authentication requirements, but it doesn't.

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?

The tool has 0 parameters with 100% schema description coverage, so the baseline is 4. The description correctly indicates this is a parameterless operation that retrieves all clusters, which aligns perfectly with the empty input schema.

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

Purpose3/5

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

The description states 'Get all clusters from the kubeconfig file' which provides a clear verb ('Get') and resource ('clusters'), but it's somewhat vague about what 'clusters' means in this Kubernetes context. It doesn't distinguish itself from sibling tools like 'get_current_cluster' or 'set_current_cluster' which suggests there might be multiple cluster-related operations.

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. There's no mention of when this tool is appropriate versus 'get_current_cluster' or other cluster-related operations in the sibling list. No context about prerequisites, timing, or exclusions is provided.

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