Skip to main content
Glama

get_cluster_details

Retrieve detailed information about a specific GKE cluster by providing the GCP project ID, cluster name, and location. Enhances cluster management within the GCP MCP server.

Instructions

Get detailed information about a specific GKE cluster. Args: project_id: The ID of the GCP project cluster_name: The name of the GKE cluster location: The location (region or zone) of the cluster Returns: Detailed information about the specified GKE cluster

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cluster_nameYes
locationYes
project_idYes

Implementation Reference

  • The handler function decorated with @mcp.tool() that implements the get_cluster_details tool. It fetches detailed GKE cluster information using the container_v1 client and returns a formatted string.
    @mcp.tool() def get_cluster_details(project_id: str, cluster_name: str, location: str) -> str: """ Get detailed information about a specific GKE cluster. Args: project_id: The ID of the GCP project cluster_name: The name of the GKE cluster location: The location (region or zone) of the cluster Returns: Detailed information about the specified GKE cluster """ try: from google.cloud import container_v1 # Initialize the GKE client client = container_v1.ClusterManagerClient() # Get cluster details cluster_path = f"projects/{project_id}/locations/{location}/clusters/{cluster_name}" cluster = client.get_cluster(name=cluster_path) # Format the response details = [] details.append(f"Name: {cluster.name}") details.append(f"Description: {cluster.description or 'None'}") details.append(f"Location: {location}") details.append(f"Location Type: {'Regional' if '-' not in location else 'Zonal'}") details.append(f"Status: {'Running' if cluster.status == container_v1.Cluster.Status.RUNNING else cluster.status.name}") details.append(f"Kubernetes Version: {cluster.current_master_version}") details.append(f"Network: {cluster.network}") details.append(f"Subnetwork: {cluster.subnetwork}") details.append(f"Cluster CIDR: {cluster.cluster_ipv4_cidr}") details.append(f"Services CIDR: {cluster.services_ipv4_cidr}") details.append(f"Endpoint: {cluster.endpoint}") # Add Node Pools information node_pools = [] for pool in cluster.node_pools: machine_type = pool.config.machine_type disk_size_gb = pool.config.disk_size_gb autoscaling = "Enabled" if pool.autoscaling and pool.autoscaling.enabled else "Disabled" min_nodes = pool.autoscaling.min_node_count if pool.autoscaling and pool.autoscaling.enabled else "N/A" max_nodes = pool.autoscaling.max_node_count if pool.autoscaling and pool.autoscaling.enabled else "N/A" initial_nodes = pool.initial_node_count node_pools.append(f" - {pool.name} (Machine: {machine_type}, Disk: {disk_size_gb}GB, Initial Nodes: {initial_nodes})") if autoscaling == "Enabled": node_pools.append(f" Autoscaling: {autoscaling} (Min: {min_nodes}, Max: {max_nodes})") if node_pools: details.append(f"Node Pools ({len(cluster.node_pools)}):\n" + "\n".join(node_pools)) # Add Addons information addons = [] if cluster.addons_config: config = cluster.addons_config addons.append(f" - HTTP Load Balancing: {'Enabled' if not config.http_load_balancing or not config.http_load_balancing.disabled else 'Disabled'}") addons.append(f" - Horizontal Pod Autoscaling: {'Enabled' if not config.horizontal_pod_autoscaling or not config.horizontal_pod_autoscaling.disabled else 'Disabled'}") addons.append(f" - Kubernetes Dashboard: {'Enabled' if not config.kubernetes_dashboard or not config.kubernetes_dashboard.disabled else 'Disabled'}") addons.append(f" - Network Policy: {'Enabled' if config.network_policy_config and not config.network_policy_config.disabled else 'Disabled'}") if addons: details.append(f"Addons:\n" + "\n".join(addons)) details_str = "\n".join(details) return f""" GKE Cluster Details: {details_str} """ except Exception as e: return f"Error getting cluster details: {str(e)}"
  • The call to register_tools from the kubernetes module, which registers the get_cluster_details tool via its @mcp.tool() decorator.
    kubernetes_tools.register_tools(mcp)
  • Import of the kubernetes tools module, providing access to register_tools which registers the get_cluster_details tool.
    from .gcp_modules.kubernetes import tools as kubernetes_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/henihaddad/gcp-mcp'

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