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

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

B3.4/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, and the description does not disclose behavior beyond confirming it returns information. It lacks any mention of read-only nature, required permissions, side effects, or how the response is structured. The 'Returns' line simply restates the purpose.

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

Conciseness4/5

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

The description is appropriately sized, front-loaded with the main purpose, and uses a clear Args/Returns structure. The Returns line is somewhat redundant ('Detailed information' again), but it does not waste much space.

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, the description gives the essential inputs and a generic outcome. However, with no output schema, it does not specify what fields the returned 'detailed information' contains. It also does not mention prerequisites or how this tool relates to list_gke_clusters. It is adequate but not rich.

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

Parameters3/5

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

The Args section adds some meaning over the schema by describing each parameter. 'location' is clarified as 'region or zone', which is valuable. However, 'project_id' and 'cluster_name' descriptions are trivial (just restating the parameter names). Since schema coverage is 0%, the description partially compensates but is not thorough.

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

Purpose5/5

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

The description opens with a specific verb and resource: 'Get detailed information about a specific GKE cluster.' This clearly distinguishes it from sibling tools like list_gke_clusters (listing clusters) and get_sql_instance_details (a different resource).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage when you need details for a specific cluster but does not explicitly state when to use this tool versus alternatives like list_gke_clusters. No exclusions or alternative recommendations are provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.