Skip to main content
Glama
gemini-dk

Firebase MCP Server

by gemini-dk

storage_list_files

List files from a specified directory path in Firebase Storage to view available stored objects.

Instructions

List files in a given path in Firebase Storage

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
directoryPathNoThe optional path to list files from. If not provided, the root is used.

Implementation Reference

  • Core handler function implementing the storage_list_files tool logic: lists files and directories in Firebase Storage bucket with pagination, generates signed URLs for files and console links for directories, returns JSON-formatted result.
    export async function listDirectoryFiles(path?: string, pageSize: number = 10, pageToken?: string): Promise<{ content: { type: string , text: string }[] }> {
      const prefix = path ? (path === '' ? '' : (path.endsWith('/') ? path : `${path}/`)) : '';
      const [files, , apiResponse] = await admin.storage().bucket().getFiles({ 
        prefix, 
        delimiter: '/', 
        maxResults: pageSize,
        pageToken
      });
      const nextPageToken = apiResponse.nextPageToken as string || undefined;
    
      const fileNames = await Promise.all(files.map(async (file) => {
        const [signedUrl] = await file.getSignedUrl({
          action: 'read',
          expires: Date.now() + 1000 * 60 * 60 // 1 hour
        });
        return { type: "file", name: file.name, downloadURL: signedUrl };
      }));
    
      const projectId = getProjectId();
      const bucketName = admin.storage().bucket().name;
      const directoryNames = (apiResponse.prefixes || []).map((prefix:string) => {    
        //const encodedPrefix = encodeURIComponent(prefix).replace(/'/g, '%27').replace(/%20/g, '+');
        const tmpPrefix = prefix.replace(/\/$/, '');
        const encodedPrefix = `~2F${tmpPrefix.replace(/\//g, '~2F')}`;
        const consoleUrl = `https://console.firebase.google.com/project/${projectId}/storage/${bucketName}/files/${encodedPrefix}`;
        return { type: "directory", name: prefix, url: consoleUrl };
      });
    
        const result = { 
          nextPageToken: nextPageToken, 
          files: [...fileNames, ...directoryNames],
          hasMore: nextPageToken !== undefined
        };
      return {
        content:[
          {
            type: "text",
            text: JSON.stringify(result,null,2)
          }
        ]
      }
    }
  • Input schema definition for the storage_list_files tool, specifying optional directoryPath parameter.
      "name": "storage_list_files",
      "description": "List files in a given path in Firebase Storage",
      "inputSchema": {
        "type": "object",
        "properties": {
          "directoryPath": {
            "type": "string",
            "description": "The optional path to list files from. If not provided, the root is used."
          }
        },
        "required": []
      }
    },
  • src/index.ts:252-257 (registration)
    Tool dispatch/registration in the main switch handler for CallToolRequestSchema, invoking the listDirectoryFiles implementation.
    case 'storage_list_files':
      return listDirectoryFiles(
        args.directoryPath as string | undefined,
        args.pageSize as number | undefined,
        args.pageToken as string | undefined
      );
  • src/index.ts:37-224 (registration)
    Registration of the tool in the ListToolsRequestSchema response, including it in the list of available tools.
        {
          name: 'firestore_add_document',
          description: 'Add a document to a Firestore collection',
          inputSchema: {
            type: 'object',
            properties: {
              collection: {
                type: 'string',
                description: 'Collection name'
              },
              data: {
                type: 'object',
                description: 'Document data'
              }
            },
            required: ['collection', 'data']
          }
        },
        {
          name: 'firestore_list_collections',
          description: 'List collections in Firestore. If documentPath is provided, returns subcollections under that document; otherwise returns root collections.',
          inputSchema: {
            type: 'object',
            properties: {
            documentPath: {
              type: 'string',
              description: 'Optional parent document path'
            },
            limit: {
              type: 'number',
              description: 'Number of collections to return',
              default: 20
            },
            pageToken: {
              type: 'string',
              description: 'Token for pagination to get the next page of results'
            }
            },
            required: []
          }
        },
        {
          name: 'firestore_list_documents',
          description: 'List documents from a Firestore collection with optional filtering',
          inputSchema: {
            type: 'object',
            properties: {
              collection: {
                type: 'string',
                description: 'Collection name'
              },
              filters: {
                type: 'array',
                description: 'Array of filter conditions',
                items: {
                  type: 'object',
                  properties: {
                    field: {
                      type: 'string',
                      description: 'Field name to filter'
                    },
                    operator: {
                      type: 'string',
                      description: 'Comparison operator'
                    },
                    value: {
                      type: 'any',
                      description: 'Value to compare against (use ISO format for dates)'
                    }
                  },
                  required: ['field', 'operator', 'value']
                }
              },
            limit: {
              type: 'number',
              description: 'Number of documents to return',
              default: 20
            },
            pageToken: {
              type: 'string',
              description: 'Token for pagination to get the next page of results'
            }
            },
            required: ['collection']
          }
        },
        {
          name: 'firestore_get_document',
          description: 'Get a document from a Firestore collection',
          inputSchema: {
            type: 'object',
            properties: {
              collection: {
                type: 'string',
                description: 'Collection name'
              },
              id: {
                type: 'string',
                description: 'Document ID'
              }
            },
            required: ['collection', 'id']
          }
        },
        {
          name: 'firestore_update_document',
          description: 'Update a document in a Firestore collection',
          inputSchema: {
            type: 'object',
            properties: {
              collection: {
                type: 'string',
                description: 'Collection name'
              },
              id: {
                type: 'string',
                description: 'Document ID'
              },
              data: {
                type: 'object',
                description: 'Updated document data'
              }
            },
            required: ['collection', 'id', 'data']
          }
        },
        {
          name: 'firestore_delete_document',
          description: 'Delete a document from a Firestore collection',
          inputSchema: {
            type: 'object',
            properties: {
              collection: {
                type: 'string',
                description: 'Collection name'
              },
              id: {
                type: 'string',
                description: 'Document ID'
              }
            },
            required: ['collection', 'id']
          }
        },
        {
          name: "auth_get_user",
          description: "Get a user by ID or email from Firebase Authentication",
          inputSchema: {
            type: "object",
            properties: {
              identifier: {
                type: "string",
                description: "User ID or email address"
              }
            },
            required: ["identifier"]
          }
        },
        {
          "name": "storage_list_files",
          "description": "List files in a given path in Firebase Storage",
          "inputSchema": {
            "type": "object",
            "properties": {
              "directoryPath": {
                "type": "string",
                "description": "The optional path to list files from. If not provided, the root is used."
              }
            },
            "required": []
          }
        },
        {
          "name": "storage_get_file_info",
          "description": "Get file information including metadata and download URL",
          "inputSchema": {
            "type": "object",
            "properties": {
              "filePath": {
                "type": "string",
                "description": "The path of the file to get information for"
              }
            },
            "required": ["filePath"]
          }
        }
        ]
    }));
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool lists files but doesn't mention behavioral traits like pagination, rate limits, authentication needs, or what happens if the path is invalid. This leaves significant gaps in understanding how the tool behaves beyond its basic function.

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 directly states the tool's purpose without any wasted words. It is appropriately sized and front-loaded, making it easy to parse quickly.

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?

Given the lack of annotations and output schema, the description is incomplete. It doesn't address key contextual aspects like return format, error handling, or how it fits with sibling tools, leaving the agent with insufficient information for effective use in a complex environment.

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?

The input schema has 100% description coverage, with the parameter 'directoryPath' well-documented in the schema itself. The description adds no additional meaning beyond the schema, such as path format examples or constraints, so it meets the baseline score without compensating further.

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 ('List files') and the resource ('in a given path in Firebase Storage'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'storage_get_file_info', which might also involve file operations, so it doesn't reach the highest score.

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 provides no guidance on when to use this tool versus alternatives, such as 'storage_get_file_info' or other sibling tools. It lacks context about use cases, prerequisites, or exclusions, leaving the agent without clear usage instructions.

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/gemini-dk/mcp-server-firebase'

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