copy_object
Copy files between S3 buckets or within the same bucket by specifying source and destination locations.
Instructions
Copies an object from one S3 location to another.
Args: source_bucket (str): The name of the source bucket. source_key (str): The key of the source object. destination_bucket (str): The name of the destination bucket. destination_key (str): The key of the destination object.
Returns: str: JSON formatted S3 response.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| source_bucket | Yes | ||
| source_key | Yes | ||
| destination_bucket | Yes | ||
| destination_key | Yes |
Implementation Reference
- src/s3_mcp.py:443-467 (handler)Main handler function for the 'copy_object' tool, decorated with @mcp.tool() for registration. Defines input schema via type hints and docstring, executes the tool by calling helper and formatting response.@mcp.tool() def copy_object( source_bucket: str, source_key: str, destination_bucket: str, destination_key: str, ) -> str: """Copies an object from one S3 location to another. Args: source_bucket (str): The name of the source bucket. source_key (str): The key of the source object. destination_bucket (str): The name of the destination bucket. destination_key (str): The key of the destination object. Returns: str: JSON formatted S3 response. """ result = _copy_object_logic( source_bucket=source_bucket, source_key=source_key, destination_bucket=destination_bucket, destination_key=destination_key, ) return format_response(result)
- src/s3_mcp.py:417-441 (helper)Helper function containing the core S3 copy_object logic using boto3 client.def _copy_object_logic( source_bucket: str, source_key: str, destination_bucket: str, destination_key: str, ) -> Dict[str, Any]: """Core logic to copy an object from one S3 location to another. Args: source_bucket (str): The name of the source bucket. source_key (str): The key of the source object. destination_bucket (str): The name of the destination bucket. destination_key (str): The key of the destination object. Returns: Dict[str, Any]: Raw boto3 response from copy_object. """ client = get_s3_client() copy_source = {'Bucket': source_bucket, 'Key': source_key} return client.copy_object( CopySource=copy_source, Bucket=destination_bucket, Key=destination_key, )