Skip to main content
Glama
KonMam

s3-mcp

by KonMam

put_object

Upload files or data to an Amazon S3 bucket by specifying bucket name, object key, and content body.

Instructions

Puts an object into an S3 bucket.

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

Returns: str: JSON formatted S3 response.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bucketYes
keyYes
bodyYes

Implementation Reference

  • The primary handler for the 'put_object' MCP tool. Decorated with @mcp.tool() for registration. Defines input schema via type hints and docstring. Executes core logic and formats response as JSON.
    @mcp.tool()
    def put_object(
        bucket: str,
        key: str,
        body: str,
    ) -> str:
        """Puts an object into an S3 bucket.
    
        Args:
            bucket (str): The name of the bucket.
            key (str): The key (name) of the object.
            body (str): The content of the object.
    
        Returns:
            str: JSON formatted S3 response.
        """
        result = _put_object_logic(bucket=bucket, key=key, body=body)
        return format_response(result)
  • Internal helper function implementing the core S3 put_object logic using boto3 client, handling body encoding.
    def _put_object_logic(
        bucket: str,
        key: str,
        body: Union[str, bytes],
    ) -> Dict[str, Any]:
        """Core logic to put an object into an S3 bucket.
    
        Args:
            bucket (str): The S3 bucket name.
            key (str): The S3 object key.
            body (Union[str, bytes]): The content of the object.
    
        Returns:
            Dict[str, Any]: Raw boto3 response from put_object.
        """
        client = get_s3_client()
        params: Dict[str, Any] = {"Bucket": bucket, "Key": key}
    
        if isinstance(body, str):
            params["Body"] = body.encode("utf-8")
        else:
            params["Body"] = body  # Assuming bytes or file-like object
    
        return client.put_object(**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