Skip to main content
Glama
KonMam

s3-mcp

by KonMam

upload_file

Upload files to Amazon S3 buckets by specifying file path, bucket name, and object key for cloud storage management.

Instructions

Uploads a file to an S3 object.

Args: filename (str): The path to the file to upload. bucket (str): The name of the bucket to upload to. key (str): The name of the key to upload to.

Returns: str: JSON formatted success message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filenameYes
bucketYes
keyYes

Implementation Reference

  • The primary handler function for the 'upload_file' tool, registered via @mcp.tool() decorator. It calls the helper logic and formats a success response.
    @mcp.tool()
    def upload_file(
        filename: str,
        bucket: str,
        key: str,
    ) -> str:
        """Uploads a file to an S3 object.
    
        Args:
            filename (str): The path to the file to upload.
            bucket (str): The name of the bucket to upload to.
            key (str): The name of the key to upload to.
    
        Returns:
            str: JSON formatted success message.
        """
        _upload_file_logic(filename=filename, bucket=bucket, key=key)
        return format_response(
            {"status": "success", "message": f"File '{filename}' uploaded to '{bucket}/{key}'."}
        )
  • Helper function containing the core S3 upload logic using boto3's client.upload_file method.
    def _upload_file_logic(
        filename: str,
        bucket: str,
        key: str,
        extra_args: Optional[Dict[str, Any]] = None,
    ) -> None:
        """Core logic to upload a file to an S3 bucket.
    
        Args:
            filename (str): The path to the file to upload.
            bucket (str): The S3 bucket name.
            key (str): The S3 object key.
            extra_args (Optional[Dict[str, Any]]): Extra arguments for the upload.
        """
        client = get_s3_client()
        client.upload_file(
            Filename=filename,
            Bucket=bucket,
            Key=key,
            ExtraArgs=extra_args,
        )

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