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()

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