Skip to main content
Glama

list_gke_clusters

List all Google Kubernetes Engine (GKE) clusters within a specified GCP project, optionally filtered by region. Simplify cluster management and visibility for better resource tracking in GCP environments.

Instructions

    List Google Kubernetes Engine (GKE) clusters in a GCP project.
    
    Args:
        project_id: The ID of the GCP project to list GKE clusters for
        region: Optional region to filter clusters (e.g., "us-central1")
    
    Returns:
        List of GKE clusters in the specified GCP project
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes
regionNo

Implementation Reference

  • The handler function for the 'list_gke_clusters' tool. It uses the Google Cloud Container API to list GKE clusters in the specified project, optionally filtered by region. Handles both regional and zonal clusters, formatting output with details like version, node count, and status.
        @mcp.tool()
        def list_gke_clusters(project_id: str, region: str = "") -> str:
            """
            List Google Kubernetes Engine (GKE) clusters in a GCP project.
            
            Args:
                project_id: The ID of the GCP project to list GKE clusters for
                region: Optional region to filter clusters (e.g., "us-central1")
            
            Returns:
                List of GKE clusters in the specified GCP project
            """
            try:
                from google.cloud import container_v1
                
                # Initialize the GKE client
                client = container_v1.ClusterManagerClient()
                
                clusters_list = []
                
                if region:
                    # List clusters in the specified region
                    parent = f"projects/{project_id}/locations/{region}"
                    response = client.list_clusters(parent=parent)
                    
                    for cluster in response.clusters:
                        version = cluster.current_master_version
                        node_count = sum(pool.initial_node_count for pool in cluster.node_pools)
                        status = "Running" if cluster.status == container_v1.Cluster.Status.RUNNING else cluster.status.name
                        clusters_list.append(f"- {cluster.name} (Region: {region}, Version: {version}, Nodes: {node_count}, Status: {status})")
                else:
                    # List clusters in all regions
                    from google.cloud import compute_v1
                    
                    # Get all regions
                    regions_client = compute_v1.RegionsClient()
                    regions_request = compute_v1.ListRegionsRequest(project=project_id)
                    regions = regions_client.list(request=regions_request)
                    
                    for region_item in regions:
                        region_name = region_item.name
                        parent = f"projects/{project_id}/locations/{region_name}"
                        try:
                            response = client.list_clusters(parent=parent)
                            
                            for cluster in response.clusters:
                                version = cluster.current_master_version
                                node_count = sum(pool.initial_node_count for pool in cluster.node_pools)
                                status = "Running" if cluster.status == container_v1.Cluster.Status.RUNNING else cluster.status.name
                                clusters_list.append(f"- {cluster.name} (Region: {region_name}, Version: {version}, Nodes: {node_count}, Status: {status})")
                        except Exception:
                            # Skip regions where we can't list clusters
                            continue
                        
                    # Also check zonal clusters
                    zones_client = compute_v1.ZonesClient()
                    zones_request = compute_v1.ListZonesRequest(project=project_id)
                    zones = zones_client.list(request=zones_request)
                    
                    for zone_item in zones:
                        zone_name = zone_item.name
                        parent = f"projects/{project_id}/locations/{zone_name}"
                        try:
                            response = client.list_clusters(parent=parent)
                            
                            for cluster in response.clusters:
                                version = cluster.current_master_version
                                node_count = sum(pool.initial_node_count for pool in cluster.node_pools)
                                status = "Running" if cluster.status == container_v1.Cluster.Status.RUNNING else cluster.status.name
                                clusters_list.append(f"- {cluster.name} (Zone: {zone_name}, Version: {version}, Nodes: {node_count}, Status: {status})")
                        except Exception:
                            # Skip zones where we can't list clusters
                            continue
                
                if not clusters_list:
                    region_msg = f" in region {region}" if region else ""
                    return f"No GKE clusters found{region_msg} for project {project_id}."
                
                clusters_str = "\n".join(clusters_list)
                region_msg = f" in region {region}" if region else ""
                
                return f"""
    Google Kubernetes Engine (GKE) Clusters{region_msg} in GCP Project {project_id}:
    {clusters_str}
    """
            except Exception as e:
                return f"Error listing GKE clusters: {str(e)}"
  • Registration of the Kubernetes tools module in the main MCP server, which includes the 'list_gke_clusters' tool via the call to kubernetes_tools.register_tools(mcp). This is invoked during server initialization.
    kubernetes_tools.register_tools(mcp)
  • The register_tools function in the Kubernetes module that defines and registers the 'list_gke_clusters' tool using the @mcp.tool() decorator.
    def register_tools(mcp):
        """Register all kubernetes tools with the MCP server."""
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. It states the action ('List') and return type ('List of GKE clusters'), but lacks critical details: permissions required, pagination behavior, rate limits, error conditions, or whether it's a read-only operation. For a cloud resource listing tool with zero annotation coverage, this leaves significant gaps in understanding how the tool behaves.

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

Conciseness5/5

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

The description is well-structured and appropriately sized. It front-loads the core purpose in the first sentence, followed by organized Args and Returns sections. Every sentence earns its place: the purpose statement is essential, parameter descriptions are necessary given 0% schema coverage, and the return statement clarifies output. No wasted words or redundancy.

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?

Given 2 parameters with 0% schema coverage and no output schema, the description does a decent job covering basics: purpose and parameter semantics. However, as a cloud resource tool with no annotations, it lacks behavioral context (e.g., auth needs, side effects) and output details (structure of returned clusters). For a simple list operation, this is minimally adequate but leaves the agent to assume safe defaults.

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?

Schema description coverage is 0%, so the schema provides no parameter documentation. The description compensates by documenting both parameters in the Args section: 'project_id: The ID of the GCP project to list GKE clusters for' and 'region: Optional region to filter clusters (e.g., "us-central1")'. This adds clear meaning beyond the bare schema, explaining purpose and providing an example for region. However, it doesn't cover format constraints or validation rules.

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 tool's purpose: 'List Google Kubernetes Engine (GKE) clusters in a GCP project.' This includes a specific verb ('List'), resource ('GKE clusters'), and scope ('in a GCP project'). It distinguishes from siblings like 'list_compute_instances' or 'list_storage_buckets' by specifying the resource type, though it doesn't explicitly differentiate from similar list tools beyond the resource name.

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., authentication), compare to siblings like 'get_cluster_details' for detailed info, or specify scenarios where filtering by region is beneficial. The agent must infer usage from the tool name and parameters alone.

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

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/henihaddad/gcp-mcp'

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