Navigation
MCP Server Firebase: Seamless Integration & Enterprise Security - MCP Implementation

MCP Server Firebase: Seamless Integration & Enterprise Security

Unify real-time apps with MCP Server Firebase: seamless Firebase integration, cloud-scale backend, and enterprise-grade security. Built for speed – no fluff." )

Developer Tools
4.0(29 reviews)
43 saves
20 comments

Users create an average of 40 projects per month with this tool

About MCP Server Firebase

What is MCP Server Firebase: Seamless Integration & Enterprise Security?

MCP Server Firebase is a protocol implementation enabling bidirectional communication between clients and Firebase services through two execution modes: a local Node.js server using the Firebase Admin SDK, and a serverless Cloudflare Workers instance leveraging the Firebase REST API. This architecture ensures compatibility with both development environments and production-grade edge computing.

Key Features of MCP Server Firebase

  • Bi-directional data synchronization with Firestore: Full CRUD operations (create, read, update, delete) with query filtering capabilities
  • Subcollection management for complex data hierarchies
  • Environment-agnostic design supporting local development and serverless deployment
  • Production-ready security controls through Firebase Authentication integration

MCP Server Firebase Features

How to Use MCP Server Firebase

Deployment follows a modular setup:

  1. Configure environment variables for credentials
  2. Select execution mode via:
    • Local server: npm run dev with Admin SDK
    • Edge deployment: npm run dev:worker for Cloudflare Workers
  3. Connect clients using the MCP SDK with appropriate endpoint configuration

Use Cases for MCP Server Firebase

  • Real-time collaborative applications needing Firestore synchronization
  • Edge-computing scenarios requiring low-latency Firebase access
  • Enterprise applications needing strict separation between client and server credentials
  • Hybrid environments combining local development with serverless production workflows

MCP Server Firebase FAQ

FAQ for MCP Server Firebase

  • Q: How to secure API keys?
    A: Use environment variables and Cloudflare Secrets to avoid hardcoded credentials. Never commit service account files to repositories.
  • Q: What permissions are required?
    A: The Firebase service account needs admin privileges for Firestore. Workers mode requires API key access matching deployed functions.
  • Q: Can both modes share the same database?
    A: Yes, both configurations connect to the same Firebase project. Ensure security rules enforce proper access controls.
  • Q: How to handle large datasets?
    A: Use query pagination with Firestore's offset and limit parameters through the list operations API.

Content

MCP Server Firebase

這是一個基於 Firebase 的 Model Context Protocol (MCP) 服務器實現,提供兩種運行模式:

  1. 本地 Node.js 模式 (使用 Firebase Admin SDK)
  2. Cloudflare Workers 模式 (使用 Firebase REST API)

功能

  • Firestore 資料庫操作 (讀取、寫入、更新、刪除文檔)
  • 集合和子集合的列表查詢
  • 支援過濾條件的查詢

必要條件

  • Node.js 18 或更高版本
  • Firebase 專案
  • Firebase 服務帳號 (用於本地模式)
  • Firebase Web API 密鑰 (用於 Cloudflare Workers 模式)

安裝

  1. 克隆此專案:
git clone https://github.com/[您的用戶名]/mcp-server-firebase.git
cd mcp-server-firebase
  1. 安裝依賴:
npm install

配置

本地模式配置 (Firebase Admin SDK)

  1. 從 Firebase 控制台下載服務帳號金鑰檔案:
* 前往 Firebase 控制台 > 專案設置 > 服務帳號 > 生成新的私鑰
  1. 將下載的 JSON 文件保存到專案目錄中 (檔名不重要,但請記住路徑)

  2. 設置環境變量:

export SERVICE_ACCOUNT_KEY_PATH="/path/to/your-service-account.json"

Cloudflare Workers 模式配置

  1. 更新 wrangler.toml 文件中的環境變量:
* FIREBASE_PROJECT_ID: 您的 Firebase 專案 ID
* FIREBASE_API_KEY: 您的 Firebase Web API 密鑰
* FIREBASE_AUTH_DOMAIN: 通常是 `[PROJECT_ID].firebaseapp.com`
  1. 或者使用 Cloudflare Secrets 設置環境變量:
npx wrangler secret put FIREBASE_PROJECT_ID
npx wrangler secret put FIREBASE_API_KEY
npx wrangler secret put FIREBASE_AUTH_DOMAIN

運行

本地模式 (Firebase Admin SDK)

# 編譯 TypeScript 並運行服務器
npm run dev

或使用提供的腳本設置環境變量並運行:

# 互動式設置 Firebase 環境變量
node setup-firebase-env.js

# 根據腳本提示運行後續命令

Cloudflare Workers 模式 (本地開發)

# 編譯 TypeScript 並在本地運行 Workers
npm run dev:worker

同時運行兩種模式

npm run dev:all

部署

部署到 Cloudflare Workers

# 部署到開發環境
npm run deploy:worker

# 部署到生產環境
npm run deploy:production

目錄結構

  • src/index.ts - 本地 Node.js 模式的入口點
  • src/worker.ts - Cloudflare Workers 模式的入口點
  • src/mcp/ - MCP 服務器實現代碼
  • src/lib/ - 公共工具函數

使用方法

連接到 MCP 服務器

在您的客戶端應用中,使用 MCP SDK 連接到服務器:

// 本地模式連接
const mcp = createMcpClient({
  endpoint: "http://localhost:8765"
});

// Cloudflare Workers 模式連接
const mcp = createMcpClient({
  endpoint: "https://your-worker.workers.dev"
});

使用 MCP 工具操作 Firestore

// 添加文檔
const result = await mcp.tools.mcp_firebase_mcp_firestore_add_document({
  documentPath: "collection/documentId",
  data: { field1: "value1", field2: 42 }
});

// 獲取文檔
const doc = await mcp.tools.mcp_firebase_mcp_firestore_get_document({
  documentPath: "collection/documentId"
});

// 更新文檔
await mcp.tools.mcp_firebase_mcp_firestore_update_document({
  documentPath: "collection/documentId",
  data: { field1: "updated value" }
});

// 刪除文檔
await mcp.tools.mcp_firebase_mcp_firestore_delete_document({
  documentPath: "collection/documentId"
});

// 列出集合中的文檔
const docs = await mcp.tools.mcp_firebase_mcp_firestore_list_documents({
  collectionPath: "collection",
  filters: [
    { field: "field2", operator: ">", value: 40 }
  ]
});

// 列出集合
const collections = await mcp.tools.mcp_firebase_mcp_firestore_list_collections({
  parentPath: "collection/documentId"  // 可選
});

安全注意事項

  • 請勿將服務帳號金鑰或 API 密鑰提交到 Git 存儲庫
  • 在部署前確保所有敏感信息已設置為環境變量或 Secrets
  • 為 Firestore 設置適當的安全規則

注意事項

  • src/worker.ts 是 Cloudflare Workers 部署版本
  • src/index.ts 是本地運行版本
  • 請確保 Firebase 服務帳號具有適當的權限

許可證

此專案使用 MIT 許可證。

Related MCP Servers & Clients