delete_objects
Remove multiple objects from an S3 bucket by specifying bucket name and object keys. Optionally suppress errors to return only failed deletions. Returns JSON-formatted S3 response.
Instructions
Deletes multiple objects from an S3 bucket.
Args: bucket (str): The name of the bucket. keys (List[str]): A list of keys to delete. quiet (bool): Suppress errors and return only failed deletions.
Returns: str: JSON formatted S3 response.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bucket | Yes | ||
| keys | Yes | ||
| quiet | No |
Implementation Reference
- src/s3_mcp.py:494-515 (handler)The main handler function for the 'delete_objects' tool, registered via @mcp.tool(). It invokes the core logic helper and formats the boto3 response as JSON.@mcp.tool() def delete_objects( bucket: str, keys: List[str], quiet: bool = False, ) -> str: """Deletes multiple objects from an S3 bucket. Args: bucket (str): The name of the bucket. keys (List[str]): A list of keys to delete. quiet (bool): Suppress errors and return only failed deletions. Returns: str: JSON formatted S3 response. """ result = _delete_objects_logic( bucket=bucket, keys=keys, quiet=quiet, ) return format_response(result)
- src/s3_mcp.py:470-492 (helper)Helper function containing the core implementation of deleting multiple S3 objects using boto3's delete_objects method.def _delete_objects_logic( bucket: str, keys: List[str], quiet: bool = False, ) -> Dict[str, Any]: """Core logic to delete multiple objects from an S3 bucket. Args: bucket (str): The S3 bucket name. keys (List[str]): A list of keys to delete. quiet (bool): Whether to suppress errors and return only failed deletions. Returns: Dict[str, Any]: Raw boto3 response from delete_objects. """ client = get_s3_client() objects_to_delete = [{'Key': key} for key in keys] delete_payload = {'Objects': objects_to_delete, 'Quiet': quiet} return client.delete_objects( Bucket=bucket, Delete=delete_payload, )