upload_file
Upload a file to a specified S3 bucket and key using the s3-mcp server. Input the file path, bucket name, and key to receive a JSON success message upon completion.
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 |
|---|---|---|---|
| bucket | Yes | ||
| filename | Yes | ||
| key | Yes |
Implementation Reference
- src/s3_mcp.py:353-372 (handler)The main handler function for the 'upload_file' MCP tool, decorated with @mcp.tool() to register it. It processes inputs and calls the core upload logic.@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)The core helper function implementing the S3 file upload using boto3 client.upload_file.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, )