list-buckets
List all S3 buckets in your AWS account. Get a complete inventory of bucket names for storage management and organization.
Instructions
List available S3 buckets
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/listBuckets.ts:40-57 (handler)The execute() method that runs when 'list-buckets' is invoked. It calls s3Resource.listBuckets() and returns the result as JSON text.
async execute(_args: Record<string, never>) { try { const buckets = await this.s3Resource.listBuckets(); return { content: [ { type: "text" as const, text: JSON.stringify(buckets, null, 2), }, ], }; } catch (error) { return createErrorResponse( error, `Error listing buckets: ${error instanceof Error ? error.message : String(error)}`, ); } } - src/tools/listBuckets.ts:22-22 (schema)Empty parameters definition (const assertion) since list-buckets takes no arguments.
readonly parameters = {} as const; - src/server.ts:28-30 (registration)Tools are registered via server.tool() in the createServer() function, iterating over all tools including ListBucketsTool.
const tools = createTools(s3Resource); for (const tool of tools) { server.tool(tool.name, tool.description, tool.parameters, tool.execute.bind(tool)); - src/resources/s3.ts:70-89 (helper)The S3Resource.listBuckets() method that actually calls AWS SDK's ListBucketsCommand and optionally filters by configured buckets.
async listBuckets(): Promise<Bucket[]> { try { const command = new ListBucketsCommand({}); const response = await this.client.send(command); const buckets = response.Buckets || []; // Use pattern matching to filter buckets return match({ buckets, hasConfiguredBuckets: this.configuredBuckets.length > 0 }) .with({ hasConfiguredBuckets: true }, ({ buckets }) => buckets .filter((bucket) => bucket.Name && this.configuredBuckets.includes(bucket.Name)) .slice(0, this.maxBuckets), ) .otherwise(({ buckets }) => buckets.slice(0, this.maxBuckets)); } catch (error) { this.logError("Error listing buckets:", error); throw error; } } - src/tools/index.ts:12-18 (registration)The createTools() factory function instantiates ListBucketsTool with the S3Resource dependency.
export function createTools(s3Resource: S3Resource): IMCPTool[] { return [ new ListBucketsTool(s3Resource), new ListObjectsTool(s3Resource), new GetObjectTool(s3Resource), ]; }