Skip to main content
Glama
KonMam

s3-mcp

by KonMam

list_objects_v2

Retrieve and list objects stored in an S3 bucket, with options to filter by prefix, paginate results, and group keys using delimiters for organized data access.

Instructions

Lists objects in an S3 bucket.

Args: bucket (str): The name of the bucket. prefix (Optional[str]): Filter for keys starting with this prefix. max_keys (Optional[int]): Maximum number of keys to return. continuation_token (Optional[str]): Token for paginating results. delimiter (Optional[str]): Delimiter for grouping keys.

Returns: str: JSON formatted S3 response.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bucketYes
prefixNo
max_keysNo
continuation_tokenNo
delimiterNo

Implementation Reference

  • The main handler function for the 'list_objects_v2' MCP tool, decorated with @mcp.tool(). It receives parameters, calls the core logic helper, and returns a formatted JSON response.
    @mcp.tool() def list_objects_v2( bucket: str, prefix: Optional[str] = None, max_keys: Optional[int] = None, continuation_token: Optional[str] = None, delimiter: Optional[str] = None, ) -> str: """Lists objects in an S3 bucket. Args: bucket (str): The name of the bucket. prefix (Optional[str]): Filter for keys starting with this prefix. max_keys (Optional[int]): Maximum number of keys to return. continuation_token (Optional[str]): Token for paginating results. delimiter (Optional[str]): Delimiter for grouping keys. Returns: str: JSON formatted S3 response. """ result = _list_objects_v2_logic( bucket=bucket, prefix=prefix, max_keys=max_keys, continuation_token=continuation_token, delimiter=delimiter, ) return format_response(result)
  • Helper function containing the core implementation logic for listing S3 objects using boto3's list_objects_v2 method, handling parameters and making the API call.
    def _list_objects_v2_logic( bucket: str, prefix: Optional[str] = None, max_keys: Optional[int] = None, continuation_token: Optional[str] = None, delimiter: Optional[str] = None, ) -> Dict[str, Any]: """Core logic to list objects in an S3 bucket. Args: bucket (str): The S3 bucket name. prefix (Optional[str]): Filter for keys starting with this prefix. max_keys (Optional[int]): Maximum number of keys to return. continuation_token (Optional[str]): Token for paginating results. delimiter (Optional[str]): Delimiter for grouping keys. Returns: Dict[str, Any]: Raw boto3 response from list_objects_v2. """ client = get_s3_client() params: Dict[str, Any] = {"Bucket": bucket} if prefix: params["Prefix"] = prefix if max_keys: params["MaxKeys"] = max_keys if continuation_token: params["ContinuationToken"] = continuation_token if delimiter: params["Delimiter"] = delimiter return client.list_objects_v2(**params)

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