Skip to main content
Glama

list_disks

Retrieve and list Compute Engine persistent disks within a specified GCP project. Optionally filter results by zone for targeted disk management and monitoring.

Instructions

    List Compute Engine persistent disks in a GCP project.
    
    Args:
        project_id: The ID of the GCP project to list disks for
        zone: Optional zone to filter disks (e.g., "us-central1-a")
    
    Returns:
        List of persistent disks in the specified GCP project
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes
zoneNo

Implementation Reference

  • Registers the list_disks tool using the @mcp.tool() decorator, which also derives the schema from the function signature and docstring.
    @mcp.tool()
  • The handler function that implements the list_disks tool. It lists persistent disks in a GCP project, optionally filtered by zone, using the Google Cloud Compute API. Formats and returns a string list of disks with details like name, type, size, status, and attachment info.
        def list_disks(project_id: str, zone: str = "") -> str:
            """
            List Compute Engine persistent disks in a GCP project.
            
            Args:
                project_id: The ID of the GCP project to list disks for
                zone: Optional zone to filter disks (e.g., "us-central1-a")
            
            Returns:
                List of persistent disks in the specified GCP project
            """
            try:
                from google.cloud import compute_v1
                
                # Initialize the Disks client
                client = compute_v1.DisksClient()
                
                disks_list = []
                
                if zone:
                    # List disks in the specified zone
                    request = compute_v1.ListDisksRequest(
                        project=project_id,
                        zone=zone
                    )
                    disks = client.list(request=request)
                    
                    for disk in disks:
                        size_gb = disk.size_gb
                        disk_type = disk.type.split('/')[-1] if disk.type else "Unknown"
                        status = disk.status
                        users = len(disk.users) if disk.users else 0
                        users_str = f"Attached to {users} instance(s)" if users > 0 else "Not attached"
                        
                        disks_list.append(f"- {disk.name} (Zone: {zone}, Type: {disk_type}, Size: {size_gb} GB, Status: {status}, {users_str})")
                else:
                    # List disks in all zones
                    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
                        request = compute_v1.ListDisksRequest(
                            project=project_id,
                            zone=zone_name
                        )
                        try:
                            disks = client.list(request=request)
                            
                            for disk in disks:
                                size_gb = disk.size_gb
                                disk_type = disk.type.split('/')[-1] if disk.type else "Unknown"
                                status = disk.status
                                users = len(disk.users) if disk.users else 0
                                users_str = f"Attached to {users} instance(s)" if users > 0 else "Not attached"
                                
                                disks_list.append(f"- {disk.name} (Zone: {zone_name}, Type: {disk_type}, Size: {size_gb} GB, Status: {status}, {users_str})")
                        except Exception:
                            # Skip zones where we can't list disks
                            continue
                
                if not disks_list:
                    zone_msg = f" in zone {zone}" if zone else ""
                    return f"No persistent disks found{zone_msg} for project {project_id}."
                
                disks_str = "\n".join(disks_list)
                zone_msg = f" in zone {zone}" if zone else ""
                
                return f"""
    Persistent Disks{zone_msg} in GCP Project {project_id}:
    {disks_str}
    """
            except Exception as e:
                return f"Error listing persistent disks: {str(e)}"

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A4.3/5.0
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It discloses the core behavior (listing disks, optional zone filter) and the return type, but does not explicitly state read-only semantics, pagination behavior, or permission requirements, leaving some gaps.

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 compact and front-loaded, with a clear one-line summary, an Args section, and a Returns section. Every sentence earns its place without unnecessary verbosity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool is simple with only two parameters and no output schema. The description adequately covers the purpose, parameters, and return value. It could mention edge cases like empty results or required permissions, but the core information is present.

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

Parameters5/5

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

The schema has no descriptions for parameters (0% coverage), but the description compensates by explaining both `project_id` and `zone`, including an example for `zone`. This adds meaningful guidance beyond the schema.

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 clearly states the tool lists Compute Engine persistent disks in a GCP project, using a specific verb and resource. It is distinct from sibling tools like list_compute_instances and list_storage_buckets.

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

Usage Guidelines4/5

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

The description provides clear context for when to use the tool (listing disks in a project, optionally filtered by zone). It does not explicitly mention alternatives or when not to use it, but the context is sufficient for most cases.

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