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
| Name | Required | Description | Default |
|---|---|---|---|
| bucket | Yes | ||
| key | Yes | ||
| filename | Yes |
Implementation Reference
- src/s3_mcp.py:395-414 (handler)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}'."} )
- src/s3_mcp.py:375-393 (helper)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, )
- src/s3_mcp.py:396-400 (schema)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: