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
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states what the tool does but doesn't mention important behavioral aspects like pagination behavior, rate limits, authentication requirements, error conditions, or whether this is a read-only operation. The description is functionally correct but lacks operational context.

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 with a clear purpose statement followed by Args and Returns sections. It's appropriately sized for a 4-parameter tool with no wasted words. The formatting with clear section headers makes it easy to parse, though the triple quotes in the provided text suggest potential formatting issues in the original.

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 list operation with 4 parameters and no annotations or output schema, the description provides adequate but minimal coverage. It explains what the tool does and documents parameters, but lacks behavioral context (pagination, errors, auth) and doesn't describe the return format beyond 'List of objects'. Given the complexity and lack of structured metadata, it meets minimum viable standards.

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?

With 0% schema description coverage, the description provides meaningful parameter documentation that compensates well. It explains all 4 parameters with clear semantics: project_id as 'GCP project', bucket_name as 'bucket to list objects from', prefix as 'filter objects by', and limit with its default value. This adds substantial value beyond the bare schema.

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 action ('List objects') and resource ('in a Cloud Storage bucket'), making the purpose immediately understandable. It doesn't specifically differentiate from sibling tools like 'list_storage_buckets' or 'list_assets', but the resource specificity (objects within a bucket) provides implicit distinction.

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. With sibling tools like 'list_storage_buckets' (lists buckets themselves) and 'list_assets' (potentially broader resource listing), there's no indication of when this specific object-listing tool is appropriate versus other listing tools.

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