list-s3-buckets
Retrieve all S3 buckets in your AWS account to manage storage, monitor resources, and organize data across regions.
Instructions
List all S3 buckets in your AWS account
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| region | No | AWS region (optional, defaults to configured region) |
Implementation Reference
- src/s3_tools/server.py:41-61 (handler)Handler logic for the 'list-s3-buckets' tool within the handle_call_tool function. It uses boto3 to create an S3 client, list all buckets, format them into a text response, or return an error message if a ClientError occurs.if name == "list-s3-buckets": try: region = arguments.get("region") if arguments else None s3_client = boto3.client('s3', region_name=region) if region else boto3.client('s3') response = s3_client.list_buckets() buckets = [bucket['Name'] for bucket in response['Buckets']] return [ types.TextContent( type="text", text=f"Found {len(buckets)} S3 buckets:\n" + "\n".join(f"- {bucket}" for bucket in buckets) ) ] except ClientError as e: return [ types.TextContent( type="text", text=f"Error listing S3 buckets: {str(e)}" ) ]
- src/s3_tools/server.py:19-32 (registration)Registration of the 'list-s3-buckets' tool in the handle_list_tools function, including its name, description, and JSON schema for input validation (region parameter).types.Tool( name="list-s3-buckets", description="List all S3 buckets in your AWS account", inputSchema={ "type": "object", "properties": { "region": { "type": "string", "description": "AWS region (optional, defaults to configured region)", } } }, ) ]
- src/s3_tools/server.py:22-30 (schema)JSON schema definition for the 'list-s3-buckets' tool input, defining an optional 'region' string parameter.inputSchema={ "type": "object", "properties": { "region": { "type": "string", "description": "AWS region (optional, defaults to configured region)", } } },