Skip to main content
Glama

download_object

Download files from a Google Cloud Storage bucket by specifying the project ID, bucket name, file name, and local save path. Simplify file retrieval for GCP resources.

Instructions

Download a file from a Cloud Storage bucket. Args: project_id: The ID of the GCP project bucket_name: The name of the bucket to download from source_blob_name: The name of the file in the bucket destination_file_path: The local path to save the file to Returns: Result of the download operation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bucket_nameYes
destination_file_pathYes
project_idYes
source_blob_nameYes

Implementation Reference

  • The handler function for the 'download_object' tool, decorated with @mcp.tool(). It downloads a specified blob from a GCP Cloud Storage bucket to a local destination file path using the google.cloud.storage client.
    @mcp.tool() def download_object(project_id: str, bucket_name: str, source_blob_name: str, destination_file_path: str) -> str: """ Download a file from a Cloud Storage bucket. Args: project_id: The ID of the GCP project bucket_name: The name of the bucket to download from source_blob_name: The name of the file in the bucket destination_file_path: The local path to save the file to Returns: Result of the download operation """ 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) # Get the blob blob = bucket.blob(source_blob_name) # Download the file blob.download_to_filename(destination_file_path) return f""" File successfully downloaded: - Source: gs://{bucket_name}/{source_blob_name} - Destination: {destination_file_path} - Size: {blob.size / (1024 * 1024):.2f} MB - Content-Type: {blob.content_type} """ except Exception as e: return f"Error downloading file: {str(e)}"

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