Supabase Storage MCP

Supabase Storage MCP

Enables secure file and bucket management operations with Supabase Storage through enterprise-grade security features, batch uploads/downloads, and comprehensive file management capabilities. Supports both local file paths and base64 data with advanced transformations and auto-download functionality.

Category
访问服务器

README

Supabase Storage MCP

A secure, production-ready Model Context Protocol (MCP) server for Supabase Storage with advanced security features, batch operations, and comprehensive file management.

Features

🛡️ Enterprise-Grade Security

  • Multi-layer Defense: Rate limiting, threat detection, and audit logging
  • Input Validation: Comprehensive validation with Zod schemas and DOMPurify sanitization
  • Real-time Monitoring: Security metrics and alert system
  • Path Traversal Prevention: Advanced protection against directory traversal attacks
  • File Type Validation: MIME type verification and file signature checking

🗂️ Bucket Management

  • Secure Bucket Creation: Create storage buckets with security validation
  • Organized Structure: Automated folder organization for scalable workflows
  • Batch Setup: Initialize multiple buckets with consistent configuration

🖼️ Advanced File Operations

  • Batch Upload: Upload 1-500 files with progress tracking and detailed reporting
  • Dual Input Support: Handle both local file paths and base64 data (Claude Desktop compatible)
  • File Validation: Size limits, MIME type checking, and signature verification
  • Transform on Download: Resize, compress, and format images during download
  • Auto-Download System: Generate JavaScript code for browser downloads

📁 File Management

  • Secure Downloads: Time-limited signed URLs with access controls
  • Batch Operations: Process multiple files efficiently
  • Advanced Search: Filter by extension, folder, and metadata
  • Custom Filenames: Override default names during download

🔗 Auto-Download Features

  • Intelligent Triggers: Automatic browser downloads with custom filenames
  • Batch Downloads: Sequential downloads with configurable delays
  • JavaScript Generation: Ready-to-use browser scripts
  • Multiple Formats: Support for signed URLs, base64, and binary data

Installation

Prerequisites

  • Node.js >= 18.0.0
  • npm >= 8.0.0
  • Supabase project with Storage enabled

Setup

  1. Clone and install dependencies:
git clone https://github.com/your-username/supabase-storage-mcp.git
cd supabase-storage-mcp
npm install
  1. Configure environment variables:
cp .env.example .env

Edit .env with your Supabase credentials:

SUPABASE_URL=https://your-project-id.supabase.co
SUPABASE_SERVICE_KEY=your-service-role-key
NODE_ENV=production
  1. Build the project:
npm run build
  1. Start the MCP server:
npm start

Configuration

Claude Desktop Integration

Add to your Claude Desktop configuration (claude_desktop_config.json):

{
  "mcpServers": {
    "supabase-storage": {
      "command": "node",
      "args": ["/path/to/supabase-storage-mcp/dist/index.js"],
      "description": "Supabase Storage MCP for file and bucket management"
    }
  }
}

Environment Variables

Variable Required Description Default
SUPABASE_URL Your Supabase project URL -
SUPABASE_SERVICE_KEY Your Supabase service role key -
NODE_ENV Environment mode development
LOG_LEVEL Logging verbosity info

Security Configuration

The server includes comprehensive security features enabled by default:

  • Rate limiting (100 requests per minute globally)
  • File size limits (50MB per file, 500 files per batch)
  • MIME type restrictions (images only by default)
  • Path traversal protection
  • Input sanitization

Usage

Basic Bucket Operations

// Create a storage bucket
await mcp.call('create_bucket', {
  bucket_name: 'my-images',
  is_public: false
});

// Setup standard bucket structure
await mcp.call('setup_buckets', {
  base_bucket_name: 'storage',
  user_id: 'user123'
});

File Upload

// Upload multiple images (file paths)
await mcp.call('upload_image_batch', {
  bucket_name: 'storage-images',
  batch_id: 'batch001',
  folder_prefix: 'original',
  user_id: 'user123',
  image_paths: ['/path/to/image1.jpg', '/path/to/image2.png']
});

// Upload with base64 data (Claude Desktop compatible)
await mcp.call('upload_image_batch', {
  bucket_name: 'storage-images',
  batch_id: 'batch002', 
  folder_prefix: 'original',
  user_id: 'user123',
  image_data: [
    {
      filename: 'image1.jpg',
      content: 'data:image/jpeg;base64,/9j/4AAQSkZJRg...',
      mime_type: 'image/jpeg'
    }
  ]
});

File Management

// List files in a bucket
await mcp.call('list_files', {
  bucket_name: 'storage-images',
  folder_path: 'original/user123',
  file_extension: '.jpg'
});

// Generate signed download URLs  
await mcp.call('get_file_url', {
  bucket_name: 'storage-images',
  storage_path: 'original/user123/batch001/image1.jpg',
  expires_in: 3600
});

// Batch signed URLs
await mcp.call('create_signed_urls', {
  bucket_name: 'storage-images',
  file_paths: ['path1.jpg', 'path2.png'],
  expires_in: 1800
});

Advanced Downloads

// Download with auto-trigger
await mcp.call('download_file_with_auto_trigger', {
  bucket_name: 'storage-images',
  file_path: 'original/user123/image1.jpg',
  return_format: 'base64',
  auto_download: true,
  custom_filename: 'my-image.jpg'
});

// Batch download with auto-trigger
await mcp.call('batch_download', {
  bucket_name: 'storage-images', 
  file_paths: ['image1.jpg', 'image2.png'],
  return_format: 'signed_url',
  auto_download: true,
  download_delay: 1000
});

Image Transformations

// Download with transformations
await mcp.call('download_file', {
  bucket_name: 'storage-images',
  file_path: 'original/image1.jpg',
  return_format: 'base64',
  transform_options: {
    width: 800,
    height: 600, 
    quality: 85
  }
});

Security Monitoring

// Get security status
await mcp.call('get_security_status', {});

API Reference

Tools

Tool Name Description
create_bucket Create a new storage bucket
setup_buckets Initialize standard bucket structure
upload_image_batch Upload multiple files with validation
list_files List files in bucket with filtering
get_file_url Generate signed download URL
create_signed_urls Generate multiple signed URLs
download_file Download file content with transformations
download_file_with_auto_trigger Download with auto-download JavaScript
batch_download Download multiple files with auto-trigger
get_security_status Get security metrics and status

File Organization

The server automatically organizes uploaded files in a structured format:

bucket-name/
├── original/
│   └── {user_id}/
│       └── {batch_id}/
│           ├── image1.jpg
│           └── image2.png
└── processed/
    └── {user_id}/
        └── {batch_id}/
            ├── thumb_image1.jpg  
            └── optimized_image2.png

Security

Built-in Protections

  • Rate Limiting: Prevents API abuse
  • Input Validation: Sanitizes all inputs
  • File Validation: MIME type and signature checking
  • Path Security: Prevents directory traversal
  • Size Limits: Configurable file and batch size limits
  • Audit Logging: Complete operation tracking

Security Best Practices

  • Store your service role key securely
  • Use environment variables for configuration
  • Monitor security logs regularly
  • Keep dependencies updated
  • Use HTTPS in production

Performance

Batch Upload Performance

  • Small batches (1-25 files): ~15-30 seconds
  • Medium batches (26-100 files): ~45-90 seconds
  • Large batches (101-500 files): ~3-8 minutes
  • Parallel uploads: 3 concurrent streams
  • Memory efficient: Streams large files

Download Performance

  • File URL generation: <50ms per URL
  • Direct downloads: 100-500ms per file
  • Batch operations: ~600 files per minute
  • Transform on download: 200-800ms per image

Development

Build

npm run build

Development Mode

npm run dev

Security Audit

npm run security-check

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support


Built with ❤️ for the MCP and Supabase communities.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选