Skip to main content
Glama
KonMam

s3-mcp

by KonMam

get_object

Retrieve objects from AWS S3 buckets by specifying bucket name and object key to access stored data.

Instructions

Gets an object from an S3 bucket.

Args: bucket (str): The name of the bucket. key (str): The key (name) of the object.

Returns: str: JSON formatted S3 response.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bucketYes
keyYes

Implementation Reference

  • The main handler function for the 'get_object' MCP tool. Registered via @mcp.tool() decorator. Calls the private helper logic and formats the response.
    @mcp.tool() def get_object(bucket: str, key: str) -> str: """Gets an object from an S3 bucket. Args: bucket (str): The name of the bucket. key (str): The key (name) of the object. Returns: str: JSON formatted S3 response. """ result = _get_object_logic(bucket=bucket, key=key) return format_response(result)
  • Private helper implementing the core S3 get_object operation using boto3 client, reads and decodes the body for JSON serialization.
    def _get_object_logic(bucket: str, key: str) -> Dict[str, Any]: """Core logic to get an object from an S3 bucket. Args: bucket (str): The S3 bucket name. key (str): The S3 object key. Returns: Dict[str, Any]: Raw boto3 response from get_object. """ client = get_s3_client() response = client.get_object(Bucket=bucket, Key=key) # The body is a StreamingBody, which is not directly JSON serializable. # We read it and decode it to a string. if 'Body' in response: response['Body'] = response['Body'].read().decode('utf-8') return response
  • src/s3_mcp.py:164-164 (registration)
    The @mcp.tool() decorator registers the get_object function as an MCP tool.
    @mcp.tool()
  • Utility function to format tool responses as indented JSON strings, used by get_object.
    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)

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