Skip to main content
Glama

set_current_cluster

Switch the active Kubernetes cluster in your kubeconfig file to manage resources across different environments using the k8s-pilot server.

Instructions

Set the current cluster in the kubeconfig file. :param cluster_name: :return:

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cluster_nameYes

Implementation Reference

  • The handler function that implements the set_current_cluster tool logic. It loads the kubeconfig, finds the matching context, updates the current-context, writes back to ~/.kube/config, and returns success or error status.
    def set_current_cluster(cluster_name: str):
        """
        Set the current cluster in the kubeconfig file.
        :param cluster_name:
        :return:
        """
        config_data = get_kubeconfig()
        contexts = config_data.get("contexts", [])
    
        for ctx in contexts:
            if ctx["name"] == cluster_name:
                config_data["current-context"] = cluster_name
                with open(os.path.expanduser("~/.kube/config"), "w") as f:
                    yaml.dump(config_data, f)
                return {"status": "success", "message": f"Current context set to {cluster_name}"}
    
        return {"status": "error", "message": f"Context {cluster_name} not found"}
  • tools/cluster.py:51-51 (registration)
    Registers the set_current_cluster tool using the @mcp.tool() decorator from the MCP server instance.
    @mcp.tool()
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. It states 'Set' implies a write/mutation operation, but doesn't describe effects (e.g., whether this changes active context, requires permissions, or has side effects), safety considerations, or response behavior. For a mutation tool with zero annotation coverage, this is inadequate.

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 with three lines, but it's not well-structured or front-loaded. The first sentence is clear, but the param and return lines are incomplete and don't add value efficiently. It avoids verbosity but could be more polished and informative.

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 tool's complexity (a write operation affecting kubeconfig), lack of annotations, no output schema, and low schema coverage, the description is incomplete. It doesn't cover behavioral aspects, parameter details, or expected outcomes, leaving significant gaps for an AI agent to understand and use the tool correctly.

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

Parameters2/5

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

The schema description coverage is 0%, so the description must compensate for undocumented parameters. It only lists ':param cluster_name:' and ':return:' without explaining what 'cluster_name' represents (e.g., format, valid values, or source) or what the return value indicates. This adds minimal meaning beyond the bare schema.

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 verb ('Set') and resource ('current cluster in the kubeconfig file'), making the purpose specific and understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_current_cluster', which is a related read operation, so it doesn't reach the highest score of 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 prerequisites (e.g., needing an existing cluster or kubeconfig), compare to siblings like 'get_clusters' or 'get_current_cluster', or specify when this operation is appropriate. This leaves the agent without contextual usage information.

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