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
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions 'Enumerate files' which implies a read operation, but doesn't specify whether this is paginated, what format results return, if there are rate limits, or authentication requirements. For a tool with 3 parameters and no annotation coverage, this leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that communicates the core purpose without unnecessary words. It's appropriately sized for a listing tool and front-loads the essential information. Every word earns its place in this concise formulation.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 3 parameters, no annotations, and no output schema, the description is insufficiently complete. It doesn't explain what the enumeration returns (list of filenames? metadata?), doesn't mention pagination for large result sets, and provides minimal behavioral context. Given the complexity and lack of structured data, more completeness is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema - it doesn't explain how parameters interact or provide usage examples. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Enumerate files') and target ('in bucket folder'), specifying the purpose as listing files for processing or download. It distinguishes from siblings like download_file or upload_image_batch by focusing on enumeration rather than file manipulation. However, it doesn't explicitly differentiate from batch_download or get_file_url in terms of scope.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description mentions 'for processing or download' which implies usage context, but provides no explicit guidance on when to use this tool versus alternatives like batch_download or get_file_url. There are no when-not-to-use statements or clear prerequisites, leaving the agent to infer appropriate usage scenarios.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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