Skip to main content
Glama
KonMam

s3-mcp

by KonMam

list_objects_v2

Retrieve a JSON-formatted list of objects from an S3 bucket, with options to filter by prefix, set maximum keys, paginate using a token, and group keys with a delimiter.

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
continuation_tokenNo
delimiterNo
max_keysNo
prefixNo

Implementation Reference

  • Main handler function for list_objects_v2 tool, decorated with @mcp.tool() for registration. Handles parameters, calls helper logic, and formats response as JSON.
    @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 boto3 client.list_objects_v2 call with parameter preparation.
    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)
  • src/s3_mcp.py:240-240 (registration)
    The @mcp.tool() decorator registers the list_objects_v2 function as an MCP tool.
    @mcp.tool()
  • Docstring in handler defines input schema (parameters) and output for FastMCP tool schema generation.
    """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.

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