Skip to main content
Glama

get_clusters

Retrieve all clusters from the kubeconfig file using this tool, enabling efficient management of Kubernetes clusters through the k8s-pilot MCP server.

Instructions

Get all clusters from the kubeconfig file. :return:

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'get_clusters' tool, decorated with @mcp.tool(). It reads the kubeconfig using get_kubeconfig(), determines the current context, and returns a list of ContextInfo objects for all clusters.
    @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 ContextInfo defining the structure for cluster context information (name, cluster, user, current), used in the output of get_clusters.
    @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()

Other Tools

Related 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