Skip to main content
Glama
KonMam

s3-mcp

by KonMam

list_buckets

Retrieve a JSON-formatted list of all S3 buckets in an AWS account using this tool, enabling quick access to bucket data for integration and management.

Instructions

Lists all buckets in the AWS account.

Returns: str: JSON formatted list of buckets.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'list_buckets' MCP tool. It is registered via the @mcp.tool() decorator with FastMCP. Calls the helper to get raw data and formats it as a JSON string for the response.
    @mcp.tool() def list_buckets() -> str: """Lists all buckets in the AWS account. Returns: str: JSON formatted list of buckets. """ result = _list_buckets_logic() return format_response(result)
  • Helper function implementing the core S3 bucket listing logic using boto3's list_buckets() method.
    def _list_buckets_logic() -> Dict[str, Any]: """Core logic to list S3 buckets. Returns: Dict[str, Any]: Raw boto3 response from list_buckets. """ client = get_s3_client() return client.list_buckets()
  • Utility helper function used by list_buckets (and other tools) to format the boto3 response as a pretty-printed JSON string.
    def format_response(data: Any) -> str: """Format response data as JSON string. Args: data (Any): Data to format Returns: str: JSON formatted string """ return json.dumps(data, indent=2, default=str)
  • Helper function to initialize and return the global S3 boto3 client, used by _list_buckets_logic. Includes credential validation via list_buckets().
    def get_s3_client() -> BaseClient: """Get or create the S3 boto3 client. Returns: BaseClient: S3 client Raises: NoCredentialsError: If AWS credentials are not found. """ global s3_client if s3_client is None: logger.info("Initializing S3 client") try: s3_client = boto3.client("s3") s3_client.list_buckets() # Validate credentials logger.info("Successfully initialized and validated S3 client.") except NoCredentialsError as e: logger.error("AWS credentials not found.") raise e except Exception as e: logger.error(f"Unexpected error initializing S3 client: {e}") raise e return s3_client

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/KonMam/s3-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server