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)}"
Behavior2/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 of behavioral disclosure. It states the tool lists disks and returns a list, but lacks critical details: it doesn't mention pagination, rate limits, authentication requirements, error handling, or whether the operation is read-only (though implied by 'List'). For a tool with no annotations, this leaves significant behavioral gaps.

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 well-structured and appropriately sized: it starts with a clear purpose statement, followed by parameter and return value sections. Each sentence adds value without redundancy. Minor improvements could include briefer formatting or more front-loaded key information, but it's efficient overall.

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 the tool's low complexity (2 parameters, no nested objects) but lack of annotations and output schema, the description is minimally adequate. It covers the basic purpose and parameters but misses behavioral details like pagination or error handling. Without an output schema, it should ideally describe the return format more thoroughly, but the current level is acceptable for a simple list operation.

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

Parameters4/5

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

The description adds meaningful semantics beyond the input schema, which has 0% description coverage. It explains that 'project_id' is for listing disks in a GCP project and 'zone' is an optional filter (e.g., 'us-central1-a'), clarifying their roles and providing an example. However, it doesn't detail format constraints or validation rules, slightly limiting the value.

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 Compute Engine persistent disks in a GCP project.' It specifies the verb ('List'), resource ('Compute Engine persistent disks'), and scope ('in a GCP project'). However, it doesn't explicitly differentiate from sibling tools like 'list_compute_instances' or 'list_snapshots' that operate on related resources, which prevents a perfect score.

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 sibling tools like 'list_compute_instances' or 'list_snapshots' that might be relevant for related tasks, nor does it specify prerequisites, exclusions, or contextual usage scenarios. The only implicit guidance is the parameter descriptions, which are insufficient for usage decisions.

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