Skip to main content
Glama

list_objects

Retrieve a list of objects from a specified Cloud Storage bucket in GCP, filtering by prefix and limiting results. Identify and manage stored data efficiently with this tool.

Instructions

    List objects in a Cloud Storage bucket.
    
    Args:
        project_id: The ID of the GCP project
        bucket_name: The name of the bucket to list objects from
        prefix: Optional prefix to filter objects by
        limit: Maximum number of objects to list (default: 100)
    
    Returns:
        List of objects in the specified Cloud Storage bucket
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bucket_nameYes
limitNo
prefixNo
project_idYes

Implementation Reference

  • The main handler function for the 'list_objects' tool. It lists objects (blobs) in a GCP Cloud Storage bucket using the google.cloud.storage client, with optional prefix and limit. Formats and returns a string list of objects.
        @mcp.tool()
        def list_objects(project_id: str, bucket_name: str, prefix: Optional[str] = None, limit: int = 100) -> str:
            """
            List objects in a Cloud Storage bucket.
            
            Args:
                project_id: The ID of the GCP project
                bucket_name: The name of the bucket to list objects from
                prefix: Optional prefix to filter objects by
                limit: Maximum number of objects to list (default: 100)
            
            Returns:
                List of objects in the specified Cloud Storage bucket
            """
            try:
                from google.cloud import storage
                
                # Initialize the Storage client
                client = storage.Client(project=project_id)
                
                # Get the bucket
                bucket = client.get_bucket(bucket_name)
                
                # List blobs
                blobs = bucket.list_blobs(prefix=prefix, max_results=limit)
                
                # Format the response
                objects_list = []
                for blob in blobs:
                    size_mb = blob.size / (1024 * 1024)
                    updated = blob.updated.strftime("%Y-%m-%d %H:%M:%S UTC") if blob.updated else "Unknown"
                    objects_list.append(f"- {blob.name} (Size: {size_mb:.2f} MB, Updated: {updated}, Content-Type: {blob.content_type})")
                
                if not objects_list:
                    return f"No objects found in bucket {bucket_name}{' with prefix ' + prefix if prefix else ''}."
                
                objects_str = "\n".join(objects_list)
                
                return f"""
    Objects in Cloud Storage Bucket {bucket_name}{' with prefix ' + prefix if prefix else ''}:
    {objects_str}
    """
            except Exception as e:
                return f"Error listing objects: {str(e)}"
  • Invocation of the storage tools registration function, which registers the list_objects tool (among others) with the MCP server instance.
    storage_tools.register_tools(mcp)
  • Import of the storage tools module, providing the register_tools function used to register the list_objects tool.
    from .gcp_modules.storage import tools as storage_tools

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A4/5.0
Behavior3/5

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

With no annotations, the description carries the burden of explaining behavior. It mentions the 'limit' parameter as maximum objects and 'prefix' as a filter, which are behavioral details. However, it does not disclose pagination behavior, permissions required, or error conditions, 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.

Conciseness4/5

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

The description is structured with Args and Returns sections, front-loaded with the main purpose. It is concise but slightly repetitive in the Returns line echoing the first sentence. Overall efficient and readable.

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?

For a simple list operation with no output schema, the description covers the essential information: purpose, parameters, and return value. It does not explain pagination or edge cases, but the tool is straightforward and the documentation is adequate.

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?

Despite 0% schema description coverage, the description fully explains each parameter: project_id, bucket_name, prefix as an optional filter, and limit with a default value. This adds meaning beyond the schema's bare types and titles.

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 states 'List objects in a Cloud Storage bucket' with a specific verb and resource, clearly distinguishing it from sibling tools like list_storage_buckets and upload_object. The tool's purpose is unambiguous.

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?

Usage context is implied by the name and description: use this tool to enumerate objects within a specific bucket. No explicit when-to-use or alternative guidance is provided, but it is clear enough for a straightforward listing operation.

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