MCP S3 File Uploader - A Model Context Protocol server for S3 uploads
Project description
MCP S3 File Uploader (mcp-s3)
A Model Context Protocol (MCP) server that provides secure file upload functionality to Amazon S3 with progress tracking and presigned URL generation.
๐ Features
- Secure S3 Upload: Upload files to AWS S3 with automatic UUID-based naming
- Progress Tracking: Real-time upload progress for large files (>100MB uses multipart upload)
- Presigned URLs: Generate time-limited access URLs for uploaded files
- Path Security: Prevents directory traversal attacks with safe path joining
- Environment Configuration: Supports both CLI arguments and
.envfile configuration - FastMCP Integration: Built with FastMCP framework for optimal MCP compatibility
- Modern Python Support: Full support for
uvanduvxpackage managers - Multiple Execution Methods: Run with traditional Python, uv, uvx, or direct script execution
๐ Prerequisites
- Python 3.10+
- AWS account with S3 access
- Valid AWS credentials (Access Key ID and Secret Access Key)
- An S3 bucket for file storage
โก Quick Start
1. Choose Your Installation Method
Method 1: Using uv (Recommended)
# Install dependencies and run
uv run python mcp_s3.py --root ~/mcp-uploads
# Or install the package and use the script
uv pip install -e .
uv run mcp-s3 --root ~/mcp-uploads
Method 2: Using uvx (Isolated Environment)
# Run directly from current directory
uvx --from . mcp-s3 --root ~/mcp-uploads
# Or if published to PyPI
uvx mcp-s3 --root ~/mcp-uploads
Method 3: Traditional Python
# With conda environment
conda activate your-env
python mcp_s3.py --root ~/mcp-uploads
# With pip/venv
pip install -r requirements.txt
python mcp_s3.py --root ~/mcp-uploads
Method 4: Direct Script Execution
# Make executable and run
chmod +x mcp_s3.py
./mcp_s3.py --root ~/mcp-uploads
2. Configure AWS Credentials
Create a .env file in the project root:
# AWS Credentials
AWS_ACCESS_KEY_ID=your_access_key_here
AWS_SECRET_ACCESS_KEY=your_secret_key_here
AWS_DEFAULT_REGION=us-east-1
# S3 Configuration
S3_BUCKET_NAME=your_bucket_name_here
3. Test Your Setup
# Test AWS connection
python test_aws_connection.py
# Or with uv
uv run python test_aws_connection.py
4. Run the MCP Server
# Basic usage (recommended)
uv run python mcp_s3.py --root ~/mcp-uploads
# With custom bucket
uv run python mcp_s3.py --root ~/mcp-uploads --bucket my-custom-bucket
# Using uvx for isolation
uvx --from . mcp-s3 --root ~/mcp-uploads
# Traditional Python
python mcp_s3.py --root ~/mcp-uploads
๐ง MCP Integration
Cursor IDE Setup
Using uv (Recommended)
Add this configuration to your ~/.cursor/mcp.json:
{
"mcpServers": {
"mcp-s3": {
"command": "uv",
"args": ["run", "python", "/path/to/mcp_s3.py", "--root", "/path/to/uploads"],
"env": {
"AWS_ACCESS_KEY_ID": "your_access_key",
"AWS_SECRET_ACCESS_KEY": "your_secret_key",
"AWS_DEFAULT_REGION": "us-east-1",
"S3_BUCKET_NAME": "your_bucket_name"
}
}
}
}
Using uvx (Isolated Environment)
{
"mcpServers": {
"mcp-s3": {
"command": "uvx",
"args": ["--from", "/path/to/project", "python", "mcp_s3.py", "--root", "/path/to/uploads"],
"env": {
"AWS_ACCESS_KEY_ID": "your_access_key",
"AWS_SECRET_ACCESS_KEY": "your_secret_key",
"S3_BUCKET_NAME": "your_bucket_name"
}
}
}
}
Traditional Python
{
"mcpServers": {
"mcp-s3": {
"transport": "stdio",
"command": "/path/to/python",
"args": [
"/path/to/mcp_s3.py",
"--root",
"/path/to/upload/directory"
],
"env": {
"AWS_ACCESS_KEY_ID": "your_access_key",
"AWS_SECRET_ACCESS_KEY": "your_secret_key",
"AWS_DEFAULT_REGION": "us-east-1",
"S3_BUCKET_NAME": "your_bucket_name"
}
}
}
}
Claude Desktop Setup
Add to your Claude Desktop MCP configuration:
{
"mcpServers": {
"s3-uploader": {
"command": "python",
"args": [
"/path/to/mcp_s3.py",
"--bucket", "your-bucket-name",
"--root", "/path/to/uploads"
]
}
}
}
๐ ๏ธ Available Tools
upload_file
Upload a local file to S3 and return a presigned URL.
Parameters:
local_path(string, required): Path to the file relative to the configured root directoryexpires_in(integer, optional): URL expiration time in seconds (default: 86400 = 24 hours)
Returns:
url: Presigned URL for accessing the uploaded filesize: File size in bytesmime_type: Detected MIME type of the files3_key: Generated S3 object key (UUID + file extension)
Example Usage in MCP Client:
@mcp-s3 upload the document.pdf file with 2-hour expiration
๐ File Structure
mcp-s3/
โโโ mcp_s3.py # Main MCP server
โโโ pyproject.toml # Modern Python project configuration
โโโ requirements.txt # Python dependencies (legacy)
โโโ __main__.py # Module entry point
โโโ test_aws_connection.py # AWS credentials tester
โโโ test_mcp_server.py # MCP server functionality test
โโโ test_with_progress.py # Progress tracking test
โโโ test_execution_methods.py # Test all execution methods
โโโ generate_mcp_config.py # Generate Cursor MCP config
โโโ setup_s3_bucket.py # S3 bucket setup script
โโโ .env # AWS credentials (create from env_example.txt)
โโโ env_example.txt # Environment variables template
โโโ USAGE.md # Detailed usage guide
โโโ AWS_SETUP_GUIDE.md # AWS setup instructions
โโโ README.md # This file
๐ Security Features
- Path Traversal Protection: Prevents access to files outside the configured root directory
- Presigned URLs: Time-limited access to uploaded files without exposing AWS credentials
- Environment Variables: Sensitive credentials stored in
.envfile (not committed to git) - UUID File Naming: Prevents filename collisions and adds obscurity
๐ Progress Tracking
- Small Files (<100MB): Progress reported at key milestones (0%, 25%, 90%, 100%)
- Large Files (โฅ100MB): Multipart upload with detailed progress per chunk
- Real-time Updates: MCP clients receive progress notifications during upload
๐งช Testing
Test AWS Connection
# Traditional Python
python test_aws_connection.py
# With uv
uv run python test_aws_connection.py
Test MCP Server
# Traditional Python
python test_mcp_server.py
# With uv
uv run python test_mcp_server.py
Test with Progress Tracking
# Traditional Python
python test_with_progress.py
# With uv
uv run python test_with_progress.py
Test All Execution Methods
# Verify all installation methods work
python test_execution_methods.py
๐จ Troubleshooting
Common Issues
-
Missing Dependencies
# With uv uv sync # Install all dependencies # Traditional pip pip install -r requirements.txt
-
"Missing required environment variables"
- Ensure your
.envfile exists and contains all required AWS credentials - Check your
.envfile format matches the example
- Ensure your
-
AWS Credentials Not Found
- Check your
.envfile - Verify AWS CLI configuration:
aws configure list - Ensure environment variables are properly loaded
- Check your
-
"File not found"
- Check that the file exists in the configured root directory
- Verify the file path is relative to the root directory
-
"Access denied to bucket"
- Verify your AWS credentials have S3 permissions
- Ensure the bucket name is correct and exists
- Check S3 bucket policies and IAM permissions
-
"Path escapes allowed root"
- File path must be within the configured root directory
- Use relative paths only (no
../traversal)
-
Permission Denied
- Ensure the upload directory exists and is writable
- Check file system permissions
-
Port Already in Use
- The server uses stdio transport, no port conflicts should occur
- If using a different transport, check for port conflicts
๐ Configuration Options
CLI Arguments
--bucket: S3 bucket name (overrides environment variable)--root: Root directory for file uploads (required)
Environment Variables
AWS_ACCESS_KEY_ID: AWS access keyAWS_SECRET_ACCESS_KEY: AWS secret access keyAWS_DEFAULT_REGION: AWS region (default: us-east-1)S3_BUCKET_NAME: Target S3 bucket name
๐ค Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Test with
python test_mcp_server.py - Submit a pull request
๐ License
This project is open source. Please ensure you comply with AWS terms of service when using S3.
๐ Additional Resources
- Model Context Protocol (MCP)
- FastMCP Framework | Documentation
- UV Package Manager - Fast Python package installer
- AWS S3 Documentation
- Cursor IDE
- Detailed Usage Guide
- AWS Setup Guide
Built with โค๏ธ using FastMCP for seamless LLM integration
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_s3-1.0.0.tar.gz.
File metadata
- Download URL: mcp_s3-1.0.0.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dcdab044e09214506d53dcfeaf64b8974bd0b5ecb69d840b234868ed499a5269
|
|
| MD5 |
9773316f72d9090e0c0e2f72cc8d6b83
|
|
| BLAKE2b-256 |
8cb842d6006beda9fb96568808dbe3f9b40fd39cfc4e9db599413035472b767b
|
File details
Details for the file mcp_s3-1.0.0-py3-none-any.whl.
File metadata
- Download URL: mcp_s3-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53c6f2ead0be9492feb1e26f910f50218385ef7113824141c54da79dba6f4720
|
|
| MD5 |
d7c4c33c57dad84e7621e69ad50a4ef4
|
|
| BLAKE2b-256 |
9af39f6ea7258136d9492e9d514b76be1bed2987eb006b9f088e48b525433b00
|