copy_object
Transfer objects between S3 buckets by specifying source and destination locations. Retrieve a JSON response confirming the operation's success.
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 |
|---|---|---|---|
| destination_bucket | Yes | ||
| destination_key | Yes | ||
| source_bucket | Yes | ||
| source_key | Yes |
Implementation Reference
- src/s3_mcp.py:443-467 (handler)The main handler function for the "copy_object" MCP tool. It is decorated with @mcp.tool(), which registers it, defines the input schema via type hints and docstring, and delegates to the core logic helper.@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)Supporting helper function that implements the core S3 object copy operation using the boto3 client's copy_object method.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, )