Skip to main content
Glama
Amazon S3 MCP Server

Amazon S3 MCP Server

by aggeentik

Amazon S3 MCP Server

A Model Context Protocol (MCP) server for AWS S3 operations, providing secure access to S3 buckets through presigned URLs.

Features

  • List Objects: Browse S3 bucket contents with prefix filtering and pagination

  • Download Objects: Generate time-limited presigned URLs for secure downloads

  • Upload Objects: Generate presigned URLs for direct client-to-S3 uploads with encryption and ACL support

  • Delete Objects: Remove objects from S3 buckets (with version support)

  • Dual Format Support: All operations return both Markdown (human-readable) and JSON formats

  • Security First: Uses presigned URLs to avoid credential exposure and enable direct client-to-S3 communication

  • Comprehensive Validation: Pydantic v2 models ensure input validation and type safety

Related MCP server: S3 MCP Server

Architecture

This server uses presigned URLs instead of direct upload/download for several key benefits:

  • Security: Time-limited access without exposing AWS credentials

  • Scalability: Direct client-to-S3 communication (no server bottleneck)

  • Performance: Eliminates server as intermediary for data transfer

  • Flexibility: Works with any HTTP client (browsers, curl, etc.)

Prerequisites

  • Python: 3.10 or higher

  • AWS Account: With S3 access

  • AWS Credentials: Configured via AWS CLI, environment variables, or IAM roles

  • UV (optional): Fast Python package manager - Install UV

Installation

1. Clone or Download

cd /path/to/mcp-servers/aws-s3-mcp

2. Install Dependencies

Option A: Using pip (Traditional)

# Install in development mode
pip install -e .

# Or install with dev dependencies for testing
pip install -e ".[dev]"
# Install UV first (if not already installed)
curl -LsSf https://astral.sh/uv/install.sh | sh

# Install dependencies with UV
uv sync

# Or install with dev dependencies
uv sync --all-extras

3. Configure AWS Credentials

Choose one of the following methods:

Option A: AWS CLI (Recommended for development)

aws configure

Option B: Environment Variables

export AWS_ACCESS_KEY_ID=your-access-key
export AWS_SECRET_ACCESS_KEY=your-secret-key
export AWS_REGION=us-east-1

Option C: Named Profile

# Create .env file
cp .env.example .env

# Edit .env and set:
# AWS_PROFILE=my-profile
# AWS_REGION=us-east-1

Usage

Running the Server

Using Python

# Run directly as module
python -m s3_mcp

# Or use the installed command
s3-mcp

Using UV

# Run with UV
uv run s3-mcp

# Or run from specific directory
uv --directory /path/to/mcp-servers/aws-s3-mcp run s3-mcp

# Or use UVX (tool runner)
uvx --from /path/to/mcp-servers/aws-s3-mcp s3-mcp

Claude Desktop Configuration

Add to your Claude Desktop configuration file:

MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json

Option 1: Using Python (Traditional)

{
  "mcpServers": {
    "s3": {
      "command": "python",
      "args": ["-m", "s3_mcp"],
      "env": {
        "AWS_REGION": "us-east-1",
        "AWS_PROFILE": "default"
      }
    }
  }
}

Option 2: Using UV with Directory Path

{
  "mcpServers": {
    "s3": {
      "command": "uv",
      "args": [
        "--directory",
        "/path/to/mcp-servers/aws-s3-mcp",
        "run",
        "s3-mcp"
      ],
      "env": {
        "AWS_REGION": "us-east-1",
        "AWS_PROFILE": "default"
      }
    }
  }
}

Option 3: Using UVX (UV Tool Runner)

{
  "mcpServers": {
    "s3": {
      "command": "uvx",
      "args": [
        "--from",
        "/path/to/mcp-servers/aws-s3-mcp",
        "s3-mcp"
      ],
      "env": {
        "AWS_REGION": "us-east-1",
        "AWS_PROFILE": "default"
      }
    }
  }
}

Option 4: Using UV from Project Directory

{
  "mcpServers": {
    "s3": {
      "command": "uv",
      "args": ["run", "s3-mcp"],
      "cwd": "/path/to/mcp-servers/aws-s3-mcp",
      "env": {
        "AWS_REGION": "us-east-1",
        "AWS_PROFILE": "default"
      }
    }
  }
}

Note: Replace /path/to/mcp-servers/aws-s3-mcp with the actual absolute path to your installation directory.

Which Option Should I Use?

  • Option 1 (Python): Best if you have Python installed globally and the package installed with pip

  • Option 2 (UV with --directory): Best for development, keeps dependencies isolated per project

  • Option 3 (UVX): Best for quick tool execution, handles dependencies automatically

  • Option 4 (UV with cwd): Alternative to Option 2, uses cwd instead of --directory

Recommended: Use Option 2 or Option 3 with UV for better dependency isolation and faster startup times.

Available Tools

1. s3_list_objects

List objects in an S3 bucket with optional prefix filtering and pagination.

Parameters:

  • bucket_name (required): S3 bucket name (3-63 chars, lowercase)

  • prefix (optional): Filter objects by key prefix (e.g., "logs/2024/")

  • limit (optional): Max objects to return (1-1000, default: 20)

  • continuation_token (optional): Token from previous response for pagination

  • response_format (optional): "markdown" (default) or "json"

Example:

List objects in my-data-bucket with prefix "images/"

Response includes:

  • Object keys, sizes, last modified dates, storage classes

  • Pagination token if more results exist

2. s3_get_object

Generate a presigned URL for downloading an S3 object.

Parameters:

  • bucket_name (required): S3 bucket name

  • key (required): Object key (path within bucket)

  • expires_in (optional): URL expiration in seconds (1-604800, default: 3600)

  • response_content_disposition (optional): Override Content-Disposition header

  • response_content_type (optional): Override Content-Type header

  • response_format (optional): "markdown" (default) or "json"

Example:

Generate download URL for my-data-bucket/reports/2024-report.pdf

Response includes:

  • Time-limited presigned URL (valid for specified duration)

  • Expiration timestamp

  • Usage example (curl command)

Security Notes:

  • URLs are time-limited (max 7 days, default 1 hour)

  • Anyone with the URL can download during validity period

  • URLs cannot be revoked before expiration

3. s3_put_object

Generate a presigned URL for uploading an object to S3.

Parameters:

  • bucket_name (required): S3 bucket name

  • key (required): Destination object key

  • expires_in (optional): URL expiration in seconds (1-604800, default: 3600)

  • content_type (optional): MIME type (e.g., "image/png", "application/pdf")

  • server_side_encryption (optional): "AES256" or "aws:kms"

  • metadata (optional): Custom metadata as key-value pairs

  • acl (optional): Access control ("private", "public-read", etc.)

  • response_format (optional): "markdown" (default) or "json"

Example:

Generate upload URL for my-bucket/uploads/document.pdf with encryption

Response includes:

  • Presigned URL for PUT operation

  • Required headers (Content-Type, encryption, etc.)

  • Usage example (curl command with all required headers)

Security Notes:

  • Enforce encryption with server_side_encryption parameter

  • Use "private" ACL unless public access required

  • URL is scoped to specific object key

4. s3_delete_object

Delete an object from an S3 bucket.

⚠️ WARNING: This is a DESTRUCTIVE operation. Deleted objects cannot be recovered unless versioning is enabled.

Parameters:

  • bucket_name (required): S3 bucket name

  • key (required): Object key to delete

  • version_id (optional): Specific version to delete (for versioned buckets)

  • response_format (optional): "markdown" (default) or "json"

Example:

Delete my-bucket/temp/old-file.txt

Behavior:

  • Non-versioned buckets: Object is permanently deleted

  • Versioned buckets: Delete marker created (object can be recovered)

  • With version_id: Specific version permanently deleted

Response includes:

  • Deletion confirmation

  • Version information if applicable

Development

Quick Start with Makefile

The project includes a Makefile for common development tasks:

make help         # Show all available commands
make install-dev  # Install package with dev dependencies
make test         # Run test suite
make test-cov     # Run tests with coverage report
make lint         # Check code quality
make format       # Format code
make check        # Run all checks (lint + typecheck + test)
make inspector    # Launch MCP Inspector for testing
make clean        # Remove build artifacts

Project Structure

aws-s3-mcp/
├── s3_mcp/
│   ├── __init__.py          # Package initialization
│   ├── __main__.py          # Entry point
│   ├── server.py            # FastMCP server and tool definitions
│   └── s3/
│       ├── __init__.py      # S3 module exports
│       ├── client.py        # S3 client wrapper with error handling
│       ├── operations.py    # Core business logic for all operations
│       └── utils.py         # Shared utilities and formatters
├── tests/                   # Test suite (pytest + moto)
├── pyproject.toml          # Project configuration and dependencies
├── .env.example            # Example environment configuration
└── README.md               # This file

Running Tests

# Using Makefile (recommended)
make install-dev  # Install with dev dependencies
make test         # Run tests
make test-cov     # Run tests with coverage report

# Or use pytest directly
pip install -e ".[dev]"
pytest -v
pytest --cov=s3_mcp --cov-report=html

Test Suite:

  • ✅ 50 unit tests covering all operations

  • ✅ 95% coverage on core business logic (operations.py)

  • ✅ 88% coverage on utilities (utils.py)

  • ✅ Tests include: list objects, get/put/delete operations, pagination, error handling, versioning, encryption, ACLs

Testing with MCP Inspector

Test the server interactively using MCP Inspector:

# Using Makefile
make inspector

# Or run directly
npx @modelcontextprotocol/inspector python -m s3_mcp.server

This will:

  1. Start the MCP Inspector web interface

  2. Launch your S3 MCP server

  3. Open a browser where you can test all tools

  4. View tool schemas, test with different parameters, and inspect responses

Code Quality

# Using Makefile (recommended)
make format      # Format code with ruff
make lint        # Check code with ruff
make typecheck   # Run mypy type checking
make check       # Run all checks (lint + typecheck + test)

# Or run tools directly
ruff format .
ruff check .
mypy s3_mcp/

Configuration

Environment Variables

Create a .env file from .env.example:

# AWS Region (default: us-east-1)
AWS_REGION=us-east-1

# AWS Profile (optional)
AWS_PROFILE=my-profile

# Maximum Presigned URL Expiration (optional, default: 604800 seconds = 7 days)
MAX_PRESIGNED_URL_EXPIRATION=604800

AWS IAM Permissions

The server requires the following IAM permissions:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "s3:ListBucket",
        "s3:GetObject",
        "s3:PutObject",
        "s3:DeleteObject"
      ],
      "Resource": [
        "arn:aws:s3:::your-bucket-name",
        "arn:aws:s3:::your-bucket-name/*"
      ]
    }
  ]
}

For versioned buckets, also add:

{
  "Effect": "Allow",
  "Action": [
    "s3:DeleteObjectVersion",
    "s3:GetObjectVersion"
  ],
  "Resource": "arn:aws:s3:::your-bucket-name/*"
}

Security Best Practices

Presigned URLs

  • Use short expiration times for sensitive data (minutes, not hours)

  • Monitor URL generation in CloudTrail logs

  • Validate bucket policies to prevent unauthorized presigned URL generation

  • Consider VPC endpoints for private S3 access

AWS Credentials

  • Never commit credentials to version control

  • Use IAM roles in production (EC2, ECS, Lambda)

  • Rotate access keys regularly

  • Use least privilege IAM permissions

  • Enable MFA for sensitive operations

Data Protection

  • Enable encryption by default (use server_side_encryption parameter)

  • Enable versioning for important buckets

  • Configure lifecycle policies for automated data management

  • Enable access logging for audit trails

Troubleshooting

Common Issues

Issue: ImportError: No module named 'fastmcp'

  • Solution: Run pip install -e . to install dependencies

Issue: NoCredentialsError: Unable to locate credentials

  • Solution: Configure AWS credentials using aws configure or environment variables

Issue: AccessDenied: Access Denied

  • Solution: Verify IAM permissions for the S3 operations you're attempting

Issue: NoSuchBucket: The specified bucket does not exist

  • Solution: Verify bucket name and region configuration

Issue: Presigned URL returns 403 Forbidden

  • Solution: Check that:

    • Required headers are included (for PUT operations)

    • URL hasn't expired

    • Bucket policy allows the operation

Debugging

Enable debug logging:

import logging
logging.basicConfig(level=logging.DEBUG)

Contributing

Contributions are welcome! Please:

  1. Fork the repository

  2. Create a feature branch

  3. Make your changes with tests

  4. Run code quality checks (black, ruff, pytest)

  5. Submit a pull request

License

This project is licensed under the MIT License.

Support

For issues, questions, or contributions:

  • Open an issue on GitHub

  • Check existing issues for solutions

  • Review AWS S3 documentation for API-specific questions

Available Tools

4 tools
s3_delete_objectDelete S3 ObjectA
DestructiveIdempotent

Delete an object from an S3 bucket.

⚠️ WARNING: This is a DESTRUCTIVE operation. Deleted objects cannot be recovered unless versioning is enabled on the bucket.

Use this tool to:

  • Remove unwanted or obsolete files

  • Clean up temporary uploads

  • Delete specific versions in versioned buckets

Args: bucket_name: S3 bucket name key: Object key to delete (e.g., 'temp/old-file.txt') version_id: Specific version to delete (for versioned buckets only) response_format: Output format - 'markdown' (default) or 'json'

Returns: Deletion confirmation with version information if applicable. For versioned buckets, indicates if a delete marker was created.

Behavior: - Non-versioned buckets: Object is permanently deleted - Versioned buckets: Delete marker created (object can be recovered) - With version_id: Specific version permanently deleted

Security Notes: - Requires s3:DeleteObject IAM permission - For versioned buckets, may need s3:DeleteObjectVersion - Consider enabling MFA Delete for added protection - Operation cannot be undone for non-versioned buckets

Error Handling: - Bucket/object not found: Returns error (idempotent - safe to retry) - Access denied: Returns error with IAM permission guidance - Invalid parameters: Returns validation error with corrections

Inputs: key (required), bucket_name (required), version_id, response_format. Returns: result

s3_get_objectGenerate Presigned URL for DownloadA
Read-onlyIdempotent

Generate a time-limited presigned URL for downloading an S3 object.

This tool creates a secure URL that allows downloading an object without AWS credentials. The URL is time-limited and automatically expires.

Use cases:

  • Share files with users who don't have AWS access

  • Download objects in browser or HTTP client

  • Integrate S3 downloads in applications without AWS SDK

Args: bucket_name: S3 bucket name key: Object key (path within bucket, e.g., 'data/report.pdf') expires_in: URL expiration in seconds (1-604800, default: 3600 = 1 hour) response_content_disposition: Override Content-Disposition (e.g., 'attachment; filename=report.pdf') response_content_type: Override Content-Type (e.g., 'application/pdf') response_format: Output format - 'markdown' (default) or 'json'

Returns: Presigned URL with expiration details and usage example (curl command).

Security Notes: - URLs are time-limited (max 7 days, default 1 hour) - Anyone with the URL can download during validity period - URLs cannot be revoked before expiration - Use shorter expiration for sensitive data

Error Handling: - Bucket/object not found: Returns error with verification suggestions - Access denied: Returns error with IAM permission guidance - Invalid parameters: Returns validation error with field details

Inputs: key (required), bucket_name (required), expires_in, response_format, +2 more. Returns: result

s3_list_objectsList S3 Bucket ObjectsA
Read-onlyIdempotent

List objects in an S3 bucket with optional prefix filtering and pagination.

This tool retrieves a list of objects (files) from an S3 bucket. Use it to:

  • Browse bucket contents

  • Find specific files by prefix

  • Paginate through large result sets

Args: bucket_name: S3 bucket name (3-63 characters, lowercase, numbers, hyphens, dots) prefix: Filter objects by key prefix (e.g., 'logs/2024/' to find all logs from 2024) limit: Max objects to return per request (1-1000, default: 20) continuation_token: Token from previous response to get next page response_format: Output format - 'markdown' (default) or 'json'

Returns: Formatted list of objects with key, size, last modified date, and storage class. If more results exist, includes continuation token for next page.

Error Handling: - Bucket not found: Returns error with suggestion to verify bucket name - Access denied: Returns error with IAM permission suggestions - Invalid input: Returns validation error with specific field issues

Inputs: bucket_name (required), limit, prefix, response_format, +1 more. Returns: result

s3_put_objectGenerate Presigned URL for UploadA

Generate a time-limited presigned URL for uploading an object to S3.

This tool creates a secure URL that allows uploading a file without AWS credentials. The URL is time-limited and enforces specified upload parameters (encryption, ACL, etc.).

Use cases:

  • Allow users to upload files directly to S3 from browsers

  • Integrate uploads in applications without AWS SDK

  • Enforce upload policies (encryption, content type, etc.)

Args: bucket_name: S3 bucket name key: Destination object key (path, e.g., 'uploads/document.pdf') expires_in: URL expiration in seconds (1-604800, default: 3600 = 1 hour) content_type: MIME type (e.g., 'image/png', 'application/pdf') server_side_encryption: Encryption algorithm ('AES256' or 'aws:kms') metadata: Custom metadata as key-value pairs acl: Access control ('private', 'public-read', 'public-read-write', etc.) response_format: Output format - 'markdown' (default) or 'json'

Returns: Presigned URL with required headers and curl usage example. The response includes all headers that must be sent with the PUT request.

Security Notes: - URLs are time-limited and scoped to specific object key - Enforce encryption with server_side_encryption parameter - Use 'private' ACL unless public access required - Consider bucket policies that require encryption

Error Handling: - Bucket not found: Returns error with bucket verification guidance - Access denied: Returns error with IAM permission details - Invalid parameters: Returns validation errors with corrections

Inputs: key (required), bucket_name (required), acl, metadata, +4 more. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.5/5.0

    Scored across 4 tools

    Disambiguation5/5

    Each tool maps to a clearly distinct operation: upload URL, download URL, listing, and deletion. The only mild surprise is that s3_put_object/s3_get_object issue presigned URLs rather than performing the transfer, but the descriptions state this explicitly and no two tools can be confused.

    Naming Consistency5/5

    All tools use a consistent s3_ prefix with snake_case verb_noun naming (put/get/delete_object, list_objects). The singular/plural difference reflects single-object vs collection semantics rather than an inconsistency.

    Tool Count4/5

    Four tools is a well-scoped, focused set for presigned-URL-centric workflows and each earns its place. However, S3's surface is broad enough that the set feels slightly under-provisioned (no bucket operations, no head/metadata, no multipart).

    Completeness3/5

    Read, list, upload-URL, and delete are covered, but there is no head_object to check existence/metadata, no copy or metadata-update operation, no multipart upload for large files, and no bucket-level operations. Agents will hit dead ends for rename/update or existence-check workflows.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables interaction with S3-compatible storage services like AWS S3 and Cloudflare R2, supporting bucket management, object listing, reading, uploading, and deletion operations.
      5
      ISC
    • A
      license
      Not graded
      quality
      F
      maintenance
      Enables interaction with AWS S3 through MCP, supporting bucket and object management, lifecycle configurations, tagging, policies, CORS settings, presigned URLs, and file uploads/downloads.
      3
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables interaction with AWS S3 storage through bucket operations (create, delete, list), object management (upload, download, delete, list), and bucket policy configuration using AWS credentials.
      23 npm
      2
      MIT