aws_list_s3_buckets
Retrieve a list of all S3 buckets in your AWS account to manage storage resources and monitor bucket inventory across regions.
Instructions
List all S3 buckets in AWS
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "aws_list_s3_buckets"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| region | No | AWS region | us-east-1 |
Implementation Reference
- src/tools/aws-tools.ts:121-132 (handler)Tool-specific handler in handleAWSTool function that invokes the AWSAdapter to list S3 buckets and formats the response with total count and bucket details.
case 'aws_list_s3_buckets': { const buckets = await adapter.listS3Buckets(); return { total: buckets.length, buckets: buckets.map((bucket) => ({ id: bucket.id, name: bucket.bucketName, region: bucket.region, creationDate: bucket.creationDate, })), }; } - src/adapters/aws-adapter.ts:136-172 (helper)Core implementation in AWSAdapter that initializes S3 client, lists all buckets using AWS SDK, determines each bucket's region, and maps to standardized S3Bucket format.
async listS3Buckets(): Promise<S3Bucket[]> { await this.initializeClients(); if (!this.s3Client) throw new Error('S3 client not initialized'); try { const command = new ListBucketsCommand({}); const response = await this.s3Client.send(command); const buckets: S3Bucket[] = []; for (const bucket of response.Buckets || []) { // Get bucket location let location = this.region; try { const locationCommand = new GetBucketLocationCommand({ Bucket: bucket.Name }); const locationResponse = await this.s3Client.send(locationCommand); location = locationResponse.LocationConstraint || this.region; } catch { // Use default region if location fetch fails } buckets.push({ id: bucket.Name || '', type: 'storage', name: bucket.Name || '', region: location, status: 'running', bucketName: bucket.Name || '', creationDate: bucket.CreationDate, }); } return buckets; } catch (error) { throw new Error(`Failed to list S3 buckets: ${error instanceof Error ? error.message : String(error)}`); } } - src/tools/aws-tools.ts:19-32 (schema)Input schema and metadata definition for the aws_list_s3_buckets tool, including optional region parameter.
{ name: 'aws_list_s3_buckets', description: 'List all S3 buckets in AWS', inputSchema: { type: 'object', properties: { region: { type: 'string', description: 'AWS region', default: 'us-east-1', }, }, }, }, - src/server.ts:19-27 (registration)Registers the aws_list_s3_buckets tool by including it in the awsTools array which is spread into the main allTools list exposed to the MCP server for tool listing.
const allTools = [ ...awsTools, ...azureTools, ...gcpTools, ...resourceManagementTools, ...costAnalysisTools, ...monitoringTools, ...securityTools, ]; - src/server.ts:64-65 (registration)Routes execution of aws_list_s3_buckets and other AWS tools to the dedicated handleAWSTool function in the main tool call handler.
if (awsTools.some((t) => t.name === name)) { result = await handleAWSTool(name, args || {});