Skip to main content
Glama

upload_object

Transfer files from local storage to a Google Cloud Storage bucket using specified project and bucket details. Automates file uploads with customizable destination names and content types for efficient cloud storage management.

Instructions

    Upload a file to a Cloud Storage bucket.
    
    Args:
        project_id: The ID of the GCP project
        bucket_name: The name of the bucket to upload to
        source_file_path: The local file path to upload
        destination_blob_name: The name to give the file in GCS (default: filename from source)
        content_type: The content type of the file (default: auto-detect)
    
    Returns:
        Result of the upload operation
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bucket_nameYes
content_typeNo
destination_blob_nameNo
project_idYes
source_file_pathYes

Implementation Reference

  • The core handler function for the 'upload_object' tool, which uploads a local file to a GCP Cloud Storage bucket using the Google Cloud Storage client.
        @mcp.tool()
        def upload_object(project_id: str, bucket_name: str, source_file_path: str, destination_blob_name: Optional[str] = None, content_type: Optional[str] = None) -> str:
            """
            Upload a file to a Cloud Storage bucket.
            
            Args:
                project_id: The ID of the GCP project
                bucket_name: The name of the bucket to upload to
                source_file_path: The local file path to upload
                destination_blob_name: The name to give the file in GCS (default: filename from source)
                content_type: The content type of the file (default: auto-detect)
            
            Returns:
                Result of the upload operation
            """
            try:
                import os
                from google.cloud import storage
                
                # Initialize the Storage client
                client = storage.Client(project=project_id)
                
                # Get the bucket
                bucket = client.get_bucket(bucket_name)
                
                # If no destination name is provided, use the source filename
                if not destination_blob_name:
                    destination_blob_name = os.path.basename(source_file_path)
                
                # Create a blob object
                blob = bucket.blob(destination_blob_name)
                
                # Upload the file
                blob.upload_from_filename(source_file_path, content_type=content_type)
                
                return f"""
    File successfully uploaded:
    - Source: {source_file_path}
    - Destination: gs://{bucket_name}/{destination_blob_name}
    - Size: {blob.size / (1024 * 1024):.2f} MB
    - Content-Type: {blob.content_type}
    """
            except Exception as e:
                return f"Error uploading file: {str(e)}"
  • Registers all storage tools, including 'upload_object', by invoking the module's register_tools function on the MCP server instance.
    # Register storage tools
    storage_tools.register_tools(mcp)
  • Imports the storage tools module containing the 'upload_object' tool implementation and registration logic.
    from .gcp_modules.storage import tools as storage_tools
  • The function signature and docstring defining the input schema (parameters) and output description for the 'upload_object' tool.
    def upload_object(project_id: str, bucket_name: str, source_file_path: str, destination_blob_name: Optional[str] = None, content_type: Optional[str] = None) -> str:
        """
        Upload a file to a Cloud Storage bucket.
        
        Args:
            project_id: The ID of the GCP project
            bucket_name: The name of the bucket to upload to
            source_file_path: The local file path to upload
            destination_blob_name: The name to give the file in GCS (default: filename from source)
            content_type: The content type of the file (default: auto-detect)
        
        Returns:
            Result of the upload operation
        """
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. While 'Upload a file' implies a write operation, the description doesn't mention authentication requirements, permissions needed, whether the operation overwrites existing files, rate limits, error conditions, or what the 'Result of the upload operation' actually contains. This leaves significant behavioral gaps for a mutation tool.

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 perfectly structured and concise. It starts with a clear purpose statement, then provides a well-organized Args section with bullet-like formatting, and ends with a Returns statement. Every sentence earns its place, and the information is front-loaded with the most important details first.

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 this is a mutation tool with no annotations and no output schema, the description has significant gaps. While parameter documentation is excellent, the description lacks crucial context about authentication requirements, error handling, what the return value actually contains, and behavioral constraints. For a tool that modifies cloud storage, this leaves the agent with incomplete operational understanding.

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 provides excellent parameter documentation with clear explanations for all 5 parameters, including defaults for destination_blob_name and content_type. Since schema description coverage is 0%, the description fully compensates by explaining what each parameter means and how it's used, going well beyond the bare schema field names.

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 'Upload a file to a Cloud Storage bucket' which is a specific verb+resource combination. It distinguishes itself from sibling tools like 'download_object' and 'delete_object' by specifying the upload direction. However, it doesn't explicitly differentiate from other potential file manipulation tools beyond the obvious upload/download 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. There's no mention of prerequisites (like authentication), when this tool is appropriate versus other storage operations, or any exclusions. The agent must infer usage from the purpose statement 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