Skip to main content
Glama
KonMam

s3-mcp

by KonMam

download_file

Download objects from AWS S3 buckets to local files by specifying bucket name, object key, and destination filename.

Instructions

Downloads an object from an S3 bucket to a file.

Args: bucket (str): The name of the bucket to download from. key (str): The name of the key to download from. filename (str): The path to the file to download to.

Returns: str: JSON formatted success message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bucketYes
keyYes
filenameYes

Implementation Reference

  • The handler function for the 'download_file' tool, registered via @mcp.tool() decorator. It invokes the helper logic and formats the success response.
    @mcp.tool()
    def download_file(
        bucket: str,
        key: str,
        filename: str,
    ) -> str:
        """Downloads an object from an S3 bucket to a file.
    
        Args:
            bucket (str): The name of the bucket to download from.
            key (str): The name of the key to download from.
            filename (str): The path to the file to download to.
    
        Returns:
            str: JSON formatted success message.
        """
        _download_file_logic(bucket=bucket, key=key, filename=filename)
        return format_response(
            {"status": "success", "message": f"File '{key}' from bucket '{bucket}' downloaded to '{filename}'."}
        )
  • The supporting helper function containing the core download logic using boto3 S3 client's download_file method.
    def _download_file_logic(
        bucket: str,
        key: str,
        filename: str,
    ) -> None:
        """Core logic to download an object from an S3 bucket.
    
        Args:
            bucket (str): The S3 bucket name.
            key (str): The S3 object key.
            filename (str): The local path to download the file to.
        """
        client = get_s3_client()
        client.download_file(
            Bucket=bucket,
            Key=key,
            Filename=filename,
        )
  • Input schema defined by function parameters with type annotations: bucket (str), key (str), filename (str); returns str.
    def download_file(
        bucket: str,
        key: str,
        filename: str,
    ) -> str:

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/KonMam/s3-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server