Firebase MCP

Firebase MCP

The Firebase MCP server provides a standardized interface to interact with Firebase services, including Firebase Authentication, Firestore, and Firebase Storage.

gannonh

Databases
Cloud Storage
Visit Server

Tools

firestore_add_document

Add a document to a Firestore collection

firestore_list_collections

List collections in Firestore. If documentPath is provided, returns subcollections under that document; otherwise returns root collections.

firestore_list_documents

List documents from a Firestore collection with optional filtering

firestore_get_document

Get a document from a Firestore collection

firestore_update_document

Update a document in a Firestore collection

firestore_delete_document

Delete a document from a Firestore collection

auth_get_user

Get a user by ID or email from Firebase Authentication

storage_list_files

List files in a given path in Firebase Storage

storage_get_file_info

Get file information including metadata and download URL

README

Firebase MCP Server

Project Logo

<a href="https://glama.ai/mcp/servers/x4i8z2xmrq"> <img width="380" height="200" src="https://glama.ai/mcp/servers/x4i8z2xmrq/badge" alt="Firebase MCP server" /> </a>

Firebase Tests CI

Overview

The Model Context Protocol (MCP) is an open protocol that enables LLM client applications to use tools and access external data sources. This MCP server allows any LLM client that supports the MCP protocol to interact with Firebase services including:

  • Authentication: User management and verification
  • Firestore: Document database operations
  • Storage: File storage and retrieval

The server exposes Firebase services through MCP tools, making them accessible to LLM clients including Claude Desktop, Cursor, Roo Code, and Cline, while handling authentication and connection management.

🔥 New in v1.3.0: Collection Group Queries

Firebase MCP now supports querying sub-collections (collection groups) in Firestore! This allows you to query across all sub-collections with the same name, regardless of their parent document - making it easy to search across your entire database hierarchy with a single query. Perfect for cross-document searches, activity feeds, and unified dashboards.

Setup

The easiest way to install the Firebase MCP server is to simply feed your LLM client (like Cline) the llms-install.md file.

1. Firebase Configuration

  • Go to Firebase Console
  • Navigate to Project Settings > Service Accounts
  • Click "Generate new private key"
  • Save the JSON file securely

2. Environment Variables

The server requires the following environment variables:

  • SERVICE_ACCOUNT_KEY_PATH: Path to your Firebase service account key JSON file (required)
  • FIREBASE_STORAGE_BUCKET: Bucket name for Firebase Storage (optional)
    • If not provided, defaults to [projectId].appspot.com

3. Install MCP Server

Add the server configuration to your MCP settings file:

  • Claude Desktop: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Cursor: [project root]/.cursor/mcp.json
  • Roo Code (VS Code Extension): (~/Library/Application Support/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json)
  • Cline (VS Code Extension): ~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json

MCP Servers can be installed manually or at runtime via npx (recommended). How you install determines your configuration:

Configure for npx

{
  "firebase-mcp": {
    "command": "npx",
    "args": [
      "-y",
      "@gannonh/firebase-mcp"
    ],
    "env": {
      "SERVICE_ACCOUNT_KEY_PATH": "/absolute/path/to/serviceAccountKey.json",
      "FIREBASE_STORAGE_BUCKET": "your-project-id.firebasestorage.app"
    }
  }
}

Configure for local installation

{
  "firebase-mcp": {
    "command": "node",
    "args": [
      "/absolute/path/to/firebase-mcp/dist/index.js"
    ],
    "env": {
      "SERVICE_ACCOUNT_KEY_PATH": "/absolute/path/to/serviceAccountKey.json",
      "FIREBASE_STORAGE_BUCKET": "your-project-id.firebasestorage.app"
    }
  }
}

Manual Installation

Install Dependencies
git clone https://github.com/gannonh/firebase-mcp
cd firebase-mcp
npm install
Build the Project
npm run build

Test your Installation

To make sure everything is working, simply prompt your client: Please run through and test all of your Firebase MCP tools.

Features

Authentication Tools

  • auth_get_user: Get user details by ID or email

    {
      identifier: string // User ID or email address
    }
    

Firestore Tools

  • firestore_add_document: Add a document to a collection

    {
      collection: string,
      data: object
    }
    
  • firestore_list_collections: List available collections

    {
      documentPath?: string, // Optional parent document path
      limit?: number,        // Default: 20
      pageToken?: string     // For pagination
    }
    
  • firestore_list_documents: List documents with optional filtering

    {
      collection: string,
      filters?: Array<{
        field: string,
        operator: string,
        value: any
      }>,
      limit?: number,
      pageToken?: string
    }
    
  • firestore_get_document: Get a specific document

    {
      collection: string,
      id: string
    }
    
  • firestore_update_document: Update an existing document

    {
      collection: string,
      id: string,
      data: object
    }
    
  • firestore_delete_document: Delete a document

    {
      collection: string,
      id: string
    }
    
  • firestore_query_collection_group: Query documents across all sub-collections 🆕

    {
      collectionId: string,       // The collection ID to query across all documents
      filters?: Array<{           // Optional filters
        field: string,
        operator: string,         // ==, !=, <, <=, >, >=, array-contains, array-contains-any, in, not-in
        value: any
      }>,
      orderBy?: Array<{           // Optional fields to order by
        field: string,
        direction?: 'asc' | 'desc' // Default: 'asc'
      }>,
      limit?: number,             // Maximum documents to return (default: 20, max: 100)
      pageToken?: string          // Token for pagination
    }
    

Storage Tools

  • storage_list_files: List files in a directory

    {
      directoryPath?: string, // Optional path, defaults to root
      pageSize?: number,      // Number of items per page, defaults to 10
      pageToken?: string      // Token for pagination
    }
    
  • storage_get_file_info: Get file metadata and download URL

    {
      filePath: string // Path to the file in storage
    }
    

Development

Building

npm run build

Testing

The project uses Vitest for testing. Tests can be run against Firebase emulators to avoid affecting production data.

  1. Install Firebase Emulators

    npm install -g firebase-tools
    firebase init emulators
    
  2. Start Emulators

    firebase emulators:start
    
  3. Run Tests

    npm run test:emulator
    

Architecture

The server is structured into three main components:

src/
├── index.ts              # Server entry point
└── lib/
    └── firebase/
        ├── authClient.ts       # Authentication operations
        ├── firebaseConfig.ts   # Firebase configuration
        ├── firestoreClient.ts  # Firestore operations
        └── storageClient.ts    # Storage operations

Each client module implements specific Firebase service operations and exposes them as MCP tools.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Implement changes with tests (80%+ coverage required to pass CI workflow)
  4. Submit a pull request

License

MIT License - see LICENSE file for details

Related Resources

Troubleshooting

Common Issues

"The specified bucket does not exist" Error

If you encounter this error when trying to access Firebase Storage:

  1. Check that your Firebase project has Storage enabled

    • Go to the Firebase Console
    • Navigate to Storage
    • Complete the initial setup if you haven't already
  2. Verify the correct bucket name

    • The default bucket name is usually [projectId].appspot.com
    • Some projects use [projectId].firebasestorage.app instead
    • You can find your bucket name in the Firebase Console under Storage
  3. Set the FIREBASE_STORAGE_BUCKET environment variable

    • Add the correct bucket name to your MCP configuration
    • Example: "FIREBASE_STORAGE_BUCKET": "your-project-id.firebasestorage.app"

"Firebase is not initialized" Error

If you see this error:

  1. Verify your service account key path

    • Make sure the path in SERVICE_ACCOUNT_KEY_PATH is correct and absolute
    • Check that the file exists and is readable
  2. Check service account permissions

    • Ensure the service account has the necessary permissions for the Firebase services you're using
    • For Storage, the service account needs the Storage Admin role

"This query requires a composite index" Error

If you see this error when using firestore_query_collection_group with filters or ordering:

  1. Follow the provided URL in the error message to create the required index
  2. Once the index is created (which may take a few minutes), retry your query
  3. For complex queries with multiple fields, you might need to create multiple indexes

JSON Parsing Errors

If you see errors about invalid JSON:

  1. Make sure there are no console.log statements in the code

    • All logging should use console.error to avoid interfering with the JSON communication
    • The MCP protocol uses stdout for JSON communication
  2. Check for syntax errors in your requests

    • Verify that all parameters are correctly formatted
    • Check for typos in field names

Recommended Servers

Supabase MCP Server

Supabase MCP Server

A Model Context Protocol (MCP) server that provides programmatic access to the Supabase Management API. This server allows AI models and other clients to manage Supabase projects and organizations through a standardized interface.

Featured
JavaScript
MCP DuckDB Knowledge Graph Memory Server

MCP DuckDB Knowledge Graph Memory Server

A memory server for Claude that stores and retrieves knowledge graph data in DuckDB, enhancing performance and query capabilities for conversations with persistent user information.

Featured
TypeScript
dbt Semantic Layer MCP Server

dbt Semantic Layer MCP Server

A server that enables querying the dbt Semantic Layer through natural language conversations with Claude Desktop and other AI assistants, allowing users to discover metrics, create queries, analyze data, and visualize results.

Featured
TypeScript
Metabase MCP Server

Metabase MCP Server

Enables AI assistants to interact with Metabase databases and dashboards, allowing users to list and execute queries, access data visualizations, and interact with database resources through natural language.

Featured
JavaScript
Airtable MCP Server

Airtable MCP Server

A Model Context Protocol server that provides tools for programmatically managing Airtable bases, tables, fields, and records through Claude Desktop or other MCP clients.

Featured
JavaScript
mcp-shodan

mcp-shodan

MCP server for querying the Shodan API and Shodan CVEDB. This server provides tools for IP lookups, device searches, DNS lookups, vulnerability queries, CPE lookups, and more.

Featured
JavaScript
Verodat MCP Server

Verodat MCP Server

An MCP server that integrates Verodat's data management capabilities with AI systems like Claude Desktop, enabling users to manage accounts, workspaces, and datasets, as well as perform AI-powered queries on their data.

Official
Local
TypeScript
Tembo MCP Server

Tembo MCP Server

An MCP server that enables Claude to interact with Tembo Cloud platform API, allowing users to manage Tembo Cloud resources through natural language.

Official
TypeScript
MongoDB MCP Server

MongoDB MCP Server

Provides read-only access to MongoDB databases for LLMs to inspect collection schemas and execute aggregation pipelines.

Official
JavaScript
nile-mcp

nile-mcp

MCP server for Nile Database - Manage and query databases, tenants, users, auth using LLMs

Official
TypeScript