delete_objects
Remove multiple files from an S3 bucket using this tool. Specify bucket name and file keys to delete objects, with optional error suppression for failed deletions.
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-516 (handler)The main handler for the 'delete_objects' tool, decorated with @mcp.tool() for registration. It calls the helper logic and formats the response using format_response.@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)Core helper function that executes the boto3 S3 client.delete_objects API call to delete multiple objects.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, )
- src/s3_mcp.py:494-494 (registration)Decorator that registers the delete_objects function as an MCP tool.@mcp.tool()
- src/s3_mcp.py:495-499 (schema)Type annotations and parameters defining the input schema for the tool.def delete_objects( bucket: str, keys: List[str], quiet: bool = False, ) -> str: