firebase-mcp

firebase-mcp

A Model Context Protocol server that exposes Firebase Firestore and Authentication to AI agents, supporting multi-project configurations and read operations.

Category
访问服务器

README

firebase-mcp

A Model Context Protocol (MCP) server that exposes Firebase Firestore and Authentication to AI agents. Built with the Firebase Admin SDK, it runs over stdio and is designed to be wired directly into any MCP-compatible host (Cursor, Claude Desktop, etc.).

Features

  • 13 Firestore read operations — list/browse collections and documents, query (including collection groups), aggregates, counts, schema sampling, composite indexes, distinct value counts, and list_paths for configured path templates
  • 2 Firebase Auth operations — look up users by UID or email, list users with pagination
  • Multi-project support — configure multiple Firebase projects in one config file; each tool call targets a specific project via projectId
  • Glob-based access control — allow/deny rules evaluated per Firestore path before any read is performed
  • Pagination on query_collection, read_collection, and list_users via cursor-based tokens
  • Batch fetching with configurable maxBatchFetchSize
  • Schema inference via get_collection_schema — samples documents and infers field types without reading the full collection
  • Distinct value counts via distinct_values — count occurrences of unique field values across a collection or collection group
  • Normalized output — Firestore Timestamps, GeoPoints, and DocumentReferences are converted to JSON-serializable values on all tools
  • Zero runtime state — each tool call hits Firebase directly through the Admin SDK

Tools

Config

Tool Description
create_config Returns a full config template (every supported field) and setup instructions. Use this when no firebase-mcp.json exists yet.
get_config Returns the current in-memory config, listing all available projects. Call this first to discover valid projectId values.
reload_config Re-reads firebase-mcp.json from disk and evicts all cached project runtimes.

Firestore (firestore_read)

All operations are dispatched through the single firestore_read tool via the operation field. Every call requires a projectId matching a key in firebase-mcp.json.

Operation Description
list_paths Lists named firestore.paths templates: placeholders, resolved type (collection vs document), optional description.
list_collections List root collections or subcollections of a document. Optionally include document counts.
list_documents List all document IDs in a collection, including phantom documents. Optionally include subcollection names.
read_collection Read documents from a collection with optional phantom-doc surfacing.
get_document Fetch a single document by path.
get_many_documents Batch-fetch documents by a list of paths or a collection + ID list.
query_collection Query with filters, ordering, limit, and pagination.
query_collection_group Query across all collections sharing the same name, regardless of parent path.
count_documents Server-side document count with optional filters.
aggregate_collection Native sum(), avg(), and count() aggregations without fetching documents.
get_collection_schema Sample a collection from both ends and infer field types.
list_indexes List Firestore composite indexes for the project.
distinct_values Count occurrences of each unique value (or value combination) of one or more fields across a collection or collection group.

Auth (auth_read)

All operations are dispatched through the single auth_read tool via the operation field. Every call requires a projectId.

Operation Description
get_user Fetch a Firebase Auth user by UID or email.
list_users List Firebase Auth users with optional pagination via pageToken.

Requirements

  • Node.js 18+
  • A Firebase project with Firestore enabled
  • A service account JSON key with Firestore and Auth read permissions

Setup

1. Create firebase-mcp.json

The config supports multiple projects under a projects key. Each key becomes the projectId value you pass to tool calls.

{
  "projects": {
    "my-app": {
      "firebase": {
        "projectId": "your-firebase-project-id",
        "serviceAccountPath": "secrets/serviceAccount.json"
      },
      "firestore": {
        "rules": {
          "allow": ["**"],
          "deny": []
        },
        "maxCollectionReadSize": 100,
        "maxBatchFetchSize": 200,
        "paths": {
          "example_orders": {
            "template": "customers/{customerId}/orders",
            "description": "Optional hint for agents; omit or replace with your own entries"
          }
        }
      },
      "timeouts": {
        "callMs": 15000
      }
    }
  }
}

To configure multiple projects, add additional keys under projects:

{
  "projects": {
    "prod": { "firebase": { ... }, "firestore": { ... } },
    "staging": { "firebase": { ... }, "firestore": { ... } }
  }
}

2. Add your service account key

Place your Firebase service account JSON at any path you prefer — you'll reference it in firebase-mcp.json above. Paths are resolved relative to the working directory when the server starts, or you can use an absolute path.

3. Wire it into your MCP host

See the Connecting to Cursor section below — no installation step required when using npx.

Configuration

Field Type Default Description
projects object — Map of project keys to project configs
projects.<key>.firebase.projectId string — Firebase project ID
projects.<key>.firebase.serviceAccountPath string — Path to service account JSON (relative to CWD or absolute)
projects.<key>.firestore.rules.allow string[] — Glob patterns for allowed Firestore paths
projects.<key>.firestore.rules.deny string[] — Glob patterns for denied Firestore paths (evaluated first)
projects.<key>.firestore.maxCollectionReadSize number 100 Default document limit for collection reads
projects.<key>.firestore.maxBatchFetchSize number 200 Maximum documents per batch fetch
projects.<key>.firestore.paths object {} Named path templates ({ name: { template, description? } }); {param} placeholders. Surfaces via list_paths.
projects.<key>.timeouts.callMs number 15000 Max duration of a single tool call in ms (integer, min 100, max 120000)

A custom config path can be passed at startup:

node dist/cli/index.js --config /path/to/firebase-mcp.json

Access Control

Firestore path access is governed by glob patterns evaluated with micromatch. Deny rules take precedence over allow rules. Every tool call checks the target path before hitting Firestore.

{
  "rules": {
    "allow": ["users/**", "products/**"],
    "deny": ["users/*/private/**"]
  }
}

Connecting to Cursor

Add to your MCP config (e.g. .cursor/mcp.json):

{
  "mcpServers": {
    "firebase": {
      "command": "npx",
      "args": ["-y", "firebase-mcp", "--config", "/path/to/firebase-mcp.json"]
    }
  }
}

npx -y will download and cache the package automatically on first run. No manual installation needed.

firestore_read and auth_read are safe to add to Cursor's tool allowlist for unattended use. get_config, reload_config, and create_config are also read-only and safe to allowlist.

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选