Skip to main content
Glama
Desmond-Labs

Supabase Storage MCP

by Desmond-Labs

list_files

Enumerate files in a Supabase Storage bucket folder to identify available files for processing or download, with optional filtering by extension.

Instructions

Enumerate files in bucket folder for processing or download

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bucket_nameYesBucket to search
folder_pathNoSpecific folder path
file_extensionNoFilter by extension (.jpg, .png)

Implementation Reference

  • The handleListFiles function that executes the tool logic: lists files from a Supabase storage bucket optionally filtered by folder and extension, computes summary stats, performs audit logging, and returns structured response.
    async function handleListFiles(args: any, requestId: string, startTime: number) { const { bucket_name, folder_path, file_extension } = args; const inputHash = generateSecureHash(JSON.stringify({ bucket_name, folder_path, file_extension })); try { const { data, error } = await supabase.storage .from(bucket_name) .list(folder_path || '', { limit: 1000, sortBy: { column: 'name', order: 'asc' } }); if (error) { throw new Error(`Failed to list files: ${error.message}`); } let files = data || []; // Filter by file extension if specified if (file_extension) { files = files.filter(file => file.name.toLowerCase().endsWith(file_extension.toLowerCase())); } const totalSize = files.reduce((sum, file) => sum + (file.metadata?.size || 0), 0); auditRequest('list_files', true, inputHash); const result: FileListResult = { files: files.map(file => ({ name: file.name, path: folder_path ? `${folder_path}/${file.name}` : file.name, size: file.metadata?.size || 0, mime_type: file.metadata?.mimetype || 'unknown', last_modified: file.updated_at || file.created_at || new Date().toISOString(), metadata: file.metadata })), total_count: files.length, total_size: totalSize }; return { content: [ { type: 'text', text: JSON.stringify({ ...result, request_id: requestId, processing_time: Date.now() - startTime }, null, 2) } ] }; } catch (error) { auditRequest('list_files', false, inputHash, getErrorMessage(error)); throw error; } }
  • src/index.ts:178-204 (registration)
    Registration of the 'list_files' tool in the ListToolsRequestSchema handler, including name, description, and input schema.
    { name: 'list_files', description: 'Enumerate files in bucket folder for processing or download', inputSchema: { type: 'object', properties: { bucket_name: { type: 'string', description: 'Bucket to search', minLength: 3, maxLength: 63 }, folder_path: { type: 'string', description: 'Specific folder path', maxLength: 300 }, file_extension: { type: 'string', description: 'Filter by extension (.jpg, .png)', maxLength: 10 } }, required: ['bucket_name'], additionalProperties: false } },
  • src/index.ts:473-474 (registration)
    Dispatch/registration case in the main CallToolRequestSchema switch statement that routes to the handleListFiles handler.
    case 'list_files': return await handleListFiles(args, requestId, startTime);
  • Input schema definition for the list_files tool validating bucket_name (required), optional folder_path and file_extension.
    inputSchema: { type: 'object', properties: { bucket_name: { type: 'string', description: 'Bucket to search', minLength: 3, maxLength: 63 }, folder_path: { type: 'string', description: 'Specific folder path', maxLength: 300 }, file_extension: { type: 'string', description: 'Filter by extension (.jpg, .png)', maxLength: 10 } }, required: ['bucket_name'], additionalProperties: false

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