create_bucket
Create a new storage bucket with security validation and audit logging. Specify bucket name and public/private access to organize and secure your Supabase Storage files.
Instructions
Create a new storage bucket with comprehensive security validation and audit logging
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bucket_name | Yes | Name of the bucket to create (3-63 chars, lowercase, alphanumeric with hyphens) | |
| is_public | No | Whether the bucket should be public |
Implementation Reference
- src/index.ts:511-560 (handler)Main handler function for 'create_bucket' tool. Validates input, calls supabase.storage.createBucket, handles errors, audits the request, and returns success response with security info.async function handleCreateBucket(args: any, requestId: string, startTime: number) { const { bucket_name, is_public } = args as { bucket_name: string; is_public?: boolean }; // Input validation if (!bucket_name || typeof bucket_name !== 'string') { throw new Error('Invalid bucket_name parameter'); } const inputHash = generateSecureHash(JSON.stringify({ bucket_name, is_public })); try { const options: any = { public: is_public || false }; const { data, error } = await supabase.storage.createBucket(bucket_name, options); if (error) { throw new Error(`Failed to create bucket: ${error.message}`); } auditRequest('create_bucket', true, inputHash); return { content: [ { type: 'text', text: JSON.stringify({ success: true, message: `Successfully created secure bucket: ${bucket_name}`, bucket_name: data.name, security_configuration: { public: options.public, audit_logging_enabled: true, threat_detection_enabled: true }, request_id: requestId, processing_time: Date.now() - startTime }, null, 2) } ] }; } catch (error) { auditRequest('create_bucket', false, inputHash, getErrorMessage(error)); throw error; } }
- src/index.ts:65-82 (schema)Tool registration and input schema definition for 'create_bucket' in the ListToolsRequestSchema handler. Specifies parameters: bucket_name (required, validated), is_public (optional boolean).{ name: 'create_bucket', description: 'Create a new storage bucket with comprehensive security validation and audit logging', inputSchema: { type: 'object', properties: { bucket_name: { type: 'string', description: 'Name of the bucket to create (3-63 chars, lowercase, alphanumeric with hyphens)', minLength: 3, maxLength: 63, pattern: '^[a-z0-9][a-z0-9\\-]*[a-z0-9]$' }, is_public: { type: 'boolean', description: 'Whether the bucket should be public', default: false } }, required: ['bucket_name'], additionalProperties: false }
- src/index.ts:464-465 (registration)Dispatch/registration in the main CallToolRequestSchema switch statement, routing 'create_bucket' calls to handleCreateBucket function.case 'create_bucket': return await handleCreateBucket(args, requestId, startTime);