delete_object
Remove specific objects from an S3 bucket by specifying bucket name and object key. Returns S3 response in JSON format for tracking deletion status.
Instructions
Deletes an object from an S3 bucket.
Args: bucket (str): The name of the bucket. key (str): The key (name) of the object.
Returns: str: JSON formatted S3 response.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bucket | Yes | ||
| key | Yes |
Implementation Reference
- src/s3_mcp.py:193-205 (handler)The main handler function for the 'delete_object' tool, decorated with @mcp.tool() for registration. It calls the helper logic and formats the response.@mcp.tool() def delete_object(bucket: str, key: str) -> str: """Deletes an object from an S3 bucket. Args: bucket (str): The name of the bucket. key (str): The key (name) of the object. Returns: str: JSON formatted S3 response. """ result = _delete_object_logic(bucket=bucket, key=key) return format_response(result)
- src/s3_mcp.py:179-191 (helper)The core helper function that performs the actual S3 delete_object operation using boto3 client.def _delete_object_logic(bucket: str, key: str) -> Dict[str, Any]: """Core logic to delete an object from an S3 bucket. Args: bucket (str): The S3 bucket name. key (str): The S3 object key. Returns: Dict[str, Any]: Raw boto3 response from delete_object. """ client = get_s3_client() return client.delete_object(Bucket=bucket, Key=key)