Skip to main content
Glama
Desmond-Labs

Supabase Storage MCP

by Desmond-Labs

setup_buckets

Initialize standard storage buckets to organize file management workflows with structured naming conventions.

Instructions

Initialize standard storage buckets for organized file management workflows

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
base_bucket_nameNoBase name for bucketsstorage
user_idNoUser identifier for organization

Implementation Reference

  • The main handler function that implements the setup_buckets tool logic. It creates standard buckets like {base_bucket_name}-images and {base_bucket_name}-exports with security configurations, audits the request, and returns a structured result.
    async function handleSetupBuckets(args: any, requestId: string, startTime: number) {
      const { base_bucket_name = 'storage', user_id } = args;
      
      const inputHash = generateSecureHash(JSON.stringify({ base_bucket_name, user_id }));
      
      try {
        const bucketsToCreate = [
          `${base_bucket_name}-images`,
          `${base_bucket_name}-exports`
        ];
        
        const bucketsCreated: string[] = [];
        
        for (const bucketName of bucketsToCreate) {
          const { data, error } = await supabase.storage.createBucket(bucketName, {
            public: false,
            fileSizeLimit: 50 * 1024 * 1024, // 50MB
            allowedMimeTypes: ['image/jpeg', 'image/png', 'image/webp', 'image/gif']
          });
          
          if (error && !error.message.includes('already exists')) {
            throw new Error(`Failed to create bucket ${bucketName}: ${error.message}`);
          }
          
          bucketsCreated.push(bucketName);
        }
        
        auditRequest('setup_buckets', true, inputHash);
        
        const result: SetupBucketsResult = {
          success: true,
          buckets_created: bucketsCreated,
          message: `Successfully created bucket structure: ${bucketsCreated.join(', ')}`,
          security_configuration: {
            images_bucket: {
              public: false,
              file_size_limit: 50 * 1024 * 1024,
              allowed_mime_types: ['image/jpeg', 'image/png', 'image/webp', 'image/gif'],
              audit_logging_enabled: true,
              threat_detection_enabled: true
            },
            exports_bucket: {
              public: false,
              file_size_limit: 50 * 1024 * 1024,
              allowed_mime_types: ['image/jpeg', 'image/png', 'image/webp', 'image/gif'],
              audit_logging_enabled: true,
              threat_detection_enabled: true
            }
          }
        };
        
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(result, null, 2)
            }
          ]
        };
      } catch (error) {
        auditRequest('setup_buckets', false, inputHash, getErrorMessage(error));
        throw error;
      }
    }
  • src/index.ts:84-106 (registration)
    Tool registration in the ListToolsRequestSchema handler, defining the name, description, and input schema for setup_buckets.
    {
      name: 'setup_buckets',
      description: 'Initialize standard storage buckets for organized file management workflows',
      inputSchema: {
        type: 'object',
        properties: {
          base_bucket_name: {
            type: 'string',
            description: 'Base name for buckets',
            default: 'storage',
            minLength: 3,
            maxLength: 50
          },
          user_id: {
            type: 'string',
            description: 'User identifier for organization',
            maxLength: 36
          }
        },
        required: [],
        additionalProperties: false
      }
    },
  • Type definition for the output/result of the setup_buckets tool, used in the handler for structuring the response.
    export interface SetupBucketsResult {
      success: boolean;
      buckets_created: string[];
      message: string;
      security_configuration: {
        images_bucket: {
          public: boolean;
          file_size_limit: number;
          allowed_mime_types: string[];
          audit_logging_enabled: boolean;
          threat_detection_enabled: boolean;
        };
        exports_bucket: {
          public: boolean;
          file_size_limit: number;
          allowed_mime_types: string[];
          audit_logging_enabled: boolean;
          threat_detection_enabled: boolean;
        };
      };
    }
  • src/index.ts:467-468 (registration)
    Dispatch case in the main CallToolRequestSchema switch statement that routes calls to the setup_buckets handler.
    case 'setup_buckets':
      return await handleSetupBuckets(args, requestId, startTime);

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/Desmond-Labs/supabase-storage-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server