Firebase MCP server

Integrates with Firebase services to enable user management, document operations, and file handling for applications using Firebase Authentication, Firestore, and Storage.
Back to servers
Provider
gemini-dk
Release date
Feb 24, 2025
Language
TypeScript
Stats
10 stars

The Firebase MCP Server provides a unified interface to interact with various Firebase services including Authentication, Firestore, and Storage. This server implements the Model Context Protocol (MCP) to standardize access to Firebase's core functionalities.

Installation

To set up the Firebase MCP Server, follow these steps:

  1. Clone the repository and build the project:

    git clone https://github.com/gemini-dk/mcp-server-firebase
    cd mcp-server-firebase
    npm install
    npm run build
    
  2. Obtain your Firebase service account key:

    • Navigate to Firebase Console > Project Settings > Service accounts
    • Click "Generate new private key"
    • Save the JSON file to a secure location in your project directory
  3. Configure the MCP settings by creating a mcp_settings.json file:

    {
      "firebase-mcp": {
        "command": "node",
        "args": [
          "/path/to/mcp-server-firebase/dist/index.js"
        ],
        "env": {
          "SERVICE_ACCOUNT_KEY_PATH": "/path/to/serviceAccountKey.json"
        }
      }
    }
    

    Be sure to replace:

    • /path/to/mcp-server-firebase with the actual directory path where you cloned the repository
    • /path/to/serviceAccountKey.json with the path to your Firebase service account key file

Using the Firebase MCP Server

The server provides access to several Firebase services through a unified API interface:

Authentication API

You can retrieve user information using ID or email:

// Example of getting a user by email
const userResponse = await mcpClient.send({
  model: "firebase-auth",
  action: "getUser",
  params: {
    email: "[email protected]"
  }
});

// Example of getting a user by ID
const userResponse = await mcpClient.send({
  model: "firebase-auth",
  action: "getUser",
  params: {
    uid: "user123"
  }
});

Firestore API

The server supports common Firestore operations:

// Adding/updating a document
const addResponse = await mcpClient.send({
  model: "firebase-firestore",
  action: "setDoc",
  params: {
    collection: "users",
    docId: "user123",
    data: {
      name: "John Doe",
      email: "[email protected]"
    }
  }
});

// Listing documents in a collection
const listResponse = await mcpClient.send({
  model: "firebase-firestore",
  action: "listDocs",
  params: {
    collection: "users"
  }
});

// Deleting a document
const deleteResponse = await mcpClient.send({
  model: "firebase-firestore",
  action: "deleteDoc",
  params: {
    collection: "users",
    docId: "user123"
  }
});

Storage API

Access and manage files in Firebase Storage:

// List files in a directory
const filesResponse = await mcpClient.send({
  model: "firebase-storage",
  action: "listFiles",
  params: {
    path: "images/"
  }
});

// Get file metadata and download URL
const fileInfoResponse = await mcpClient.send({
  model: "firebase-storage",
  action: "getFileInfo",
  params: {
    path: "images/profile.jpg"
  }
});

Configuration Options

You can customize your Firebase MCP Server by adding additional environment variables to the env section of your mcp_settings.json file:

"env": {
  "SERVICE_ACCOUNT_KEY_PATH": "/path/to/serviceAccountKey.json",
  "FIREBASE_DATABASE_URL": "https://your-project-id.firebaseio.com",
  "STORAGE_BUCKET": "your-project-id.appspot.com"
}

These settings allow you to specify which Firebase project and resources the MCP server will connect to.

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later