upload_file
Upload files to Amazon S3 buckets by specifying file path, bucket name, and object key for cloud storage management.
Instructions
Uploads a file to an S3 object.
Args: filename (str): The path to the file to upload. bucket (str): The name of the bucket to upload to. key (str): The name of the key to upload to.
Returns: str: JSON formatted success message.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filename | Yes | ||
| bucket | Yes | ||
| key | Yes |
Implementation Reference
- src/s3_mcp.py:353-372 (handler)The primary handler function for the 'upload_file' tool, registered via @mcp.tool() decorator. It calls the helper logic and formats a success response.@mcp.tool() def upload_file( filename: str, bucket: str, key: str, ) -> str: """Uploads a file to an S3 object. Args: filename (str): The path to the file to upload. bucket (str): The name of the bucket to upload to. key (str): The name of the key to upload to. Returns: str: JSON formatted success message. """ _upload_file_logic(filename=filename, bucket=bucket, key=key) return format_response( {"status": "success", "message": f"File '{filename}' uploaded to '{bucket}/{key}'."} )
- src/s3_mcp.py:330-351 (helper)Helper function containing the core S3 upload logic using boto3's client.upload_file method.def _upload_file_logic( filename: str, bucket: str, key: str, extra_args: Optional[Dict[str, Any]] = None, ) -> None: """Core logic to upload a file to an S3 bucket. Args: filename (str): The path to the file to upload. bucket (str): The S3 bucket name. key (str): The S3 object key. extra_args (Optional[Dict[str, Any]]): Extra arguments for the upload. """ client = get_s3_client() client.upload_file( Filename=filename, Bucket=bucket, Key=key, ExtraArgs=extra_args, )